diff options
author | phk <phk@FreeBSD.org> | 1999-08-28 14:33:44 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1999-08-28 14:33:44 +0000 |
commit | 9c72381e09a5593df856423c995563779f7535e8 (patch) | |
tree | 3471f1e5faa7dd2bf47573f428c3a46114bac456 /sys/kern | |
parent | a261857e2d7ff67439a916b9f0b8db5e91302af0 (diff) | |
download | FreeBSD-src-9c72381e09a5593df856423c995563779f7535e8.zip FreeBSD-src-9c72381e09a5593df856423c995563779f7535e8.tar.gz |
We don't need to pass the diskname argument all over the diskslice/label
code, we can find the name from any convenient dev_t
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/subr_disklabel.c | 2 | ||||
-rw-r--r-- | sys/kern/subr_diskmbr.c | 28 | ||||
-rw-r--r-- | sys/kern/subr_diskslice.c | 62 |
3 files changed, 42 insertions, 50 deletions
diff --git a/sys/kern/subr_disklabel.c b/sys/kern/subr_disklabel.c index a52efbd..e3a734c 100644 --- a/sys/kern/subr_disklabel.c +++ b/sys/kern/subr_disklabel.c @@ -373,7 +373,7 @@ diskerr(bp, dname, what, pri, blkdone, lp) pr = addlog; } else pr = printf; - sname = dsname(dname, unit, slice, part, partname); + sname = dsname(bp->b_dev, unit, slice, part, partname); (*pr)("%s%s: %s %sing fsbn ", sname, partname, what, bp->b_flags & B_READ ? "read" : "writ"); sn = bp->b_blkno; diff --git a/sys/kern/subr_diskmbr.c b/sys/kern/subr_diskmbr.c index 3425379..6d05806 100644 --- a/sys/kern/subr_diskmbr.c +++ b/sys/kern/subr_diskmbr.c @@ -64,7 +64,7 @@ static struct dos_partition historical_bogus_partition_table[NDOSPART] = { static int check_part __P((char *sname, struct dos_partition *dp, u_long offset, int nsectors, int ntracks, u_long mbr_offset)); -static void extended __P((char *dname, dev_t dev, struct disklabel *lp, +static void mbr_extended __P((dev_t dev, struct disklabel *lp, struct diskslices *ssp, u_long ext_offset, u_long ext_size, u_long base_ext_offset, int nsectors, int ntracks, u_long mbr_offset)); @@ -150,8 +150,7 @@ check_part(sname, dp, offset, nsectors, ntracks, mbr_offset ) } int -dsinit(dname, dev, lp, sspp) - char *dname; +dsinit(dev, lp, sspp) dev_t dev; struct disklabel *lp; struct diskslices **sspp; @@ -182,7 +181,8 @@ reread_mbr: bp->b_flags |= B_READ; BUF_STRATEGY(bp, 1); if (biowait(bp) != 0) { - diskerr(bp, dname, "error reading primary partition table", + diskerr(bp, devtoname(bp->b_dev), + "error reading primary partition table", LOG_PRINTF, 0, (struct disklabel *)NULL); printf("\n"); error = EIO; @@ -191,7 +191,7 @@ reread_mbr: /* Weakly verify it. */ cp = bp->b_data; - sname = dsname(dname, dkunit(dev), WHOLE_DISK_SLICE, RAW_PART, + sname = dsname(dev, dkunit(dev), WHOLE_DISK_SLICE, RAW_PART, partname); if (cp[0x1FE] != 0x55 || cp[0x1FF] != 0xAA) { if (bootverbose) @@ -263,7 +263,7 @@ reread_mbr: if (dp->dp_scyl == 0 && dp->dp_shd == 0 && dp->dp_ssect == 0 && dp->dp_start == 0 && dp->dp_size == 0) continue; - sname = dsname(dname, dkunit(dev), BASE_SLICE + dospart, + sname = dsname(dev, dkunit(dev), BASE_SLICE + dospart, RAW_PART, partname); /* @@ -326,7 +326,7 @@ reread_mbr: for (dospart = 0; dospart < NDOSPART; dospart++, sp++) if (sp->ds_type == DOSPTYP_EXTENDED || sp->ds_type == DOSPTYP_EXTENDEDX) - extended(dname, bp->b_dev, lp, ssp, + mbr_extended(bp->b_dev, lp, ssp, sp->ds_offset, sp->ds_size, sp->ds_offset, max_nsectors, max_ntracks, mbr_offset); @@ -339,9 +339,8 @@ done: } void -extended(dname, dev, lp, ssp, ext_offset, ext_size, base_ext_offset, +mbr_extended(dev, lp, ssp, ext_offset, ext_size, base_ext_offset, nsectors, ntracks, mbr_offset) - char *dname; dev_t dev; struct disklabel *lp; struct diskslices *ssp; @@ -371,7 +370,8 @@ extended(dname, dev, lp, ssp, ext_offset, ext_size, base_ext_offset, bp->b_flags |= B_READ; BUF_STRATEGY(bp, 1); if (biowait(bp) != 0) { - diskerr(bp, dname, "error reading extended partition table", + diskerr(bp, devtoname(bp->b_dev), + "error reading extended partition table", LOG_PRINTF, 0, (struct disklabel *)NULL); printf("\n"); goto done; @@ -380,7 +380,7 @@ extended(dname, dev, lp, ssp, ext_offset, ext_size, base_ext_offset, /* Weakly verify it. */ cp = bp->b_data; if (cp[0x1FE] != 0x55 || cp[0x1FF] != 0xAA) { - sname = dsname(dname, dkunit(dev), WHOLE_DISK_SLICE, RAW_PART, + sname = dsname(dev, dkunit(dev), WHOLE_DISK_SLICE, RAW_PART, partname); if (bootverbose) printf("%s: invalid extended partition table: no magic\n", @@ -400,7 +400,7 @@ extended(dname, dev, lp, ssp, ext_offset, ext_size, base_ext_offset, dp->dp_typ == DOSPTYP_EXTENDEDX) { char buf[32]; - sname = dsname(dname, dkunit(dev), WHOLE_DISK_SLICE, + sname = dsname(dev, dkunit(dev), WHOLE_DISK_SLICE, RAW_PART, partname); snprintf(buf, sizeof(buf), "%s", sname); if (strlen(buf) < sizeof buf - 11) @@ -410,7 +410,7 @@ extended(dname, dev, lp, ssp, ext_offset, ext_size, base_ext_offset, ext_offsets[dospart] = base_ext_offset + dp->dp_start; ext_sizes[dospart] = dp->dp_size; } else { - sname = dsname(dname, dkunit(dev), slice, RAW_PART, + sname = dsname(dev, dkunit(dev), slice, RAW_PART, partname); check_part(sname, dp, ext_offset, nsectors, ntracks, mbr_offset); @@ -431,7 +431,7 @@ extended(dname, dev, lp, ssp, ext_offset, ext_size, base_ext_offset, /* If we found any more slices, recursively find all the subslices. */ for (dospart = 0; dospart < NDOSPART; dospart++) if (ext_sizes[dospart] != 0) - extended(dname, dev, lp, ssp, ext_offsets[dospart], + mbr_extended(dev, lp, ssp, ext_offsets[dospart], ext_sizes[dospart], base_ext_offset, nsectors, ntracks, mbr_offset); diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c index 4d154c9..771f285 100644 --- a/sys/kern/subr_diskslice.c +++ b/sys/kern/subr_diskslice.c @@ -88,12 +88,8 @@ static void set_ds_bad __P((struct diskslices *ssp, int slice, struct dkbad_intern *btp)); static void set_ds_label __P((struct diskslices *ssp, int slice, struct disklabel *lp)); -#ifdef DEVFS -static void set_ds_labeldevs __P((char *dname, dev_t dev, - struct diskslices *ssp)); -static void set_ds_labeldevs_unaliased __P((char *dname, dev_t dev, - struct diskslices *ssp)); -#endif +static void set_ds_labeldevs __P((dev_t dev, struct diskslices *ssp)); +static void set_ds_labeldevs_unaliased __P((dev_t dev, struct diskslices *ssp)); static void set_ds_wlabel __P((struct diskslices *ssp, int slice, int wlabel)); @@ -375,8 +371,7 @@ dsgone(sspp) * is subject to the same restriction as dsopen(). */ int -dsioctl(dname, dev, cmd, data, flags, sspp) - char *dname; +dsioctl(dev, cmd, data, flags, sspp) dev_t dev; u_long cmd; caddr_t data; @@ -476,9 +471,7 @@ dsioctl(dname, dev, cmd, data, flags, sspp) } free_ds_label(ssp, slice); set_ds_label(ssp, slice, lp); -#ifdef DEVFS - set_ds_labeldevs(dname, dev, ssp); -#endif + set_ds_labeldevs(dev, ssp); return (0); case DIOCSYNCSLICEINFO: @@ -502,7 +495,7 @@ dsioctl(dname, dev, cmd, data, flags, sspp) *sspp = NULL; lp = malloc(sizeof *lp, M_DEVBUF, M_WAITOK); *lp = *ssp->dss_slices[WHOLE_DISK_SLICE].ds_label; - error = dsopen(dname, dev, + error = dsopen(dev, ssp->dss_slices[WHOLE_DISK_SLICE].ds_copenmask & (1 << RAW_PART) ? S_IFCHR : S_IFBLK, ssp->dss_oflags, sspp, lp); @@ -522,7 +515,7 @@ dsioctl(dname, dev, cmd, data, flags, sspp) part = 0; openmask; openmask >>= 1, part++) { if (!(openmask & 1)) continue; - error = dsopen(dname, + error = dsopen( dkmodslice(dkmodpart(dev, part), slice), S_IFBLK, ssp->dss_oflags, sspp, @@ -539,7 +532,7 @@ dsioctl(dname, dev, cmd, data, flags, sspp) part = 0; openmask; openmask >>= 1, part++) { if (!(openmask & 1)) continue; - error = dsopen(dname, + error = dsopen( dkmodslice(dkmodpart(dev, part), slice), S_IFCHR, ssp->dss_oflags, sspp, @@ -560,7 +553,7 @@ dsioctl(dname, dev, cmd, data, flags, sspp) return (0); case DIOCWDINFO: - error = dsioctl(dname, dev, DIOCSDINFO, data, flags, &ssp); + error = dsioctl(dev, DIOCSDINFO, data, flags, &ssp); if (error != 0) return (error); /* @@ -660,15 +653,17 @@ dsmakeslicestruct(nslices, lp) } char * -dsname(dname, unit, slice, part, partname) - char *dname; +dsname(dev, unit, slice, part, partname) + dev_t dev; int unit; int slice; int part; char *partname; { static char name[32]; + char *dname; + dname = devsw(dev)->d_name; if (strlen(dname) > 16) dname = "nametoolong"; snprintf(name, sizeof(name), "%s%d", dname, unit); @@ -689,8 +684,7 @@ dsname(dname, unit, slice, part, partname) * strategy routine must be special to allow activity. */ int -dsopen(dname, dev, mode, flags, sspp, lp) - char *dname; +dsopen(dev, mode, flags, sspp, lp) dev_t dev; int mode; u_int flags; @@ -721,7 +715,7 @@ dsopen(dname, dev, mode, flags, sspp, lp) unit = dkunit(dev); if (lp->d_secsize % DEV_BSIZE) { - printf("%s%d: invalid sector size %lu\n", dname, unit, + printf("%s: invalid sector size %lu\n", devtoname(dev), (u_long)lp->d_secsize); return (EINVAL); } @@ -744,7 +738,7 @@ dsopen(dname, dev, mode, flags, sspp, lp) if (!(flags & DSO_ONESLICE)) { TRACE(("dsinit\n")); - error = dsinit(dname, dev, lp, sspp); + error = dsinit(dev, lp, sspp); if (error != 0) { dsgone(sspp); return (error); @@ -793,7 +787,7 @@ dsopen(dname, dev, mode, flags, sspp, lp) ) continue; dev1 = dkmodslice(dkmodpart(dev, RAW_PART), slice); - sname = dsname(dname, unit, slice, RAW_PART, partname); + sname = dsname(dev, unit, slice, RAW_PART, partname); #ifdef DEVFS if (slice != COMPATIBILITY_SLICE && sp->ds_bdev == NULL && sp->ds_size != 0) { @@ -850,9 +844,7 @@ dsopen(dname, dev, mode, flags, sspp, lp) } } set_ds_label(ssp, slice, lp1); -#ifdef DEVFS - set_ds_labeldevs(dname, dev1, ssp); -#endif + set_ds_labeldevs(dev1, ssp); set_ds_wlabel(ssp, slice, FALSE); } @@ -1092,33 +1084,33 @@ set_ds_label(ssp, slice, lp) ssp->dss_slices[COMPATIBILITY_SLICE].ds_label = lp; } -#ifdef DEVFS static void -set_ds_labeldevs(dname, dev, ssp) - char *dname; +set_ds_labeldevs(dev, ssp) dev_t dev; struct diskslices *ssp; { +#ifdef DEVFS int slice; - set_ds_labeldevs_unaliased(dname, dev, ssp); + set_ds_labeldevs_unaliased(dev, ssp); if (ssp->dss_first_bsd_slice == COMPATIBILITY_SLICE) return; slice = dkslice(dev); if (slice == COMPATIBILITY_SLICE) - set_ds_labeldevs_unaliased(dname, + set_ds_labeldevs_unaliased( dkmodslice(dev, ssp->dss_first_bsd_slice), ssp); else if (slice == ssp->dss_first_bsd_slice) - set_ds_labeldevs_unaliased(dname, + set_ds_labeldevs_unaliased( dkmodslice(dev, COMPATIBILITY_SLICE), ssp); +#endif /* DEVFS */ } static void -set_ds_labeldevs_unaliased(dname, dev, ssp) - char *dname; +set_ds_labeldevs_unaliased(dev, ssp) dev_t dev; struct diskslices *ssp; { +#ifdef DEVFS struct disklabel *lp; int mynor; int part; @@ -1137,7 +1129,7 @@ set_ds_labeldevs_unaliased(dname, dev, ssp) pp = &lp->d_partitions[part]; if (pp->p_size == 0) continue; - sname = dsname(dname, dkunit(dev), slice, part, partname); + sname = dsname(dev, dkunit(dev), slice, part, partname); if (part == RAW_PART && sp->ds_bdev != NULL) { sp->ds_bdevs[part] = devfs_makelink(sp->ds_bdev, @@ -1157,8 +1149,8 @@ set_ds_labeldevs_unaliased(dname, dev, ssp) "r%s%s", sname, partname); } } -} #endif /* DEVFS */ +} static void set_ds_wlabel(ssp, slice, wlabel) |