Changeset View
Changeset View
Standalone View
Standalone View
stand/userboot/userboot/devicename.c
| Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | #endif | ||||
| return (0); | return (0); | ||||
| fail: | fail: | ||||
| free(idev); | free(idev); | ||||
| return (err); | return (err); | ||||
| } | } | ||||
| char * | |||||
| userboot_fmtdev(void *vdev) | |||||
| { | |||||
| struct devdesc *dev = (struct devdesc *)vdev; | |||||
| static char buf[128]; /* XXX device length constant? */ | |||||
| switch(dev->d_dev->dv_type) { | |||||
| case DEVT_NONE: | |||||
| strcpy(buf, "(no device)"); | |||||
| break; | |||||
| case DEVT_CD: | |||||
| sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); | |||||
| break; | |||||
| case DEVT_DISK: | |||||
| return (disk_fmtdev(vdev)); | |||||
| case DEVT_NET: | |||||
| sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); | |||||
| break; | |||||
| case DEVT_ZFS: | |||||
| #if defined(USERBOOT_ZFS_SUPPORT) | |||||
| return (zfs_fmtdev(vdev)); | |||||
| #else | |||||
| sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit); | |||||
| #endif | |||||
| break; | |||||
| } | |||||
| return (buf); | |||||
| } | |||||
| /* | /* | ||||
| * Set currdev to suit the value being supplied in (value) | * Set currdev to suit the value being supplied in (value) | ||||
| */ | */ | ||||
| int | int | ||||
| userboot_setcurrdev(struct env_var *ev, int flags, const void *value) | userboot_setcurrdev(struct env_var *ev, int flags, const void *value) | ||||
| { | { | ||||
| struct disk_devdesc *ncurr; | struct disk_devdesc *ncurr; | ||||
| int rv; | int rv; | ||||
| if ((rv = userboot_parsedev(&ncurr, value, NULL)) != 0) | if ((rv = userboot_parsedev(&ncurr, value, NULL)) != 0) | ||||
| return (rv); | return (rv); | ||||
| free(ncurr); | free(ncurr); | ||||
| return (mount_currdev(ev, flags, value)); | return (mount_currdev(ev, flags, value)); | ||||
| } | } | ||||