Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F109347960
D37335.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D37335.diff
View Options
diff --git a/stand/common/disk.h b/stand/common/disk.h
--- a/stand/common/disk.h
+++ b/stand/common/disk.h
@@ -111,7 +111,7 @@
* Print information about slices on a disk.
*/
extern int disk_print(struct disk_devdesc *, char *, int);
-extern int disk_parsedev(struct disk_devdesc *, const char *, const char **);
+extern int disk_parsedev(struct devdesc **, const char *, const char **);
char *disk_fmtdev(struct devdesc *vdev);
diff --git a/stand/common/disk.c b/stand/common/disk.c
--- a/stand/common/disk.c
+++ b/stand/common/disk.c
@@ -413,11 +413,12 @@
}
int
-disk_parsedev(struct disk_devdesc *dev, const char *devspec, const char **path)
+disk_parsedev(struct devdesc **idev, const char *devspec, const char **path)
{
int unit, slice, partition;
const char *np;
char *cp;
+ struct disk_devdesc *dev;
np = devspec;
unit = -1;
@@ -470,9 +471,13 @@
if (*cp != '\0' && *cp != ':')
return (EINVAL);
+ dev = malloc(sizeof(*dev));
+ if (dev == NULL)
+ return (ENOMEM);
dev->dd.d_unit = unit;
dev->d_slice = slice;
dev->d_partition = partition;
+ *idev = &dev->dd;
if (path != NULL)
*path = (*cp == '\0') ? cp: cp + 1;
return (0);
diff --git a/stand/efi/libefi/devicename.c b/stand/efi/libefi/devicename.c
--- a/stand/efi/libefi/devicename.c
+++ b/stand/efi/libefi/devicename.c
@@ -111,11 +111,7 @@
break;
case DEVT_DISK:
- idev = malloc(sizeof(struct disk_devdesc));
- if (idev == NULL)
- return (ENOMEM);
-
- err = disk_parsedev((struct disk_devdesc *)idev, np, path);
+ err = disk_parsedev(&idev, np, path);
if (err != 0)
goto fail;
break;
diff --git a/stand/i386/libi386/devicename.c b/stand/i386/libi386/devicename.c
--- a/stand/i386/libi386/devicename.c
+++ b/stand/i386/libi386/devicename.c
@@ -84,7 +84,7 @@
static int
i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path)
{
- struct i386_devdesc *idev;
+ struct i386_devdesc *idev = NULL;
struct devsw *dv;
int i, unit, err;
char *cp;
@@ -113,11 +113,7 @@
break;
case DEVT_DISK:
- idev = malloc(sizeof(struct i386_devdesc));
- if (idev == NULL)
- return (ENOMEM);
-
- err = disk_parsedev((struct disk_devdesc *)idev, np, path);
+ err = disk_parsedev((struct devdesc **)&idev, np, path);
if (err != 0)
goto fail;
break;
diff --git a/stand/i386/zfsboot/zfsboot.c b/stand/i386/zfsboot/zfsboot.c
--- a/stand/i386/zfsboot/zfsboot.c
+++ b/stand/i386/zfsboot/zfsboot.c
@@ -168,7 +168,7 @@
{
unsigned i;
int auto_boot, fd, nextboot = 0;
- struct disk_devdesc devdesc;
+ struct disk_devdesc *devdesc;
bios_getmem();
@@ -215,11 +215,13 @@
if (devsw[i]->dv_init != NULL)
(devsw[i]->dv_init)();
- disk_parsedev(&devdesc, boot_devname + 4, NULL);
+ /* XXX assumes this will be a disk, but it looks likely give above */
+ disk_parsedev((struct devdesc **)&devdesc, boot_devname + 4, NULL);
- bootdev = MAKEBOOTDEV(dev_maj[DEVT_DISK], devdesc.d_slice + 1,
- devdesc.dd.d_unit,
- devdesc.d_partition >= 0 ? devdesc.d_partition : 0xff);
+ bootdev = MAKEBOOTDEV(dev_maj[DEVT_DISK], devdesc->d_slice + 1,
+ devdesc->dd.d_unit,
+ devdesc->d_partition >= 0 ? devdesc->d_partition : 0xff);
+ free(devdesc);
/*
* devformat() can be called only after dv_init
diff --git a/stand/uboot/devicename.c b/stand/uboot/devicename.c
--- a/stand/uboot/devicename.c
+++ b/stand/uboot/devicename.c
@@ -115,7 +115,8 @@
#ifdef LOADER_DISK_SUPPORT
case DEVT_DISK:
- err = disk_parsedev((struct disk_devdesc *)idev, np, path);
+ free(idev);
+ err = disk_parsedev((struct devdesc **)&idev, np, path);
if (err != 0)
goto fail;
break;
diff --git a/stand/uboot/main.c b/stand/uboot/main.c
--- a/stand/uboot/main.c
+++ b/stand/uboot/main.c
@@ -206,7 +206,7 @@
static void
get_load_device(int *type, int *unit, int *slice, int *partition)
{
- struct disk_devdesc dev;
+ struct disk_devdesc *dev;
char *devstr;
const char *p;
char *endp;
@@ -237,10 +237,11 @@
if (*type & DEV_TYP_STOR) {
size_t len = strlen(p);
if (strcspn(p, " .") == len && strcspn(p, ":") >= len - 1 &&
- disk_parsedev(&dev, p, NULL) == 0) {
- *unit = dev.dd.d_unit;
- *slice = dev.d_slice;
- *partition = dev.d_partition;
+ disk_parsedev((struct devdesc **)&dev, p, NULL) == 0) {
+ *unit = dev->dd.d_unit;
+ *slice = dev->d_slice;
+ *partition = dev->d_partition;
+ free(dev);
return;
}
}
diff --git a/stand/userboot/userboot/devicename.c b/stand/userboot/userboot/devicename.c
--- a/stand/userboot/userboot/devicename.c
+++ b/stand/userboot/userboot/devicename.c
@@ -38,7 +38,7 @@
#include "libzfs.h"
#endif
-static int userboot_parsedev(struct disk_devdesc **dev, const char *devspec,
+static int userboot_parsedev(struct devdesc **dev, const char *devspec,
const char **path);
/*
@@ -49,7 +49,7 @@
int
userboot_getdev(void **vdev, const char *devspec, const char **path)
{
- struct disk_devdesc **dev = (struct disk_devdesc **)vdev;
+ struct devdesc **dev = (struct devdesc **)vdev;
int rv;
/*
@@ -87,10 +87,10 @@
*
*/
static int
-userboot_parsedev(struct disk_devdesc **dev, const char *devspec,
+userboot_parsedev(struct devdesc **dev, const char *devspec,
const char **path)
{
- struct disk_devdesc *idev;
+ struct devdesc *idev;
struct devsw *dv;
int i, unit, err;
const char *cp;
@@ -119,7 +119,8 @@
break;
case DEVT_DISK:
- err = disk_parsedev(idev, np, path);
+ free(idev);
+ err = disk_parsedev(&idev, np, path);
if (err != 0)
goto fail;
break;
@@ -143,13 +144,14 @@
goto fail;
}
- idev->dd.d_unit = unit;
+ idev->d_unit = unit;
if (path != NULL)
*path = (*cp == 0) ? cp : cp + 1;
break;
case DEVT_ZFS:
#if defined(USERBOOT_ZFS_SUPPORT)
+ /* XXX assumes sizeof disk_devdesc >= sizeof zfs_devdesc */
err = zfs_parsedev((struct zfs_devdesc *)idev, np, path);
if (err != 0)
goto fail;
@@ -162,7 +164,7 @@
err = EINVAL;
goto fail;
}
- idev->dd.d_dev = dv;
+ idev->d_dev = dv;
if (dev == NULL) {
free(idev);
} else {
@@ -182,7 +184,7 @@
int
userboot_setcurrdev(struct env_var *ev, int flags, const void *value)
{
- struct disk_devdesc *ncurr;
+ struct devdesc *ncurr;
int rv;
if ((rv = userboot_parsedev(&ncurr, value, NULL)) != 0)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Feb 4, 9:24 PM (21 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16461172
Default Alt Text
D37335.diff (6 KB)
Attached To
Mode
D37335: stand: Change disk_parsedev() API
Attached
Detach File
Event Timeline
Log In to Comment