Changeset View
Changeset View
Standalone View
Standalone View
stand/libofw/devicename.c
Show All 25 Lines | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <stand.h> | #include <stand.h> | ||||
#include "bootstrap.h" | #include "bootstrap.h" | ||||
#include "libofw.h" | #include "libofw.h" | ||||
#include "libzfs.h" | |||||
static int ofw_parsedev(struct ofw_devdesc **, const char *, const char **); | static int ofw_parsedev(struct ofw_devdesc **, const char *, const char **); | ||||
/* | /* | ||||
* Point (dev) at an allocated device specifier for the device matching the | * Point (dev) at an allocated device specifier for the device matching the | ||||
* path in (devspec). If it contains an explicit device specification, | * path in (devspec). If it contains an explicit device specification, | ||||
* use that. If not, use the default device. | * use that. If not, use the default device. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
found: | found: | ||||
if (path != NULL) | if (path != NULL) | ||||
*path = s; | *path = s; | ||||
idev = malloc(sizeof(struct ofw_devdesc)); | idev = malloc(sizeof(struct ofw_devdesc)); | ||||
if (idev == NULL) { | if (idev == NULL) { | ||||
printf("ofw_parsedev: malloc failed\n"); | printf("ofw_parsedev: malloc failed\n"); | ||||
return ENOMEM; | return ENOMEM; | ||||
} | } | ||||
strcpy(idev->d_path, name); | |||||
idev->dd.d_dev = dv; | idev->dd.d_dev = dv; | ||||
if (dv->dv_type == DEVT_ZFS) { | if (dv->dv_parsedev != NULL) { | ||||
p = devspec + strlen(dv->dv_name); | p = devspec + strlen(dv->dv_name); | ||||
free(idev); | free(idev); | ||||
err = zfs_parsedev((struct devdesc **)&idev, p, path); | err = dv->dv_parsedev((struct devdesc **)&idev, p, path); | ||||
if (err != 0) { | if (err != 0) { | ||||
return (err); | return (err); | ||||
} | } | ||||
} else { | |||||
strcpy(idev->d_path, name); | |||||
} | } | ||||
if (dev == NULL) { | if (dev == NULL) { | ||||
free(idev); | free(idev); | ||||
} else { | } else { | ||||
*dev = idev; | *dev = idev; | ||||
} | } | ||||
return(0); | return(0); | ||||
Show All 15 Lines |