From 7c6bd3d11c7409dd8a50922fe14e20a5bbe7457c Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Tue, 13 Mar 2018 14:16:40 +0200 Subject: [PATCH] loader: Remove d_type from devdesc. illumos issue #9278 --- usr/src/boot/lib/libstand/stand.h | 13 ++++++------- usr/src/boot/sys/boot/common/multiboot2.c | 2 +- usr/src/boot/sys/boot/efi/libefi/devicename.c | 3 +-- usr/src/boot/sys/boot/efi/loader/main.c | 7 ++----- usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c | 9 ++++----- usr/src/boot/sys/boot/i386/libi386/biosdisk.c | 3 +-- usr/src/boot/sys/boot/i386/libi386/bootinfo32.c | 8 ++++---- usr/src/boot/sys/boot/i386/libi386/devicename.c | 3 +-- usr/src/boot/sys/boot/i386/loader/main.c | 3 +-- usr/src/boot/sys/boot/ofw/libofw/devicename.c | 9 ++++----- usr/src/boot/sys/boot/sparc64/loader/main.c | 1 - usr/src/boot/sys/boot/uboot/common/main.c | 11 +++++------ usr/src/boot/sys/boot/uboot/lib/devicename.c | 3 +-- usr/src/boot/sys/boot/userboot/userboot/devicename.c | 17 ++++++++--------- usr/src/boot/sys/boot/userboot/userboot/main.c | 4 +--- usr/src/boot/sys/boot/zfs/zfs.c | 9 ++++----- 16 files changed, 44 insertions(+), 61 deletions(-) diff --git a/usr/src/boot/lib/libstand/stand.h b/usr/src/boot/lib/libstand/stand.h index 915302b0f5..5039803d6d 100644 --- a/usr/src/boot/lib/libstand/stand.h +++ b/usr/src/boot/lib/libstand/stand.h @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD$ - * From $NetBSD: stand.h,v 1.22 1997/06/26 19:17:40 drochner Exp $ + * From $NetBSD: stand.h,v 1.22 1997/06/26 19:17:40 drochner Exp $ */ /* @@ -131,7 +131,7 @@ extern struct fs_ops pkgfs_fsops; #define SEEK_CUR 1 /* set file offset to current plus offset */ #define SEEK_END 2 /* set file offset to EOF plus offset */ -/* +/* * Device switch */ struct devsw { @@ -167,7 +167,6 @@ extern int errno; */ struct devdesc { struct devsw *d_dev; - int d_type; int d_unit; void *d_opendata; }; @@ -286,7 +285,7 @@ extern struct dirent *readdirfd(int); extern void srandom(u_long seed); extern u_long random(void); - + /* imports from stdlib, locally modified */ extern long strtol(const char *, char **, int); extern unsigned long strtoul(const char *, char **, int); @@ -374,9 +373,9 @@ extern int null_stat(struct open_file *f, struct stat *sb); extern int null_readdir(struct open_file *f, struct dirent *d); -/* - * Machine dependent functions and data, must be provided or stubbed by - * the consumer +/* + * Machine dependent functions and data, must be provided or stubbed by + * the consumer */ extern int getchar(void); extern int ischar(void); diff --git a/usr/src/boot/sys/boot/common/multiboot2.c b/usr/src/boot/sys/boot/common/multiboot2.c index 0e3b7bbaa3..86b09a850a 100644 --- a/usr/src/boot/sys/boot/common/multiboot2.c +++ b/usr/src/boot/sys/boot/common/multiboot2.c @@ -597,7 +597,7 @@ mb_kernel_cmdline(struct preloaded_file *fp, struct devdesc *rootdev, else mb2 = true; - if (rootdev->d_type == DEVT_ZFS) + if (rootdev->d_dev->dv_type == DEVT_ZFS) zfs_root = true; /* If we have fstype set in env, reset zfs_root if needed. */ diff --git a/usr/src/boot/sys/boot/efi/libefi/devicename.c b/usr/src/boot/sys/boot/efi/libefi/devicename.c index c1c38c7a61..34062f2f25 100644 --- a/usr/src/boot/sys/boot/efi/libefi/devicename.c +++ b/usr/src/boot/sys/boot/efi/libefi/devicename.c @@ -158,7 +158,6 @@ efi_parsedev(struct devdesc **dev, const char *devspec, const char **path) } idev->d_dev = dv; - idev->d_type = dv->dv_type; if (dev != NULL) *dev = idev; @@ -177,7 +176,7 @@ efi_fmtdev(void *vdev) struct devdesc *dev = (struct devdesc *)vdev; static char buf[SPECNAMELEN + 1]; - switch (dev->d_type) { + switch (dev->d_dev->dv_type) { case DEVT_NONE: strlcpy(buf, "(no device)", sizeof (buf)); break; diff --git a/usr/src/boot/sys/boot/efi/loader/main.c b/usr/src/boot/sys/boot/efi/loader/main.c index 547418679a..dbc915d7ec 100644 --- a/usr/src/boot/sys/boot/efi/loader/main.c +++ b/usr/src/boot/sys/boot/efi/loader/main.c @@ -137,7 +137,7 @@ has_keyboard(void) } else if (DevicePathType(path) == MESSAGING_DEVICE_PATH && DevicePathSubType(path) == MSG_USB_CLASS_DP) { USB_CLASS_DEVICE_PATH *usb; - + usb = (USB_CLASS_DEVICE_PATH *)(void *)path; if (usb->DeviceClass == 3 && /* HID */ usb->DeviceSubClass == 1 && /* Boot devices */ @@ -161,7 +161,6 @@ set_devdesc_currdev(struct devsw *dev, int unit) char *devname; currdev.d_dev = dev; - currdev.d_type = currdev.d_dev->dv_type; currdev.d_unit = unit; devname = efi_fmtdev(&currdev); @@ -188,7 +187,6 @@ find_currdev(EFI_LOADED_IMAGE *img) currdev.dd.d_dev = &zfs_dev; currdev.dd.d_unit = 0; - currdev.dd.d_type = currdev.dd.d_dev->dv_type; currdev.pool_guid = pool_guid; currdev.root_guid = 0; devname = efi_fmtdev(&currdev); @@ -206,7 +204,6 @@ find_currdev(EFI_LOADED_IMAGE *img) struct disk_devdesc currdev; currdev.dd.d_dev = &efipart_hddev; - currdev.dd.d_type = currdev.dd.d_dev->dv_type; currdev.dd.d_unit = dp->pd_unit; currdev.d_slice = -1; currdev.d_partition = -1; @@ -890,7 +887,7 @@ command_chain(int argc, char *argv[]) struct disk_devdesc *d_dev; pdinfo_t *hd, *pd; - switch (dev->d_type) { + switch (dev->d_dev->dv_type) { case DEVT_ZFS: z_dev = (struct zfs_devdesc *)dev; loaded_image->DeviceHandle = diff --git a/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c b/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c index 8abf4f0b2f..89eb2281a4 100644 --- a/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c +++ b/usr/src/boot/sys/boot/i386/gptzfsboot/zfsboot.c @@ -182,7 +182,7 @@ main(void) /* * zfs_fmtdev() can be called only after dv_init */ - if (bdev != NULL && bdev->dd.d_type == DEVT_ZFS) { + if (bdev != NULL && bdev->dd.d_dev->dv_type == DEVT_ZFS) { /* set up proper device name string for ZFS */ strncpy(boot_devname, zfs_fmtdev(bdev), sizeof (boot_devname)); } @@ -373,7 +373,7 @@ load(void) bootinfo.bi_esymtab = VTOP(p); bootinfo.bi_kernelname = VTOP(kname); - if (bdev->dd.d_type == DEVT_ZFS) { + if (bdev->dd.d_dev->dv_type == DEVT_ZFS) { zfsargs.size = sizeof(zfsargs); zfsargs.pool = bdev->d_kind.zfs.pool_guid; zfsargs.root = bdev->d_kind.zfs.root_guid; @@ -409,12 +409,12 @@ mount_root(char *arg) if (bdev != NULL) free(bdev); bdev = ddesc; - if (bdev->dd.d_type == DEVT_DISK) { + if (bdev->dd.d_dev->dv_type == DEVT_DISK) { if (bdev->d_kind.biosdisk.partition == -1) part = 0xff; else part = bdev->d_kind.biosdisk.partition; - bootdev = MAKEBOOTDEV(dev_maj[bdev->dd.d_type], + bootdev = MAKEBOOTDEV(dev_maj[bdev->dd.d_dev->dv_type], bdev->d_kind.biosdisk.slice + 1, bdev->dd.d_unit, part); bootinfo.bi_bios_dev = bd_unit2bios(bdev->dd.d_unit); @@ -638,7 +638,6 @@ probe_partition(void *arg, const char *partname, if (pool_guid != 0 && bdev == NULL) { bdev = malloc(sizeof (struct i386_devdesc)); bzero(bdev, sizeof (struct i386_devdesc)); - bdev->dd.d_type = DEVT_ZFS; bdev->dd.d_dev = &zfs_dev; bdev->d_kind.zfs.pool_guid = pool_guid; diff --git a/usr/src/boot/sys/boot/i386/libi386/biosdisk.c b/usr/src/boot/sys/boot/i386/libi386/biosdisk.c index 100fa0b481..a1854f8ff6 100644 --- a/usr/src/boot/sys/boot/i386/libi386/biosdisk.c +++ b/usr/src/boot/sys/boot/i386/libi386/biosdisk.c @@ -361,7 +361,6 @@ bd_open(struct open_file *f, ...) * would overflow so it should be safe to perform here. */ disk.dd.d_dev = dev->dd.d_dev; - disk.dd.d_type = dev->dd.d_type; disk.dd.d_unit = dev->dd.d_unit; disk.d_slice = -1; disk.d_partition = -1; @@ -749,7 +748,7 @@ bd_getdev(struct i386_devdesc *d) { struct disk_devdesc *dev; int biosdev; - int major; + int major; int rootdev; char *nip, *cp; int i, unit; diff --git a/usr/src/boot/sys/boot/i386/libi386/bootinfo32.c b/usr/src/boot/sys/boot/i386/libi386/bootinfo32.c index 3386fd777f..fd54ac4be5 100644 --- a/usr/src/boot/sys/boot/i386/libi386/bootinfo32.c +++ b/usr/src/boot/sys/boot/i386/libi386/bootinfo32.c @@ -148,8 +148,8 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t howto = bi_getboothowto(args); - /* - * Allow the environment variable 'rootdev' to override the supplied device + /* + * Allow the environment variable 'rootdev' to override the supplied device * This should perhaps go to MI code and/or have $rootdev tested/set by * MI code before launching the kernel. */ @@ -168,7 +168,7 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t /* XXX - use a default bootdev of 0. Is this ok??? */ bootdevnr = 0; - switch(rootdev->dd.d_type) { + switch(rootdev->dd.d_dev->dv_type) { case DEVT_CD: /* Pass in BIOS device number. */ bi.bi_bios_dev = bc_unit2bios(rootdev->dd.d_unit); @@ -187,7 +187,7 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip, vm_offset_t default: printf("WARNING - don't know how to boot from device type %d\n", - rootdev->dd.d_type); + rootdev->dd.d_dev->dv_type); } if (bootdevnr == -1) { printf("root device %s invalid\n", i386_fmtdev(rootdev)); diff --git a/usr/src/boot/sys/boot/i386/libi386/devicename.c b/usr/src/boot/sys/boot/i386/libi386/devicename.c index fb676ab7a5..8a6daf6ad7 100644 --- a/usr/src/boot/sys/boot/i386/libi386/devicename.c +++ b/usr/src/boot/sys/boot/i386/libi386/devicename.c @@ -158,7 +158,6 @@ i386_parsedev(struct i386_devdesc **dev, const char *devspec, const char **path) } idev->dd.d_dev = dv; - idev->dd.d_type = dv->dv_type; if (dev != NULL) *dev = idev; @@ -178,7 +177,7 @@ i386_fmtdev(void *vdev) struct i386_devdesc *dev = (struct i386_devdesc *)vdev; static char buf[SPECNAMELEN + 1]; - switch (dev->dd.d_type) { + switch (dev->dd.d_dev->dv_type) { case DEVT_NONE: strlcpy(buf, "(no device)", sizeof (buf)); break; diff --git a/usr/src/boot/sys/boot/i386/loader/main.c b/usr/src/boot/sys/boot/i386/loader/main.c index 577e186c4c..be24ca4acf 100644 --- a/usr/src/boot/sys/boot/i386/loader/main.c +++ b/usr/src/boot/sys/boot/i386/loader/main.c @@ -287,13 +287,12 @@ extract_currdev(void) if ((biosdev == 0) && (B_TYPE(initial_bootdev) != 2)) /* biosdev doesn't match major */ biosdev = 0x80 + B_UNIT(initial_bootdev); /* assume harddisk */ } - new_currdev.dd.d_type = new_currdev.dd.d_dev->dv_type; /* * If we are booting off of a BIOS disk and we didn't succeed in determining * which one we booted off of, just use disk0: as a reasonable default. */ - if ((new_currdev.dd.d_type == biosdisk.dv_type) && + if ((new_currdev.dd.d_dev->dv_type == biosdisk.dv_type) && ((new_currdev.dd.d_unit = bd_bios2unit(biosdev)) == -1)) { printf("Can't work out which disk we are booting from.\n" "Guessed BIOS device 0x%x not found by probes, defaulting to disk0:\n", biosdev); diff --git a/usr/src/boot/sys/boot/ofw/libofw/devicename.c b/usr/src/boot/sys/boot/ofw/libofw/devicename.c index 62076c9c1d..af06dafd9d 100644 --- a/usr/src/boot/sys/boot/ofw/libofw/devicename.c +++ b/usr/src/boot/sys/boot/ofw/libofw/devicename.c @@ -34,7 +34,7 @@ static int ofw_parsedev(struct ofw_devdesc **, const char *, const char **); -/* +/* * Point (dev) at an allocated device specifier for the device matching the * path in (devspec). If it contains an explicit device specification, * use that. If not, use the default device. @@ -49,7 +49,7 @@ ofw_getdev(void **vdev, const char *devspec, const char **path) * If it looks like this is just a path and no * device, go with the current device. */ - if ((devspec == NULL) || + if ((devspec == NULL) || ((strchr(devspec, '@') == NULL) && (strchr(devspec, ':') == NULL))) { @@ -58,7 +58,7 @@ ofw_getdev(void **vdev, const char *devspec, const char **path) *path = devspec; return(rv); } - + /* * Try to parse the device name off the beginning of the devspec */ @@ -113,8 +113,7 @@ found: } strcpy(idev->d_path, name); idev->dd.d_dev = dv; - idev->dd.d_type = dv->dv_type; - if (idev->dd.d_type == DEVT_ZFS) { + if (dv->dv_type == DEVT_ZFS) { p = devspec + strlen(dv->dv_name); err = zfs_parsedev((struct zfs_devdesc *)idev, p, path); if (err != 0) { diff --git a/usr/src/boot/sys/boot/sparc64/loader/main.c b/usr/src/boot/sys/boot/sparc64/loader/main.c index cee45a234c..88c06bcf74 100644 --- a/usr/src/boot/sys/boot/sparc64/loader/main.c +++ b/usr/src/boot/sys/boot/sparc64/loader/main.c @@ -809,7 +809,6 @@ sparc64_zfs_probe(void) zfs_currdev.pool_guid = guid; zfs_currdev.root_guid = 0; zfs_currdev.dd.d_dev = &zfs_dev; - zfs_currdev.dd.d_type = zfs_currdev.dd.d_dev->dv_type; } } #endif /* LOADER_ZFS_SUPPORT */ diff --git a/usr/src/boot/sys/boot/uboot/common/main.c b/usr/src/boot/sys/boot/uboot/common/main.c index 9de0e7b4df..a312fca0ec 100644 --- a/usr/src/boot/sys/boot/uboot/common/main.c +++ b/usr/src/boot/sys/boot/uboot/common/main.c @@ -47,7 +47,7 @@ int devs_no; uintptr_t uboot_heap_start; uintptr_t uboot_heap_end; -struct device_type { +struct device_type { const char *name; int type; } device_types[] = { @@ -267,7 +267,7 @@ get_load_device(int *type, int *unit, int *slice, int *partition) } p = endp; - + /* No partition specification. */ if (*p == '\0') return; @@ -298,7 +298,7 @@ get_load_device(int *type, int *unit, int *slice, int *partition) *unit = -1; *slice = 0; *partition = -1; -} +} static void print_disk_probe_info() @@ -454,7 +454,6 @@ main(void) printf("Found U-Boot device: %s\n", devsw[i]->dv_name); currdev.dd.d_dev = devsw[i]; - currdev.dd.d_type = currdev.d_dev->dv_type; currdev.dd.d_unit = 0; if ((load_type == -1 || (load_type & DEV_TYP_STOR)) && @@ -533,7 +532,7 @@ command_devinfo(int argc, char *argv[]) command_errmsg = "no U-Boot devices found!?"; return (CMD_ERROR); } - + printf("U-Boot devices:\n"); for (i = 0; i < devs_no; i++) { ub_dump_di(i); @@ -577,7 +576,7 @@ handle_uboot_env_var(enum ubenv_action action, const char * var) * import the uboot variable ubname into the loader variable ldname, * otherwise the historical behavior is to import to uboot.ubname. */ - if (action == UBENV_IMPORT) { + if (action == UBENV_IMPORT) { len = strcspn(var, "="); if (len == 0) { printf("name cannot start with '=': '%s'\n", var); diff --git a/usr/src/boot/sys/boot/uboot/lib/devicename.c b/usr/src/boot/sys/boot/uboot/lib/devicename.c index 9f4bb679d9..4d3350e78c 100644 --- a/usr/src/boot/sys/boot/uboot/lib/devicename.c +++ b/usr/src/boot/sys/boot/uboot/lib/devicename.c @@ -146,7 +146,6 @@ uboot_parsedev(struct uboot_devdesc **dev, const char *devspec, goto fail; } idev->dd.d_dev = dv; - idev->dd.d_type = dv->dv_type; if (dev == NULL) { free(idev); } else { @@ -166,7 +165,7 @@ uboot_fmtdev(void *vdev) struct uboot_devdesc *dev = (struct uboot_devdesc *)vdev; static char buf[128]; - switch(dev->dd.d_type) { + switch(dev->dd.d_dev->dv_type) { case DEVT_NONE: strcpy(buf, "(no device)"); break; diff --git a/usr/src/boot/sys/boot/userboot/userboot/devicename.c b/usr/src/boot/sys/boot/userboot/userboot/devicename.c index c20187b198..79aeff4bb9 100644 --- a/usr/src/boot/sys/boot/userboot/userboot/devicename.c +++ b/usr/src/boot/sys/boot/userboot/userboot/devicename.c @@ -39,7 +39,7 @@ static int userboot_parsedev(struct disk_devdesc **dev, const char *devspec, const char **path); -/* +/* * Point (dev) at an allocated device specifier for the device matching the * path in (devspec). If it contains an explicit device specification, * use that. If not, use the default device. @@ -49,13 +49,13 @@ userboot_getdev(void **vdev, const char *devspec, const char **path) { struct disk_devdesc **dev = (struct disk_devdesc **)vdev; int rv; - + /* * If it looks like this is just a path and no * device, go with the current device. */ - if ((devspec == NULL) || - (devspec[0] == '/') || + if ((devspec == NULL) || + (devspec[0] == '/') || (strchr(devspec, ':') == NULL)) { if (((rv = userboot_parsedev(dev, getenv("currdev"), NULL)) == 0) && @@ -63,7 +63,7 @@ userboot_getdev(void **vdev, const char *devspec, const char **path) *path = devspec; return(rv); } - + /* * Try to parse the device name off the beginning of the devspec */ @@ -82,7 +82,7 @@ userboot_getdev(void **vdev, const char *devspec, const char **path) * For disk-type devices, the syntax is: * * disk[s][]: - * + * */ static int userboot_parsedev(struct disk_devdesc **dev, const char *devspec, const char **path) @@ -109,7 +109,7 @@ userboot_parsedev(struct disk_devdesc **dev, const char *devspec, const char **p idev = malloc(sizeof(struct disk_devdesc)); err = 0; np = (devspec + strlen(dv->dv_name)); - + switch(dv->dv_type) { case DEVT_NONE: /* XXX what to do here? Do we care? */ break; @@ -158,7 +158,6 @@ userboot_parsedev(struct disk_devdesc **dev, const char *devspec, const char **p goto fail; } idev->dd.d_dev = dv; - idev->dd.d_type = dv->dv_type; if (dev == NULL) { free(idev); } else { @@ -178,7 +177,7 @@ userboot_fmtdev(void *vdev) struct disk_devdesc *dev = (struct disk_devdesc *)vdev; static char buf[128]; /* XXX device length constant? */ - switch(dev->dd.d_type) { + switch(dev->dd.d_dev->dv_type) { case DEVT_NONE: strcpy(buf, "(no device)"); break; diff --git a/usr/src/boot/sys/boot/userboot/userboot/main.c b/usr/src/boot/sys/boot/userboot/userboot/main.c index 5abd95b5cf..781eece576 100644 --- a/usr/src/boot/sys/boot/userboot/userboot/main.c +++ b/usr/src/boot/sys/boot/userboot/userboot/main.c @@ -142,7 +142,7 @@ loader_main(struct loader_callbacks *cb, void *arg, int version, int ndisks) } /* - * Set the 'current device' by (if possible) recovering the boot device as + * Set the 'current device' by (if possible) recovering the boot device as * supplied by the initial bootstrap. */ static void @@ -169,7 +169,6 @@ extract_currdev(void) if (userboot_disk_maxunit > 0) { dev.dd.d_dev = &userboot_disk; - dev.dd.d_type = dev.dd.d_dev->dv_type; dev.dd.d_unit = 0; dev.d_slice = 0; dev.d_partition = 0; @@ -183,7 +182,6 @@ extract_currdev(void) } } else { dev.dd.d_dev = &host_dev; - dev.dd.d_type = dev.dd.d_dev->dv_type; dev.dd.d_unit = 0; } diff --git a/usr/src/boot/sys/boot/zfs/zfs.c b/usr/src/boot/sys/boot/zfs/zfs.c index d5e932ff0d..493ebd7e57 100644 --- a/usr/src/boot/sys/boot/zfs/zfs.c +++ b/usr/src/boot/sys/boot/zfs/zfs.c @@ -692,7 +692,6 @@ zfs_parsedev(struct zfs_devdesc *dev, const char *devspec, const char **path) if (path != NULL) *path = (*end == '\0') ? end : end + 1; dev->dd.d_dev = &zfs_dev; - dev->dd.d_type = zfs_dev.dv_type; return (0); } @@ -707,7 +706,7 @@ zfs_bootfs(void *zdev) int n; buf[0] = '\0'; - if (dev->dd.d_type != DEVT_ZFS) + if (dev->dd.d_dev->dv_type != DEVT_ZFS) return (buf); spa = spa_find_by_guid(dev->pool_guid); @@ -762,7 +761,7 @@ zfs_fmtdev(void *vdev) spa_t *spa; buf[0] = '\0'; - if (dev->dd.d_type != DEVT_ZFS) + if (dev->dd.d_dev->dv_type != DEVT_ZFS) return (buf); if (dev->pool_guid == 0) { @@ -960,7 +959,7 @@ zfs_set_env(void) ctr++; continue; } - + snprintf(envname, sizeof(envname), "bootenvmenu_caption[%d]", zfs_env_index); snprintf(envval, sizeof(envval), "%s", zfs_be->name); rv = setenv(envname, envval, 1); @@ -993,7 +992,7 @@ zfs_set_env(void) } } - + for (; zfs_env_index <= ZFS_BE_LAST; zfs_env_index++) { snprintf(envname, sizeof(envname), "bootenvmenu_caption[%d]", zfs_env_index); (void)unsetenv(envname); -- 2.11.4.GIT