Index: sys/arch/hp300/dev/rd.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp300/dev/rd.c,v retrieving revision 1.110 diff -d -p -u -r1.110 rd.c --- sys/arch/hp300/dev/rd.c 31 Jul 2021 20:29:36 -0000 1.110 +++ sys/arch/hp300/dev/rd.c 12 Aug 2022 07:16:13 -0000 @@ -468,7 +468,7 @@ const struct bdevsw rd_bdevsw = { .d_dump = rddump, .d_psize = rdsize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw rd_cdevsw = { @@ -483,7 +483,7 @@ const struct cdevsw rd_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; static int Index: sys/arch/sun3/dev/xd.c =================================================================== RCS file: /cvsroot/src/sys/arch/sun3/dev/xd.c,v retrieving revision 1.77 diff -d -p -u -r1.77 xd.c --- sys/arch/sun3/dev/xd.c 7 Aug 2021 16:19:06 -0000 1.77 +++ sys/arch/sun3/dev/xd.c 12 Aug 2022 07:16:13 -0000 @@ -293,7 +293,7 @@ const struct bdevsw xd_bdevsw = { .d_dump = xddump, .d_psize = xdsize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw xd_cdevsw = { @@ -308,7 +308,7 @@ const struct cdevsw xd_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; /* Index: sys/arch/sun3/dev/xy.c =================================================================== RCS file: /cvsroot/src/sys/arch/sun3/dev/xy.c,v retrieving revision 1.82 diff -d -p -u -r1.82 xy.c --- sys/arch/sun3/dev/xy.c 7 Aug 2021 16:19:06 -0000 1.82 +++ sys/arch/sun3/dev/xy.c 12 Aug 2022 07:16:13 -0000 @@ -224,7 +224,7 @@ const struct bdevsw xy_bdevsw = { .d_dump = xydump, .d_psize = xysize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw xy_cdevsw = { @@ -239,7 +239,7 @@ const struct cdevsw xy_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; /* Index: sys/arch/vax/mba/hp.c =================================================================== RCS file: /cvsroot/src/sys/arch/vax/mba/hp.c,v retrieving revision 1.54 diff -d -p -u -r1.54 hp.c --- sys/arch/vax/mba/hp.c 22 May 2017 17:13:09 -0000 1.54 +++ sys/arch/vax/mba/hp.c 12 Aug 2022 07:16:13 -0000 @@ -96,7 +96,7 @@ const struct bdevsw hp_bdevsw = { .d_dump = nulldump, .d_psize = hppsize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw hp_cdevsw = { @@ -111,7 +111,7 @@ const struct cdevsw hp_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; #define HP_WCSR(reg, val) \ Index: sys/arch/vax/vsa/hdc9224.c =================================================================== RCS file: /cvsroot/src/sys/arch/vax/vsa/hdc9224.c,v retrieving revision 1.62 diff -d -p -u -r1.62 hdc9224.c --- sys/arch/vax/vsa/hdc9224.c 7 Aug 2021 16:19:07 -0000 1.62 +++ sys/arch/vax/vsa/hdc9224.c 12 Aug 2022 07:16:13 -0000 @@ -196,7 +196,7 @@ const struct bdevsw rd_bdevsw = { .d_dump = nulldump, .d_psize = rdpsize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw rd_cdevsw = { @@ -211,7 +211,7 @@ const struct cdevsw rd_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; /* At least 0.7 uS between register accesses */ Index: sys/arch/xen/xen/xbd_xenbus.c =================================================================== RCS file: /cvsroot/src/sys/arch/xen/xen/xbd_xenbus.c,v retrieving revision 1.129 diff -d -p -u -r1.129 xbd_xenbus.c --- sys/arch/xen/xen/xbd_xenbus.c 13 Jul 2020 21:21:56 -0000 1.129 +++ sys/arch/xen/xen/xbd_xenbus.c 12 Aug 2022 07:16:14 -0000 @@ -232,7 +232,7 @@ const struct bdevsw xbd_bdevsw = { .d_dump = xbddump, .d_psize = xbdsize, .d_discard = nodiscard, - .d_flag = D_DISK | D_MPSAFE + .d_flag = D_DISK | D_MPSAFE | D_STORAGEPOOL }; const struct cdevsw xbd_cdevsw = { @@ -247,7 +247,7 @@ const struct cdevsw xbd_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK | D_MPSAFE + .d_flag = D_DISK | D_MPSAFE | D_STORAGEPOOL }; extern struct cfdriver xbd_cd; Index: sys/dev/ccd.c =================================================================== RCS file: /cvsroot/src/sys/dev/ccd.c,v retrieving revision 1.189 diff -d -p -u -r1.189 ccd.c --- sys/dev/ccd.c 28 Mar 2022 12:48:35 -0000 1.189 +++ sys/dev/ccd.c 12 Aug 2022 07:16:14 -0000 @@ -191,7 +191,7 @@ const struct bdevsw ccd_bdevsw = { .d_dump = nodump, .d_psize = ccdsize, .d_discard = nodiscard, - .d_flag = D_DISK | D_MPSAFE + .d_flag = D_DISK | D_MPSAFE | D_STORAGEPOOL }; const struct cdevsw ccd_cdevsw = { @@ -206,7 +206,7 @@ const struct cdevsw ccd_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK | D_MPSAFE + .d_flag = D_DISK | D_MPSAFE | D_STORAGEPOOL }; static const struct dkdriver ccddkdriver = { Index: sys/dev/cgd.c =================================================================== RCS file: /cvsroot/src/sys/dev/cgd.c,v retrieving revision 1.146 diff -d -p -u -r1.146 cgd.c --- sys/dev/cgd.c 2 Apr 2022 09:53:20 -0000 1.146 +++ sys/dev/cgd.c 12 Aug 2022 07:16:14 -0000 @@ -94,7 +94,7 @@ const struct bdevsw cgd_bdevsw = { .d_dump = cgddump, .d_psize = cgdsize, .d_discard = nodiscard, - .d_flag = D_DISK | D_MPSAFE + .d_flag = D_DISK | D_MPSAFE | D_STORAGEPOOL }; const struct cdevsw cgd_cdevsw = { @@ -109,7 +109,7 @@ const struct cdevsw cgd_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK | D_MPSAFE + .d_flag = D_DISK | D_MPSAFE | D_STORAGEPOOL }; /* Index: sys/dev/ld.c =================================================================== RCS file: /cvsroot/src/sys/dev/ld.c,v retrieving revision 1.112 diff -d -p -u -r1.112 ld.c --- sys/dev/ld.c 30 May 2021 11:24:02 -0000 1.112 +++ sys/dev/ld.c 12 Aug 2022 07:16:14 -0000 @@ -93,7 +93,7 @@ const struct bdevsw ld_bdevsw = { .d_dump = lddump, .d_psize = ldsize, .d_discard = lddiscard, - .d_flag = D_DISK | D_MPSAFE + .d_flag = D_DISK | D_MPSAFE | D_STORAGEPOOL }; const struct cdevsw ld_cdevsw = { @@ -108,7 +108,7 @@ const struct cdevsw ld_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = lddiscard, - .d_flag = D_DISK | D_MPSAFE + .d_flag = D_DISK | D_MPSAFE | D_STORAGEPOOL }; static const struct dkdriver lddkdriver = { Index: sys/dev/vnd.c =================================================================== RCS file: /cvsroot/src/sys/dev/vnd.c,v retrieving revision 1.286 diff -d -p -u -r1.286 vnd.c --- sys/dev/vnd.c 31 May 2022 14:13:31 -0000 1.286 +++ sys/dev/vnd.c 12 Aug 2022 07:16:14 -0000 @@ -209,7 +209,7 @@ const struct bdevsw vnd_bdevsw = { .d_dump = vnddump, .d_psize = vndsize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw vnd_cdevsw = { @@ -224,7 +224,7 @@ const struct cdevsw vnd_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; static int vnd_match(device_t, cfdata_t, void *); Index: sys/dev/ata/wd.c =================================================================== RCS file: /cvsroot/src/sys/dev/ata/wd.c,v retrieving revision 1.467 diff -d -p -u -r1.467 wd.c --- sys/dev/ata/wd.c 28 Mar 2022 12:39:37 -0000 1.467 +++ sys/dev/ata/wd.c 12 Aug 2022 07:16:14 -0000 @@ -154,7 +154,7 @@ const struct bdevsw wd_bdevsw = { .d_discard = wddiscard, .d_cfdriver = &wd_cd, .d_devtounit = disklabel_dev_unit, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw wd_cdevsw = { @@ -171,7 +171,7 @@ const struct cdevsw wd_cdevsw = { .d_discard = wddiscard, .d_cfdriver = &wd_cd, .d_devtounit = disklabel_dev_unit, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; /* #define WD_DUMP_NOT_TRUSTED if you just want to watch */ Index: sys/dev/dkwedge/dk.c =================================================================== RCS file: /cvsroot/src/sys/dev/dkwedge/dk.c,v retrieving revision 1.112 diff -d -p -u -r1.112 dk.c --- sys/dev/dkwedge/dk.c 11 Jun 2022 18:17:00 -0000 1.112 +++ sys/dev/dkwedge/dk.c 12 Aug 2022 07:16:14 -0000 @@ -105,6 +105,9 @@ static int dkwedge_del1(struct dkwedge_i static int dk_open_parent(dev_t, int, struct vnode **); static int dk_close_parent(struct vnode *, int); +static device_t dkwedge_rootspec_hook(const char *); +static void dkwedge_rootspec_print(void); + static dev_type_open(dkopen); static dev_type_close(dkclose); static dev_type_read(dkread); @@ -123,7 +126,7 @@ const struct bdevsw dk_bdevsw = { .d_dump = dkdump, .d_psize = dksize, .d_discard = dkdiscard, - .d_flag = D_DISK | D_MPSAFE + .d_flag = D_DISK | D_MPSAFE | D_STORAGEPOOL }; const struct cdevsw dk_cdevsw = { @@ -138,7 +141,7 @@ const struct cdevsw dk_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = dkdiscard, - .d_flag = D_DISK | D_MPSAFE + .d_flag = D_DISK | D_MPSAFE | D_STORAGEPOOL }; static struct dkwedge_softc **dkwedges; @@ -492,6 +495,9 @@ dkwedge_add(struct dkwedge_info *dkw) dk_set_geometry(sc, pdk); disk_attach(&sc->sc_dk); + /* Wedges don't have partitions */ + device_set_flag(sc->sc_dev, DVF_NO_PARTITIONS); + /* Disk wedge is ready for use! */ sc->sc_state = DKW_STATE_RUNNING; @@ -818,8 +824,17 @@ dkwedge_find_by_parent(const char *name, return NULL; } -void -dkwedge_print_wnames(void) +static device_t +dkwedge_rootspec_hook(const char *spec) +{ + device_t dv; + + dv = dkwedge_find_by_wname(spec); + return dv; +} + +static void +dkwedge_rootspec_print(void) { struct dkwedge_softc *sc; int i; @@ -897,6 +912,12 @@ dkwedge_init(void) } rw_exit(&dkwedge_discovery_methods_lock); + + /* never unloaded, so don't need to save the hook establish cookies */ + mountroot_rootspec_hook_establish("wedge", + dkwedge_rootspec_hook, dkwedge_rootspec_print); + mountroot_rootspec_hook_establish("NAME", + dkwedge_rootspec_hook, dkwedge_rootspec_print); } #ifdef DKWEDGE_AUTODISCOVER Index: sys/dev/dm/device-mapper.c =================================================================== RCS file: /cvsroot/src/sys/dev/dm/device-mapper.c,v retrieving revision 1.64 diff -d -p -u -r1.64 device-mapper.c --- sys/dev/dm/device-mapper.c 31 Mar 2022 19:30:15 -0000 1.64 +++ sys/dev/dm/device-mapper.c 12 Aug 2022 07:16:14 -0000 @@ -83,7 +83,7 @@ const struct bdevsw dm_bdevsw = { .d_dump = nodump, .d_psize = dmsize, .d_discard = nodiscard, - .d_flag = D_DISK | D_MPSAFE + .d_flag = D_DISK | D_MPSAFE | D_STORAGEPOOL }; const struct cdevsw dm_cdevsw = { @@ -98,7 +98,7 @@ const struct cdevsw dm_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK | D_MPSAFE + .d_flag = D_DISK | D_MPSAFE | D_STORAGEPOOL }; const struct dkdriver dmdkdriver = { Index: sys/dev/flash/flash.c =================================================================== RCS file: /cvsroot/src/sys/dev/flash/flash.c,v retrieving revision 1.18 diff -d -p -u -r1.18 flash.c --- sys/dev/flash/flash.c 31 Mar 2022 19:30:16 -0000 1.18 +++ sys/dev/flash/flash.c 12 Aug 2022 07:16:14 -0000 @@ -161,6 +161,9 @@ flash_attach(device_t parent, device_t s sc->sc_readonly = false; } + /* flash devices don't have partitions */ + device_set_flag(sc->sc_dev, DVF_NO_PARTITIONS); + aprint_normal("\n"); if (sc->sc_partinfo.part_size == 0) { Index: sys/dev/gpib/rd.c =================================================================== RCS file: /cvsroot/src/sys/dev/gpib/rd.c,v retrieving revision 1.44 diff -d -p -u -r1.44 rd.c --- sys/dev/gpib/rd.c 31 Jul 2021 20:29:37 -0000 1.44 +++ sys/dev/gpib/rd.c 12 Aug 2022 07:16:14 -0000 @@ -264,7 +264,7 @@ const struct bdevsw rd_bdevsw = { .d_dump = rddump, .d_psize = rdsize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw rd_cdevsw = { @@ -279,7 +279,7 @@ const struct cdevsw rd_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; int Index: sys/dev/mca/ed_mca.c =================================================================== RCS file: /cvsroot/src/sys/dev/mca/ed_mca.c,v retrieving revision 1.67 diff -d -p -u -r1.67 ed_mca.c --- sys/dev/mca/ed_mca.c 3 Sep 2018 16:29:32 -0000 1.67 +++ sys/dev/mca/ed_mca.c 12 Aug 2022 07:16:14 -0000 @@ -103,7 +103,7 @@ const struct bdevsw ed_bdevsw = { .d_dump = edmcadump, .d_psize = edmcasize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw ed_cdevsw = { @@ -118,7 +118,7 @@ const struct cdevsw ed_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; static struct dkdriver eddkdriver = { Index: sys/dev/mscp/mscp_disk.c =================================================================== RCS file: /cvsroot/src/sys/dev/mscp/mscp_disk.c,v retrieving revision 1.90 diff -d -p -u -r1.90 mscp_disk.c --- sys/dev/mscp/mscp_disk.c 9 Aug 2021 19:24:33 -0000 1.90 +++ sys/dev/mscp/mscp_disk.c 12 Aug 2022 07:16:14 -0000 @@ -164,7 +164,7 @@ const struct bdevsw ra_bdevsw = { .d_dump = radump, .d_psize = rasize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw ra_cdevsw = { @@ -179,7 +179,7 @@ const struct cdevsw ra_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; static struct dkdriver radkdriver = { Index: sys/dev/ofw/ofdisk.c =================================================================== RCS file: /cvsroot/src/sys/dev/ofw/ofdisk.c,v retrieving revision 1.54 diff -d -p -u -r1.54 ofdisk.c --- sys/dev/ofw/ofdisk.c 26 Jan 2020 21:43:52 -0000 1.54 +++ sys/dev/ofw/ofdisk.c 12 Aug 2022 07:16:14 -0000 @@ -88,7 +88,7 @@ const struct bdevsw ofdisk_bdevsw = { .d_dump = ofdisk_dump, .d_psize = ofdisk_size, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw ofdisk_cdevsw = { @@ -103,7 +103,7 @@ const struct cdevsw ofdisk_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; static void ofminphys(struct buf *); Index: sys/dev/qbus/rl.c =================================================================== RCS file: /cvsroot/src/sys/dev/qbus/rl.c,v retrieving revision 1.53 diff -d -p -u -r1.53 rl.c --- sys/dev/qbus/rl.c 7 Aug 2021 16:19:15 -0000 1.53 +++ sys/dev/qbus/rl.c 12 Aug 2022 07:16:14 -0000 @@ -97,7 +97,7 @@ const struct bdevsw rl_bdevsw = { .d_dump = rldump, .d_psize = rlpsize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw rl_cdevsw = { @@ -112,7 +112,7 @@ const struct cdevsw rl_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; #define MAXRLXFER (RL_BPS * RL_SPT) Index: sys/dev/raidframe/rf_netbsdkintf.c =================================================================== RCS file: /cvsroot/src/sys/dev/raidframe/rf_netbsdkintf.c,v retrieving revision 1.408 diff -d -p -u -r1.408 rf_netbsdkintf.c --- sys/dev/raidframe/rf_netbsdkintf.c 10 Aug 2022 01:16:38 -0000 1.408 +++ sys/dev/raidframe/rf_netbsdkintf.c 12 Aug 2022 07:16:14 -0000 @@ -217,7 +217,7 @@ const struct bdevsw raid_bdevsw = { .d_dump = raiddump, .d_psize = raidsize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw raid_cdevsw = { @@ -232,7 +232,7 @@ const struct cdevsw raid_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; static struct dkdriver rf_dkdriver = { @@ -2928,39 +2928,9 @@ rf_find_raid_components(void) for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); dv != NULL; dv = deviter_next(&di)) { - /* we are only interested in disks */ - if (device_class(dv) != DV_DISK) - continue; - - /* we don't care about floppies */ - if (device_is_a(dv, "fd")) { - continue; - } - - /* we don't care about CDs. */ - if (device_is_a(dv, "cd")) { - continue; - } - - /* we don't care about md. */ - if (device_is_a(dv, "md")) { - continue; - } - - /* hdfd is the Atari/Hades floppy driver */ - if (device_is_a(dv, "hdfd")) { - continue; - } - - /* fdisa is the Atari/Milan floppy driver */ - if (device_is_a(dv, "fdisa")) { - continue; - } - - /* we don't care about spiflash */ - if (device_is_a(dv, "spiflash")) { + /* we are only interested in disks that "contain" things */ + if ((device_bdev_flags(dv) & D_STORAGEPOOL) == 0) continue; - } /* are we in the wedges pass ? */ wedge = device_is_a(dv, "dk"); Index: sys/dev/scsipi/sd.c =================================================================== RCS file: /cvsroot/src/sys/dev/scsipi/sd.c,v retrieving revision 1.334 diff -d -p -u -r1.334 sd.c --- sys/dev/scsipi/sd.c 28 Mar 2022 12:39:46 -0000 1.334 +++ sys/dev/scsipi/sd.c 12 Aug 2022 07:16:14 -0000 @@ -169,7 +169,7 @@ const struct bdevsw sd_bdevsw = { .d_discard = nodiscard, .d_cfdriver = &sd_cd, .d_devtounit = disklabel_dev_unit, - .d_flag = D_DISK | D_MPSAFE + .d_flag = D_DISK | D_MPSAFE | D_STORAGEPOOL }; const struct cdevsw sd_cdevsw = { @@ -186,7 +186,7 @@ const struct cdevsw sd_cdevsw = { .d_discard = nodiscard, .d_cfdriver = &sd_cd, .d_devtounit = disklabel_dev_unit, - .d_flag = D_DISK | D_MPSAFE + .d_flag = D_DISK | D_MPSAFE | D_STORAGEPOOL }; static const struct dkdriver sddkdriver = { Index: sys/dev/vme/xd.c =================================================================== RCS file: /cvsroot/src/sys/dev/vme/xd.c,v retrieving revision 1.98 diff -d -p -u -r1.98 xd.c --- sys/dev/vme/xd.c 7 Aug 2021 16:19:17 -0000 1.98 +++ sys/dev/vme/xd.c 12 Aug 2022 07:16:14 -0000 @@ -299,7 +299,7 @@ const struct bdevsw xd_bdevsw = { .d_dump = xddump, .d_psize = xdsize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw xd_cdevsw = { @@ -314,7 +314,7 @@ const struct cdevsw xd_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; struct xdc_attach_args { /* this is the "aux" args to xdattach */ Index: sys/dev/vme/xy.c =================================================================== RCS file: /cvsroot/src/sys/dev/vme/xy.c,v retrieving revision 1.102 diff -d -p -u -r1.102 xy.c --- sys/dev/vme/xy.c 7 Aug 2021 16:19:17 -0000 1.102 +++ sys/dev/vme/xy.c 12 Aug 2022 07:16:15 -0000 @@ -215,7 +215,7 @@ const struct bdevsw xy_bdevsw = { .d_dump = xydump, .d_psize = xysize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; const struct cdevsw xy_cdevsw = { @@ -230,7 +230,7 @@ const struct cdevsw xy_cdevsw = { .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; struct xyc_attach_args { /* this is the "aux" args to xyattach */ Index: sys/kern/kern_hook.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_hook.c,v retrieving revision 1.13 diff -d -p -u -r1.13 kern_hook.c --- sys/kern/kern_hook.c 31 May 2022 08:43:16 -0000 1.13 +++ sys/kern/kern_hook.c 12 Aug 2022 07:16:16 -0000 @@ -220,6 +220,86 @@ domountroothook(device_t therootdev) } } +/* + * "Mountroot rootspec hook" types, functions, and variables. + */ + +static LIST_HEAD(rootspec_hook_list, rootspec_hook_desc) rootspec_hook_list = + LIST_HEAD_INITIALIZER(rootspec_hook_list); +struct rootspec_hook_desc { + LIST_ENTRY(rootspec_hook_desc) hk_list; + device_t (*hk_hook_func)(const char *); + void (*hk_print_func)(void); + const char *hk_prefix; + size_t hk_prefixlen; +}; + +void * +mountroot_rootspec_hook_establish(const char *prefix, + device_t (*hookfn)(const char *), void (*printfn)(void)) +{ + struct rootspec_hook_desc *hd; + + hd = malloc(sizeof(*hd), M_DEVBUF, M_NOWAIT); + if (hd == NULL) + return (NULL); + + hd->hk_hook_func = hookfn; + hd->hk_print_func = printfn; + hd->hk_prefix = prefix; + hd->hk_prefixlen = strlen(prefix); + LIST_INSERT_HEAD(&rootspec_hook_list, hd, hk_list); + + return hd; +} + +void +mountroot_rootspec_hook_disestablish(void *vhook) +{ +#ifdef DIAGNOSTIC + struct rootspec_hook_desc *hd; + + LIST_FOREACH(hd, &rootspec_hook_list, hk_list) { + if (hd == vhook) + break; + } + + if (hd == NULL) + panic("%s: hook %p not established", __func__, vhook); +#endif + LIST_REMOVE((struct rootspec_hook_desc *)vhook, hk_list); + free(vhook, M_DEVBUF); +} + +device_t +domountroot_rootspec_hooks(const char *spec) +{ + struct rootspec_hook_desc *hd; + device_t ret; + + LIST_FOREACH(hd, &rootspec_hook_list, hk_list) { + if ((strlen(spec) > hd->hk_prefixlen + 1) && + (spec[hd->hk_prefixlen] == ':' || spec[hd->hk_prefixlen] == '=') && + (strncmp(hd->hk_prefix, spec, hd->hk_prefixlen) == 0)) { + ret = (*hd->hk_hook_func)(spec + hd->hk_prefixlen + 1); + if (ret != NULL) + return ret; + } + } + + return NULL; +} + +void +domountroot_rootspec_print(void) +{ + struct rootspec_hook_desc *hd; + + LIST_FOREACH(hd, &rootspec_hook_list, hk_list) + (*hd->hk_print_func)(); +} + + static hook_list_t exechook_list = LIST_HEAD_INITIALIZER(exechook_list); void * Index: sys/kern/kern_subr.c =================================================================== RCS file: /cvsroot/src/sys/kern/kern_subr.c,v retrieving revision 1.230 diff -d -p -u -r1.230 kern_subr.c --- sys/kern/kern_subr.c 19 Mar 2022 13:51:35 -0000 1.230 +++ sys/kern/kern_subr.c 12 Aug 2022 07:16:16 -0000 @@ -109,7 +109,6 @@ __KERNEL_RCSID(0, "$NetBSD: kern_subr.c, static device_t finddevice(const char *); static device_t getdisk(const char *, int, int, dev_t *, int); static device_t parsedisk(const char *, int, int, dev_t *); -static const char *getwedgename(const char *, int); static void setroot_nfs(device_t); static void setroot_md(device_t *); @@ -173,15 +172,6 @@ daddr_t booted_startblk; uint64_t booted_nblks; char *bootspec; -/* - * Use partition letters if it's a disk class but not a wedge or flash. - * XXX Check for wedge/flash is kinda gross. - */ -#define DEV_USES_PARTITIONS(dv) \ - (device_class((dv)) == DV_DISK && \ - !device_is_a((dv), "dk") && \ - !device_is_a((dv), "flash")) - void setroot(device_t bootdv, int bootpartition) { @@ -319,7 +309,7 @@ setroot_ask(device_t bootdv, int bootpar printf("root device"); if (bootdv != NULL) { printf(" (default %s", device_xname(bootdv)); - if (DEV_USES_PARTITIONS(bootdv)) + if (device_has_partitions(bootdv)) printf("%c", bootpartition + 'a'); printf(")"); } @@ -350,7 +340,7 @@ setroot_ask(device_t bootdv, int bootpar * a network device or a disk without partitions, * there is no default dump device. */ - if (DEV_USES_PARTITIONS(rootdv) == 0) + if (!device_has_partitions(rootdv)) defdumpdv = NULL; else defdumpdv = rootdv; @@ -451,7 +441,7 @@ setroot_ask(device_t bootdv, int bootpar case DV_IFNET: case DV_DISK: aprint_normal("root on %s", device_xname(rootdv)); - if (DEV_USES_PARTITIONS(rootdv)) + if (device_has_partitions(rootdv)) aprint_normal("%c", (int)DISKPART(rootdev) + 'a'); break; default: @@ -479,7 +469,6 @@ setroot_root(device_t bootdv, int bootpa dev_t nrootdev; if (rootspec == NULL) { - /* * Wildcarded root; use the boot device. */ @@ -494,7 +483,7 @@ setroot_root(device_t bootdv, int bootpa * Root is on a disk. `bootpartition' is root, * unless the device does not use partitions. */ - if (DEV_USES_PARTITIONS(bootdv)) + if (device_has_partitions(bootdv)) rootdev = MAKEDISKDEV(majdev, device_unit(bootdv), bootpartition); @@ -542,7 +531,7 @@ haveroot: case DV_IFNET: case DV_DISK: aprint_normal("root on %s", device_xname(rootdv)); - if (DEV_USES_PARTITIONS(rootdv)) + if (device_has_partitions(rootdv)) aprint_normal("%c", (int)DISKPART(rootdev) + 'a'); break; default: @@ -615,7 +604,7 @@ setroot_dump(device_t rootdv, device_t d goto nodumpdev; } } else { /* (c) */ - if (DEV_USES_PARTITIONS(rootdv) == 0) { + if (!device_has_partitions(rootdv)) { for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); dv != NULL; dv = deviter_next(&di)) @@ -639,7 +628,7 @@ setroot_dump(device_t rootdv, device_t d dumpcdev = devsw_blk2chr(dumpdev); aprint_normal(" dumps on %s", device_xname(dumpdv)); - if (DEV_USES_PARTITIONS(dumpdv)) + if (device_has_partitions(dumpdv)) aprint_normal("%c", (int)DISKPART(dumpdev) + 'a'); aprint_normal("\n"); return; @@ -653,10 +642,10 @@ setroot_dump(device_t rootdv, device_t d static device_t finddevice(const char *name) { - const char *wname; + device_t dv; - if ((wname = getwedgename(name, strlen(name))) != NULL) - return dkwedge_find_by_wname(wname); + if ((dv = domountroot_rootspec_hooks(name)) != NULL) + return dv; return device_find_by_xname(name); } @@ -682,7 +671,7 @@ getdisk(const char *str, int len, int de printf("use one of:"); for (dv = deviter_first(&di, DEVITER_F_ROOT_FIRST); dv != NULL; dv = deviter_next(&di)) { - if (DEV_USES_PARTITIONS(dv)) + if (device_has_partitions(dv)) printf(" %s[a-%c]", device_xname(dv), 'a' + MAXPARTITIONS - 1); else if (device_class(dv) == DV_DISK) @@ -691,7 +680,7 @@ getdisk(const char *str, int len, int de printf(" %s", device_xname(dv)); } deviter_release(&di); - dkwedge_print_wnames(); + domountroot_rootspec_print(); if (isdump) printf(" none"); #if defined(DDB) @@ -702,28 +691,10 @@ getdisk(const char *str, int len, int de return dv; } -static const char * -getwedgename(const char *name, int namelen) -{ - const char *wpfx1 = "wedge:"; - const char *wpfx2 = "NAME="; - const int wpfx1len = strlen(wpfx1); - const int wpfx2len = strlen(wpfx2); - - if (namelen > wpfx1len && strncmp(name, wpfx1, wpfx1len) == 0) - return name + wpfx1len; - - if (namelen > wpfx2len && strncasecmp(name, wpfx2, wpfx2len) == 0) - return name + wpfx2len; - - return NULL; -} - static device_t parsedisk(const char *str, int len, int defpart, dev_t *devp) { device_t dv; - const char *wname; char c; int majdev, part; char xname[16]; /* same size as dv_xname */ @@ -731,9 +702,7 @@ parsedisk(const char *str, int len, int if (len == 0) return (NULL); - if ((wname = getwedgename(str, len)) != NULL) { - if ((dv = dkwedge_find_by_wname(wname)) == NULL) - return NULL; + if ((dv = domountroot_rootspec_hooks(str)) != NULL) { part = defpart; goto gotdisk; } @@ -757,7 +726,7 @@ parsedisk(const char *str, int len, int majdev = devsw_name2blk(device_xname(dv), NULL, 0); if (majdev < 0) panic("parsedisk"); - if (DEV_USES_PARTITIONS(dv)) + if (device_has_partitions(dv)) *devp = MAKEDISKDEV(majdev, device_unit(dv), part); else Index: sys/kern/subr_device.c =================================================================== RCS file: /cvsroot/src/sys/kern/subr_device.c,v retrieving revision 1.13 diff -d -p -u -r1.13 subr_device.c --- sys/kern/subr_device.c 28 Mar 2022 12:38:59 -0000 1.13 +++ sys/kern/subr_device.c 12 Aug 2022 07:16:16 -0000 @@ -332,6 +332,28 @@ device_attached_to_iattr(device_t dev, c return strcmp(pspec->cfp_iattr, iattr) == 0; } +/* + * device_has_partitions: + * + * Returns true if the device is a DISK device and uses + * partitions. + */ +bool +device_has_partitions(device_t dev) +{ + + return device_class((dev)) == DV_DISK && + !(dev->dv_flags & DVF_NO_PARTITIONS); + +} + +void +device_set_flag(device_t dev, int flag) +{ + + dev->dv_flags |= flag; +} + void device_set_handle(device_t dev, devhandle_t handle) { Index: sys/kern/subr_devsw.c =================================================================== RCS file: /cvsroot/src/sys/kern/subr_devsw.c,v retrieving revision 1.46 diff -d -p -u -r1.46 subr_devsw.c --- sys/kern/subr_devsw.c 9 Jul 2022 10:30:27 -0000 1.46 +++ sys/kern/subr_devsw.c 12 Aug 2022 07:16:16 -0000 @@ -77,6 +77,7 @@ __KERNEL_RCSID(0, "$NetBSD: subr_devsw.c #include #include +#include #include #include #include @@ -1071,6 +1072,18 @@ bdev_type(dev_t dev) } int +device_bdev_flags(device_t dv) +{ + devmajor_t bmajor; + + bmajor = devsw_name2blk(device_xname(dv), NULL, 0); + if (bmajor == NODEVMAJOR) + return 0; + + return bdev_flags(makedev(bmajor, 0)); +} + +int bdev_size(dev_t dev) { const struct bdevsw *d; Index: sys/rump/librump/rumpvfs/rumpblk.c =================================================================== RCS file: /cvsroot/src/sys/rump/librump/rumpvfs/rumpblk.c,v retrieving revision 1.64 diff -d -p -u -r1.64 rumpblk.c --- sys/rump/librump/rumpvfs/rumpblk.c 7 Jul 2016 06:55:44 -0000 1.64 +++ sys/rump/librump/rumpvfs/rumpblk.c 12 Aug 2022 07:16:16 -0000 @@ -102,7 +102,7 @@ static const struct bdevsw rumpblk_bdevs .d_dump = nodump, .d_psize = nosize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; static const struct bdevsw rumpblk_bdevsw_fail = { @@ -113,7 +113,7 @@ static const struct bdevsw rumpblk_bdevs .d_dump = nodump, .d_psize = nosize, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; static const struct cdevsw rumpblk_cdevsw = { @@ -128,7 +128,7 @@ static const struct cdevsw rumpblk_cdevs .d_mmap = nommap, .d_kqfilter = nokqfilter, .d_discard = nodiscard, - .d_flag = D_DISK + .d_flag = D_DISK | D_STORAGEPOOL }; static int backend_open(struct rblkdev *, const char *); Index: sys/sys/conf.h =================================================================== RCS file: /cvsroot/src/sys/sys/conf.h,v retrieving revision 1.161 diff -d -p -u -r1.161 conf.h --- sys/sys/conf.h 28 Mar 2022 12:39:18 -0000 1.161 +++ sys/sys/conf.h 12 Aug 2022 07:16:16 -0000 @@ -64,6 +64,7 @@ struct vnode; #define D_MPSAFE 0x0100 #define D_NEGOFFSAFE 0x0200 #define D_UNUSED0 0x0400 /* was D_MCLOSE */ +#define D_STORAGEPOOL 0x0800 /* Can contain a raid, lvm, zfs, etc */ /* * Block device switch table @@ -212,6 +213,7 @@ int cdev_type(dev_t); int cdev_flags(dev_t); int bdev_type(dev_t); int bdev_flags(dev_t); +int device_bdev_flags(device_t); /* symbolic sleep message strings */ extern const char devopn[], devio[], devwait[], devin[], devout[]; Index: sys/sys/device.h =================================================================== RCS file: /cvsroot/src/sys/sys/device.h,v retrieving revision 1.182 diff -d -p -u -r1.182 device.h --- sys/sys/device.h 28 Mar 2022 12:38:59 -0000 1.182 +++ sys/sys/device.h 12 Aug 2022 07:16:16 -0000 @@ -263,6 +263,7 @@ struct device; */ #define DVF_PRIV_ALLOC 0x0002 /* device private storage != device */ #define DVF_DETACH_SHUTDOWN 0x0080 /* device detaches safely at shutdown */ +#define DVF_NO_PARTITIONS 0x1000 /* (disk) device doesn't have partitions */ #ifdef _KERNEL TAILQ_HEAD(devicelist, device); @@ -619,7 +620,9 @@ void *device_private(device_t); void device_set_private(device_t, void *); prop_dictionary_t device_properties(device_t); void device_set_handle(device_t, devhandle_t); +void device_set_flag(device_t, int); devhandle_t device_handle(device_t); +bool device_has_partitions(device_t); bool devhandle_is_valid(devhandle_t); devhandle_t devhandle_invalid(void); Index: sys/sys/dkio.h =================================================================== RCS file: /cvsroot/src/sys/sys/dkio.h,v retrieving revision 1.26 diff -d -p -u -r1.26 dkio.h --- sys/sys/dkio.h 2 Mar 2020 16:01:56 -0000 1.26 +++ sys/sys/dkio.h 12 Aug 2022 07:16:16 -0000 @@ -33,7 +33,9 @@ #define _SYS_DKIO_H_ #include +#ifndef _STANDALONE #include +#endif /* * Disk-specific ioctls. Index: sys/sys/systm.h =================================================================== RCS file: /cvsroot/src/sys/sys/systm.h,v retrieving revision 1.301 diff -d -p -u -r1.301 systm.h --- sys/sys/systm.h 16 Jun 2021 11:55:10 -0000 1.301 +++ sys/sys/systm.h 12 Aug 2022 07:16:16 -0000 @@ -585,6 +585,14 @@ void mountroothook_disestablish(void *); void mountroothook_destroy(void); void domountroothook(device_t); +/* Regiser rootspec/bootdevice prefixs for per-driver handling. */ +void *mountroot_rootspec_hook_establish(const char *, + device_t (*)(const char *), + void (*)(void)); +void mountroot_rootspec_hook_disestablish(void *); +device_t domountroot_rootspec_hooks(const char *); +void domountroot_rootspec_print(void); + /* * Exec hooks. Subsystems may want to do cleanup when a process * execs.