diff --git a/stand/common/dev_net.c b/stand/common/dev_net.c --- a/stand/common/dev_net.c +++ b/stand/common/dev_net.c @@ -77,7 +77,7 @@ static int netdev_opens; static int net_init(void); -static int net_open(struct open_file *, ...); +static int net_open(struct open_file *); static int net_close(struct open_file *); static void net_cleanup(void); static int net_strategy(void *, int, daddr_t, size_t, char *, size_t *); @@ -115,21 +115,16 @@ /* * Called by devopen after it sets f->f_dev to our devsw entry. * This opens the low-level device and sets dev->d_opendata. - * This is declared with variable arguments... */ static int -net_open(struct open_file *f, ...) +net_open(struct open_file *f) { - struct iodesc *d; - va_list args; struct devdesc *dev; + struct iodesc *d; const char *devname; /* Device part of file name (or NULL). */ int error = 0; - va_start(args, f); - dev = va_arg(args, struct devdesc *); - va_end(args); - + dev = f->f_devdata; devname = dev->d_dev->dv_name; /* Before opening another interface, close the previous one first. */ if (netdev_sock >= 0 && strcmp(devname, netdev_name) != 0) diff --git a/stand/common/devopen.c b/stand/common/devopen.c --- a/stand/common/devopen.c +++ b/stand/common/devopen.c @@ -49,7 +49,7 @@ /* point to device-specific data so that device open can use it */ f->f_dev = dev->d_dev; f->f_devdata = dev; - result = dev->d_dev->dv_open(f, dev); + result = dev->d_dev->dv_open(f); if (result != 0) { f->f_devdata = NULL; f->f_dev = NULL; diff --git a/stand/common/disk.c b/stand/common/disk.c --- a/stand/common/disk.c +++ b/stand/common/disk.c @@ -236,6 +236,10 @@ struct ptable_entry part; int rc, slice, partition; + /* + * XXX Audit callers, see if we have anything shifty going on or if we + * can properly assert here that dev->dd.d_dev->dv_type == DEVT_DISK. + */ if (sectorsize == 0) { DPRINTF("unknown sector size"); return (ENXIO); diff --git a/stand/common/md.c b/stand/common/md.c --- a/stand/common/md.c +++ b/stand/common/md.c @@ -61,7 +61,7 @@ /* devsw I/F */ static int md_init(void); static int md_strategy(void *, int, daddr_t, size_t, char *, size_t *); -static int md_open(struct open_file *, ...); +static int md_open(struct open_file *); static int md_close(struct open_file *); static int md_print(int); @@ -121,15 +121,11 @@ } static int -md_open(struct open_file *f, ...) +md_open(struct open_file *f) { - va_list ap; struct devdesc *dev; - va_start(ap, f); - dev = va_arg(ap, struct devdesc *); - va_end(ap); - + dev = f->f_devdata; if (dev->d_unit != 0) return (ENXIO); diff --git a/stand/common/vdisk.c b/stand/common/vdisk.c --- a/stand/common/vdisk.c +++ b/stand/common/vdisk.c @@ -38,7 +38,7 @@ static int vdisk_init(void); static int vdisk_strategy(void *, int, daddr_t, size_t, char *, size_t *); -static int vdisk_open(struct open_file *, ...); +static int vdisk_open(struct open_file *); static int vdisk_close(struct open_file *); static int vdisk_ioctl(struct open_file *, u_long, void *); static int vdisk_print(int); @@ -292,24 +292,20 @@ } static int -vdisk_open(struct open_file *f, ...) +vdisk_open(struct open_file *f) { - va_list args; - struct disk_devdesc *dev; + struct devdesc *dev; vdisk_info_t *vd; int rc = 0; - va_start(args, f); - dev = va_arg(args, struct disk_devdesc *); - va_end(args); - if (dev == NULL) - return (EINVAL); - vd = vdisk_get_info((struct devdesc *)dev); + dev = f->f_devdata; + vd = vdisk_get_info(dev); if (vd == NULL) return (EINVAL); - if (dev->dd.d_dev->dv_type == DEVT_DISK) { - rc = disk_open(dev, vd->vdisk_size, vd->vdisk_sectorsz); + if (dev->d_dev->dv_type == DEVT_DISK) { + rc = disk_open((struct disk_devdesc *)dev, vd->vdisk_size, + vd->vdisk_sectorsz); } if (rc == 0) vd->vdisk_open++; diff --git a/stand/efi/libefi/efihttp.c b/stand/efi/libefi/efihttp.c --- a/stand/efi/libefi/efihttp.c +++ b/stand/efi/libefi/efihttp.c @@ -58,7 +58,7 @@ static int efihttp_dev_init(void); static int efihttp_dev_strategy(void *devdata, int rw, daddr_t blk, size_t size, char *buf, size_t *rsize); -static int efihttp_dev_open(struct open_file *f, ...); +static int efihttp_dev_open(struct open_file *f); static int efihttp_dev_close(struct open_file *f); static int efihttp_fs_open(const char *path, struct open_file *f); @@ -228,8 +228,9 @@ } static int -efihttp_dev_open(struct open_file *f, ...) +efihttp_dev_open(struct open_file *f) { + struct devdesc *dev; EFI_HTTP_CONFIG_DATA config; EFI_HTTPv4_ACCESS_POINT config_access; DNS_DEVICE_PATH *dns; @@ -238,13 +239,13 @@ IPv4_DEVICE_PATH *ipv4; MAC_ADDR_DEVICE_PATH *mac; URI_DEVICE_PATH *uri; - struct devdesc *dev; struct open_efihttp *oh; char *c; EFI_HANDLE handle; EFI_STATUS status; int err, len; + dev = f->f_devdata; if (!efihttp_init_done) return (ENXIO); @@ -292,7 +293,6 @@ if (!oh) return (ENOMEM); oh->dev_handle = handle; - dev = (struct devdesc *)f->f_devdata; dev->d_opendata = oh; status = BS->OpenProtocol(handle, &httpsb_guid, (void **)&sb, IH, NULL, diff --git a/stand/efi/libefi/efipart.c b/stand/efi/libefi/efipart.c --- a/stand/efi/libefi/efipart.c +++ b/stand/efi/libefi/efipart.c @@ -53,7 +53,7 @@ static int efipart_strategy(void *, int, daddr_t, size_t, char *, size_t *); static int efipart_realstrategy(void *, int, daddr_t, size_t, char *, size_t *); -static int efipart_open(struct open_file *, ...); +static int efipart_open(struct open_file *); static int efipart_close(struct open_file *); static int efipart_ioctl(struct open_file *, u_long, void *); @@ -881,21 +881,15 @@ } static int -efipart_open(struct open_file *f, ...) +efipart_open(struct open_file *f) { - va_list args; - struct disk_devdesc *dev; + struct devdesc *dev; pdinfo_t *pd; EFI_BLOCK_IO *blkio; EFI_STATUS status; - va_start(args, f); - dev = va_arg(args, struct disk_devdesc *); - va_end(args); - if (dev == NULL) - return (EINVAL); - - pd = efiblk_get_pdinfo((struct devdesc *)dev); + dev = f->f_devdata; + pd = efiblk_get_pdinfo(dev); if (pd == NULL) return (EIO); @@ -914,10 +908,10 @@ if (pd->pd_bcache == NULL) pd->pd_bcache = bcache_allocate(); - if (dev->dd.d_dev->dv_type == DEVT_DISK) { + if (dev->d_dev->dv_type == DEVT_DISK) { int rc; - rc = disk_open(dev, + rc = disk_open((struct disk_devdesc *)dev, blkio->Media->BlockSize * (blkio->Media->LastBlock + 1), blkio->Media->BlockSize); if (rc != 0) { diff --git a/stand/i386/libfirewire/firewire.c b/stand/i386/libfirewire/firewire.c --- a/stand/i386/libfirewire/firewire.c +++ b/stand/i386/libfirewire/firewire.c @@ -68,7 +68,7 @@ static int fw_init(void); static int fw_strategy(void *devdata, int flag, daddr_t dblk, size_t size, char *buf, size_t *rsize); -static int fw_open(struct open_file *f, ...); +static int fw_open(struct open_file *f); static int fw_close(struct open_file *f); static int fw_print(int verbose); static void fw_cleanup(void); @@ -176,18 +176,8 @@ } static int -fw_open(struct open_file *f, ...) +fw_open(struct open_file *f __unused) { -#if 0 - va_list ap; - struct i386_devdesc *dev; - struct open_disk *od; - int error; - - va_start(ap, f); - dev = va_arg(ap, struct i386_devdesc *); - va_end(ap); -#endif return (ENXIO); } diff --git a/stand/i386/libi386/biosdisk.c b/stand/i386/libi386/biosdisk.c --- a/stand/i386/libi386/biosdisk.c +++ b/stand/i386/libi386/biosdisk.c @@ -147,7 +147,7 @@ char *buf, size_t *rsize); static int bd_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size, char *buf, size_t *rsize); -static int bd_open(struct open_file *f, ...); +static int bd_open(struct open_file *f); static int bd_close(struct open_file *f); static int bd_ioctl(struct open_file *f, u_long cmd, void *data); static int bd_print(int verbose); @@ -837,20 +837,16 @@ * slice before it?) */ static int -bd_open(struct open_file *f, ...) +bd_open(struct open_file *f) { + struct devdesc *dev; bdinfo_t *bd; - struct disk_devdesc *dev; - va_list ap; int rc; TSENTER(); - va_start(ap, f); - dev = va_arg(ap, struct disk_devdesc *); - va_end(ap); - - bd = bd_get_bdinfo(&dev->dd); + dev = f->f_devdata; + bd = bd_get_bdinfo(dev); if (bd == NULL) return (EIO); @@ -864,13 +860,13 @@ bd->bd_bcache = bcache_allocate(); if (bd->bd_open == 0) - bd->bd_sectors = bd_disk_get_sectors(dev); + bd->bd_sectors = bd_disk_get_sectors((struct disk_devdesc *)dev); bd->bd_open++; rc = 0; - if (dev->dd.d_dev->dv_type == DEVT_DISK) { - rc = disk_open(dev, bd->bd_sectors * bd->bd_sectorsize, - bd->bd_sectorsize); + if (dev->d_dev->dv_type == DEVT_DISK) { + rc = disk_open((struct disk_devdesc *)dev, + bd->bd_sectors * bd->bd_sectorsize, bd->bd_sectorsize); if (rc != 0) { bd->bd_open--; if (bd->bd_open == 0) { diff --git a/stand/kboot/hostdisk.c b/stand/kboot/hostdisk.c --- a/stand/kboot/hostdisk.c +++ b/stand/kboot/hostdisk.c @@ -34,7 +34,7 @@ static int hostdisk_init(void); static int hostdisk_strategy(void *devdata, int flag, daddr_t dblk, size_t size, char *buf, size_t *rsize); -static int hostdisk_open(struct open_file *f, ...); +static int hostdisk_open(struct open_file *f); static int hostdisk_close(struct open_file *f); static int hostdisk_ioctl(struct open_file *f, u_long cmd, void *data); static int hostdisk_print(int verbose); @@ -88,15 +88,11 @@ } static int -hostdisk_open(struct open_file *f, ...) +hostdisk_open(struct open_file *f) { struct devdesc *desc; - va_list vl; - - va_start(vl, f); - desc = va_arg(vl, struct devdesc *); - va_end(vl); + desc = f->f_devdata; desc->d_unit = host_open(desc->d_opendata, O_RDONLY, 0); if (desc->d_unit <= 0) { diff --git a/stand/kboot/hostfs.c b/stand/kboot/hostfs.c --- a/stand/kboot/hostfs.c +++ b/stand/kboot/hostfs.c @@ -249,7 +249,7 @@ * 'Open' the host device. */ static int -host_dev_open(struct open_file *f, ...) +host_dev_open(struct open_file *f) { return (0); } diff --git a/stand/libofw/ofw_disk.c b/stand/libofw/ofw_disk.c --- a/stand/libofw/ofw_disk.c +++ b/stand/libofw/ofw_disk.c @@ -45,7 +45,7 @@ static int ofwd_init(void); static int ofwd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, char *buf, size_t *rsize); -static int ofwd_open(struct open_file *f, ...); +static int ofwd_open(struct open_file *f); static int ofwd_close(struct open_file *f); static int ofwd_ioctl(struct open_file *f, u_long cmd, void *data); static int ofwd_print(int verbose); @@ -118,15 +118,11 @@ } static int -ofwd_open(struct open_file *f, ...) +ofwd_open(struct open_file *f) { struct ofw_devdesc *dp; - va_list vl; - - va_start(vl, f); - dp = va_arg(vl, struct ofw_devdesc *); - va_end(vl); + dp = (struct ofw_devdesc *)f->f_devdata; if (dp != kdp) { if (kdp != NULL) { OF_close(kdp->d_handle); diff --git a/stand/libsa/geli/gelidev.c b/stand/libsa/geli/gelidev.c --- a/stand/libsa/geli/gelidev.c +++ b/stand/libsa/geli/gelidev.c @@ -37,7 +37,7 @@ static int geli_dev_init(void); static int geli_dev_strategy(void *, int, daddr_t, size_t, char *, size_t *); -static int geli_dev_open(struct open_file *f, ...); +static int geli_dev_open(struct open_file *f); static int geli_dev_close(struct open_file *f); static int geli_dev_ioctl(struct open_file *, u_long, void *); static int geli_dev_print(int); @@ -201,7 +201,7 @@ } static int -geli_dev_open(struct open_file *f, ...) +geli_dev_open(struct open_file *f __unused) { /* diff --git a/stand/libsa/libsa.3 b/stand/libsa/libsa.3 --- a/stand/libsa/libsa.3 +++ b/stand/libsa/libsa.3 @@ -705,7 +705,7 @@ int (*dv_init)(void); int (*dv_strategy)(void *devdata, int rw, daddr_t blk, size_t size, char *buf, size_t *rsize); - int (*dv_open)(struct open_file *f, ...); + int (*dv_open)(struct open_file *f); int (*dv_close)(struct open_file *f); int (*dv_ioctl)(struct open_file *f, u_long cmd, void *data); int (*dv_print)(int verbose); diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h --- a/stand/libsa/stand.h +++ b/stand/libsa/stand.h @@ -154,7 +154,7 @@ int (*dv_init)(void); /* early probe call */ int (*dv_strategy)(void *devdata, int rw, daddr_t blk, size_t size, char *buf, size_t *rsize); - int (*dv_open)(struct open_file *f, ...); + int (*dv_open)(struct open_file *f); int (*dv_close)(struct open_file *f); int (*dv_ioctl)(struct open_file *f, u_long cmd, void *data); int (*dv_print)(int verbose); /* print device information */ @@ -174,8 +174,13 @@ * versions may be larger, but should be allowed to * overlap. */ +/* + * XXX We do enough casts to disk_devdesc that a dev2disk would likely be a good + * idea. + */ struct devdesc { struct devsw *d_dev; + size_t d_size; int d_unit; void *d_opendata; }; diff --git a/stand/libsa/zfs/zfs.c b/stand/libsa/zfs/zfs.c --- a/stand/libsa/zfs/zfs.c +++ b/stand/libsa/zfs/zfs.c @@ -1564,18 +1564,14 @@ * Attempt to open the pool described by (dev) for use by (f). */ static int -zfs_dev_open(struct open_file *f, ...) +zfs_dev_open(struct open_file *f) { - va_list args; struct zfs_devdesc *dev; struct zfsmount *mount; spa_t *spa; int rv; - va_start(args, f); - dev = va_arg(args, struct zfs_devdesc *); - va_end(args); - + dev = (struct zfs_devdesc *)f->f_devdata; if ((spa = spa_find_by_dev(dev)) == NULL) return (ENXIO); diff --git a/stand/uboot/main.c b/stand/uboot/main.c --- a/stand/uboot/main.c +++ b/stand/uboot/main.c @@ -378,7 +378,7 @@ for (currdev.dd.d_unit = 0; currdev.dd.d_unit < UB_MAX_DEV; currdev.dd.d_unit++) { print_disk_probe_info(); - open_result = devsw[devidx]->dv_open(&f, &currdev); + open_result = devsw[devidx]->dv_open(&f); if (open_result == 0) { printf(" good.\n"); return (0); @@ -396,7 +396,7 @@ if (currdev.dd.d_unit == -1) break; print_disk_probe_info(); - open_result = devsw[devidx]->dv_open(&f, &currdev); + open_result = devsw[devidx]->dv_open(&f); if (open_result == 0) { printf(" good.\n"); return (0); @@ -408,7 +408,7 @@ if ((currdev.dd.d_unit = uboot_diskgetunit(load_type, load_unit)) != -1) { print_disk_probe_info(); - open_result = devsw[devidx]->dv_open(&f,&currdev); + open_result = devsw[devidx]->dv_open(&f); if (open_result == 0) { printf(" good.\n"); return (0); diff --git a/stand/uboot/uboot_disk.c b/stand/uboot/uboot_disk.c --- a/stand/uboot/uboot_disk.c +++ b/stand/uboot/uboot_disk.c @@ -74,7 +74,7 @@ /* devsw I/F */ static int stor_init(void); static int stor_strategy(void *, int, daddr_t, size_t, char *, size_t *); -static int stor_open(struct open_file *, ...); +static int stor_open(struct open_file *); static int stor_close(struct open_file *); static int stor_ioctl(struct open_file *f, u_long cmd, void *data); static int stor_print(int); @@ -174,16 +174,10 @@ } static int -stor_open(struct open_file *f, ...) +stor_open(struct open_file *f) { - va_list ap; - struct disk_devdesc *dev; - - va_start(ap, f); - dev = va_arg(ap, struct disk_devdesc *); - va_end(ap); - return (stor_opendev(dev)); + return (stor_opendev((struct disk_devdesc *)f->f_devdata)); } static int diff --git a/stand/usb/storage/umass_loader.c b/stand/usb/storage/umass_loader.c --- a/stand/usb/storage/umass_loader.c +++ b/stand/usb/storage/umass_loader.c @@ -44,7 +44,7 @@ #include "umass_common.h" static int umass_disk_init(void); -static int umass_disk_open(struct open_file *,...); +static int umass_disk_open(struct open_file *); static int umass_disk_close(struct open_file *); static void umass_disk_cleanup(void); static int umass_disk_ioctl(struct open_file *, u_long, void *); @@ -122,20 +122,16 @@ } static int -umass_disk_open(struct open_file *f,...) +umass_disk_open(struct open_file *f) { - va_list ap; - struct disk_devdesc *dev; - - va_start(ap, f); - dev = va_arg(ap, struct disk_devdesc *); - va_end(ap); + struct devdesc *dev; + dev = f->f_devdata; if (umass_uaa.device == NULL) return (ENXIO); if (dev->d_unit != 0) return (EIO); - return (umass_disk_open_sub(dev)); + return (umass_disk_open_sub((struct disk_devdesc *)dev)); } static int diff --git a/stand/userboot/userboot/host.c b/stand/userboot/userboot/host.c --- a/stand/userboot/userboot/host.c +++ b/stand/userboot/userboot/host.c @@ -133,7 +133,7 @@ * 'Open' the host device. */ static int -host_dev_open(struct open_file *f, ...) +host_dev_open(struct open_file *f __unused) { return (0); diff --git a/stand/userboot/userboot/main.c b/stand/userboot/userboot/main.c --- a/stand/userboot/userboot/main.c +++ b/stand/userboot/userboot/main.c @@ -266,15 +266,19 @@ #endif if (userboot_disk_maxunit > 0) { + struct open_file f = { 0 }; + dev.dd.d_dev = &userboot_disk; dev.dd.d_unit = 0; dev.d_slice = D_SLICEWILD; dev.d_partition = D_PARTWILD; + f.f_devdata = &dev; + /* * If we cannot auto-detect the partition type then * access the disk as a raw device. */ - if (dev.dd.d_dev->dv_open(NULL, &dev)) { + if (dev.dd.d_dev->dv_open(&f)) { dev.d_slice = D_SLICENONE; dev.d_partition = D_PARTNONE; } diff --git a/stand/userboot/userboot/userboot_disk.c b/stand/userboot/userboot/userboot_disk.c --- a/stand/userboot/userboot/userboot_disk.c +++ b/stand/userboot/userboot/userboot_disk.c @@ -57,7 +57,7 @@ size_t size, char *buf, size_t *rsize); static int userdisk_realstrategy(void *devdata, int flag, daddr_t dblk, size_t size, char *buf, size_t *rsize); -static int userdisk_open(struct open_file *f, ...); +static int userdisk_open(struct open_file *f); static int userdisk_close(struct open_file *f); static int userdisk_ioctl(struct open_file *f, u_long cmd, void *data); static int userdisk_print(int verbose); @@ -156,22 +156,18 @@ * Attempt to open the disk described by (dev) for use by (f). */ static int -userdisk_open(struct open_file *f, ...) +userdisk_open(struct open_file *f) { - va_list ap; - struct disk_devdesc *dev; + struct devdesc *dev; - va_start(ap, f); - dev = va_arg(ap, struct disk_devdesc *); - va_end(ap); - - if (dev->dd.d_unit < 0 || dev->dd.d_unit >= userdisk_maxunit) + dev = f->f_devdata; + if (dev->d_unit < 0 || dev->d_unit >= userdisk_maxunit) return (EIO); - ud_info[dev->dd.d_unit].ud_open++; - if (ud_info[dev->dd.d_unit].ud_bcache == NULL) - ud_info[dev->dd.d_unit].ud_bcache = bcache_allocate(); - return (disk_open(dev, ud_info[dev->dd.d_unit].mediasize, - ud_info[dev->dd.d_unit].sectorsize)); + ud_info[dev->d_unit].ud_open++; + if (ud_info[dev->d_unit].ud_bcache == NULL) + ud_info[dev->d_unit].ud_bcache = bcache_allocate(); + return (disk_open((struct disk_devdesc *)dev, + ud_info[dev->d_unit].mediasize, ud_info[dev->d_unit].sectorsize)); } static int