From 295586e818d338a492a6c7735a1984fdbb5eccb7 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Wed, 2 Jan 2019 20:31:15 +0000 Subject: [PATCH] i386_parsedev() needs to support fd devices MFC after: 2 weeks --- stand/i386/libi386/devicename.c | 48 ++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/stand/i386/libi386/devicename.c b/stand/i386/libi386/devicename.c index bde216f1e0b2..926a2c5a850e 100644 --- a/stand/i386/libi386/devicename.c +++ b/stand/i386/libi386/devicename.c @@ -103,23 +103,42 @@ i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path) } if (dv == NULL) return(ENOENT); - idev = malloc(sizeof(struct i386_devdesc)); - err = 0; + np = (devspec + strlen(dv->dv_name)); + idev = NULL; + err = 0; switch(dv->dv_type) { - case DEVT_NONE: /* XXX what to do here? Do we care? */ + case DEVT_NONE: break; case DEVT_DISK: + idev = malloc(sizeof(struct i386_devdesc)); + if (idev == NULL) + return (ENOMEM); + err = disk_parsedev((struct disk_devdesc *)idev, np, path); if (err != 0) goto fail; break; - case DEVT_CD: - case DEVT_NET: + case DEVT_ZFS: + idev = malloc(sizeof (struct zfs_devdesc)); + if (idev == NULL) + return (ENOMEM); + + err = zfs_parsedev((struct zfs_devdesc *)idev, np, path); + if (err != 0) + goto fail; + break; + + default: + idev = malloc(sizeof (struct devdesc)); + if (idev == NULL) + return (ENOMEM); + unit = 0; + cp = (char *)np; if (*np && (*np != ':')) { unit = strtol(np, &cp, 0); /* get unit number if present */ @@ -127,9 +146,8 @@ i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path) err = EUNIT; goto fail; } - } else { - cp = (char *)np; } + if (*cp && (*cp != ':')) { err = EINVAL; goto fail; @@ -139,21 +157,13 @@ i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path) if (path != NULL) *path = (*cp == 0) ? cp : cp + 1; break; - case DEVT_ZFS: - err = zfs_parsedev((struct zfs_devdesc *)idev, np, path); - if (err != 0) - goto fail; - break; - default: - err = EINVAL; - goto fail; } idev->dd.d_dev = dv; - if (dev == NULL) { - free(idev); - } else { + if (dev != NULL) *dev = idev; - } + else + free(idev); + return(0); fail: