Changeset View
Changeset View
Standalone View
Standalone View
sys/boot/efi/loader/devicename.c
Context not available. | |||||
#include <stand.h> | #include <stand.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <sys/disklabel.h> | #include <sys/disklabel.h> | ||||
#include <sys/param.h> | |||||
#include "bootstrap.h" | #include "bootstrap.h" | ||||
#ifdef ZFS_EFI_BOOT | |||||
#include "libzfs.h" | |||||
#endif | |||||
#include <efi.h> | #include <efi.h> | ||||
#include <efilib.h> | #include <efilib.h> | ||||
Context not available. | |||||
static int efi_parsedev(struct devdesc **, const char *, const char **); | static int efi_parsedev(struct 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. | ||||
Context not available. | |||||
struct devsw *dv; | struct devsw *dv; | ||||
char *cp; | char *cp; | ||||
const char *np; | const char *np; | ||||
int i, err; | int i; | ||||
/* minimum length check */ | /* minimum length check */ | ||||
if (strlen(devspec) < 2) | if (strlen(devspec) < 2) | ||||
Context not available. | |||||
if (devsw[i] == NULL) | if (devsw[i] == NULL) | ||||
return (ENOENT); | return (ENOENT); | ||||
idev = malloc(sizeof(struct devdesc)); | np = devspec + strlen(dv->dv_name); | ||||
if (idev == NULL) | |||||
return (ENOMEM); | |||||
idev->d_dev = dv; | #ifdef ZFS_EFI_BOOT | ||||
idev->d_type = dv->dv_type; | if (dv->dv_type == DEVT_ZFS) { | ||||
idev->d_unit = -1; | int err; | ||||
err = 0; | idev = malloc(sizeof(struct zfs_devdesc)); | ||||
np = devspec + strlen(dv->dv_name); | if (idev == NULL) | ||||
if (*np != '\0' && *np != ':') { | return (ENOMEM); | ||||
idev->d_unit = strtol(np, &cp, 0); | |||||
if (cp == np) { | err = zfs_parsedev((struct zfs_devdesc*)idev, np, path); | ||||
idev->d_unit = -1; | if (err != 0) { | ||||
free(idev); | free(idev); | ||||
return (EUNIT); | return (err); | ||||
} | } | ||||
*dev = idev; | |||||
cp = strchr(np + 1, ':'); | |||||
} else { | |||||
#endif | |||||
idev = malloc(sizeof(struct devdesc)); | |||||
if (idev == NULL) | |||||
return (ENOMEM); | |||||
idev->d_dev = dv; | |||||
idev->d_type = dv->dv_type; | |||||
idev->d_unit = -1; | |||||
if (*np != '\0' && *np != ':') { | |||||
idev->d_unit = strtol(np, &cp, 0); | |||||
if (cp == np) { | |||||
idev->d_unit = -1; | |||||
free(idev); | |||||
return (EUNIT); | |||||
} | |||||
} | |||||
#ifdef ZFS_EFI_BOOT | |||||
} | } | ||||
#endif | |||||
if (*cp != '\0' && *cp != ':') { | if (*cp != '\0' && *cp != ':') { | ||||
free(idev); | free(idev); | ||||
return (EINVAL); | return (EINVAL); | ||||
Context not available. | |||||
efi_fmtdev(void *vdev) | efi_fmtdev(void *vdev) | ||||
{ | { | ||||
struct devdesc *dev = (struct devdesc *)vdev; | struct devdesc *dev = (struct devdesc *)vdev; | ||||
static char buf[32]; /* XXX device length constant? */ | static char buf[SPECNAMELEN + 1]; | ||||
switch(dev->d_type) { | switch(dev->d_type) { | ||||
#ifdef ZFS_EFI_BOOT | |||||
case DEVT_ZFS: | |||||
return (zfs_fmtdev(dev)); | |||||
#endif | |||||
case DEVT_NONE: | case DEVT_NONE: | ||||
strcpy(buf, "(no device)"); | strcpy(buf, "(no device)"); | ||||
break; | break; | ||||
Context not available. | |||||
break; | break; | ||||
} | } | ||||
return(buf); | return (buf); | ||||
} | } | ||||
/* | /* | ||||
Context not available. | |||||
rv = efi_parsedev(&ncurr, value, NULL); | rv = efi_parsedev(&ncurr, value, NULL); | ||||
if (rv != 0) | if (rv != 0) | ||||
return(rv); | return (rv); | ||||
free(ncurr); | free(ncurr); | ||||
env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); | env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); | ||||
Context not available. |