Auto-allocation of disks into a disklabel needs DIOCGPDINFO support.

Can't even compile these, so confirmation that this actually compiles
would be appreciated. In most cases I just punted as the physical
info is unconditionally put into the disklabel at attach time.

These are all the files I could find that had DIOCGDINFO and not
DIOCGPDINFO.

ok?

.... Ken

Index: ./arch/sparc/dev/presto.c
===================================================================
RCS file: /cvs/src/sys/arch/sparc/dev/presto.c,v
retrieving revision 1.19
diff -u -p -r1.19 presto.c
--- ./arch/sparc/dev/presto.c   22 Sep 2010 01:18:57 -0000      1.19
+++ ./arch/sparc/dev/presto.c   22 Sep 2010 05:04:21 -0000
@@ -71,7 +71,7 @@ struct presto_softc {
 
 void   prestostrategy(struct buf *);
 void   presto_attach(struct device *, struct device *, void *);
-void   presto_getdisklabel(dev_t, struct presto_softc *);
+void   presto_getdisklabel(dev_t, struct presto_softc *, struct disklabel *, 
int);
 int    presto_match(struct device *, void *, void *);
 
 struct cfattach presto_ca = {
@@ -209,7 +209,7 @@ prestoopen(dev_t dev, int flag, int fmt,
                return (ENXIO);
 
        /* read the disk label */
-       presto_getdisklabel(dev, sc);
+       presto_getdisklabel(dev, sc, sc->sc_dk.dk_label, 0);
 
        /* only allow valid partitions */
        part = DISKPART(dev);
@@ -324,6 +324,10 @@ prestoioctl(dev_t dev, u_long cmd, caddr
        sc = (struct presto_softc *)device_lookup(&presto_cd, unit);
 
        switch (cmd) {
+       case DIOCGPDINFO:
+               presto_getdisklabel(dev, sc, (struct disklabel *)data, 1);
+               break;
+
        case DIOCGDINFO:
                bcopy(sc->sc_dk.dk_label, data, sizeof(struct disklabel));
                return (0);
@@ -351,10 +355,9 @@ prestoioctl(dev_t dev, u_long cmd, caddr
  * Read the disklabel. If none is present, use a fictitious one instead.
  */
 void
-presto_getdisklabel(dev_t dev, struct presto_softc *sc)
+presto_getdisklabel(dev_t dev, struct presto_softc *sc, struct disklabel *lp,
+    int spoofonly);
 {
-       struct disklabel *lp = sc->sc_dk.dk_label;
-
        bzero(sc->sc_dk.dk_label, sizeof(struct disklabel));
 
        lp->d_secsize = DEV_BSIZE;
@@ -373,5 +376,5 @@ presto_getdisklabel(dev_t dev, struct pr
        lp->d_magic2 = DISKMAGIC;
        lp->d_checksum = dkcksum(lp);
 
-       readdisklabel(DISKLABELDEV(dev), prestostrategy, sc->sc_dk.dk_label, 0);
+       readdisklabel(DISKLABELDEV(dev), prestostrategy, lp, spoofonly);
 }
Index: ./arch/sparc/dev/xd.c
===================================================================
RCS file: /cvs/src/sys/arch/sparc/dev/xd.c,v
retrieving revision 1.51
diff -u -p -r1.51 xd.c
--- ./arch/sparc/dev/xd.c       22 Sep 2010 01:18:57 -0000      1.51
+++ ./arch/sparc/dev/xd.c       22 Sep 2010 05:04:21 -0000
@@ -839,6 +839,7 @@ xdioctl(dev, command, addr, flag, p)
                return 0;
 
        case DIOCGDINFO:        /* get disk label */
+       case DIOCGPDINFO:       /* no separate 'physical' info available. */
                bcopy(xd->sc_dk.dk_label, addr, sizeof(struct disklabel));
                return 0;
 
Index: ./arch/sparc/dev/xy.c
===================================================================
RCS file: /cvs/src/sys/arch/sparc/dev/xy.c,v
retrieving revision 1.49
diff -u -p -r1.49 xy.c
--- ./arch/sparc/dev/xy.c       22 Sep 2010 01:18:57 -0000      1.49
+++ ./arch/sparc/dev/xy.c       22 Sep 2010 05:04:21 -0000
@@ -800,6 +800,7 @@ xyioctl(dev, command, addr, flag, p)
                return 0;
 
        case DIOCGDINFO:        /* get disk label */
+       case DIOCGPDINFO:       /* no separate 'physical' info available. */
                bcopy(xy->sc_dk.dk_label, addr, sizeof(struct disklabel));
                return 0;
 
Index: ./arch/vax/mba/hp.c
===================================================================
RCS file: /cvs/src/sys/arch/vax/mba/hp.c,v
retrieving revision 1.22
diff -u -p -r1.22 hp.c
--- ./arch/vax/mba/hp.c 22 Sep 2010 01:18:57 -0000      1.22
+++ ./arch/vax/mba/hp.c 22 Sep 2010 05:04:21 -0000
@@ -329,6 +329,7 @@ hpioctl(dev, cmd, addr, flag, p)
 
        switch (cmd) {
        case    DIOCGDINFO:
+       case    DIOCGPDINFO:    /* no separate 'physical' info available. */
                bcopy(lp, addr, sizeof (struct disklabel));
                return 0;
 
Index: ./arch/vax/mscp/mscp_disk.c
===================================================================
RCS file: /cvs/src/sys/arch/vax/mscp/mscp_disk.c,v
retrieving revision 1.31
diff -u -p -r1.31 mscp_disk.c
--- ./arch/vax/mscp/mscp_disk.c 22 Sep 2010 01:18:57 -0000      1.31
+++ ./arch/vax/mscp/mscp_disk.c 22 Sep 2010 05:04:21 -0000
@@ -378,6 +378,7 @@ raioctl(dev, cmd, data, flag, p)
        switch (cmd) {
 
        case DIOCGDINFO:
+       case DIOCGPDINFO:       /* no separate 'physical' info available. */
                bcopy(lp, data, sizeof (struct disklabel));
                break;
 
Index: ./arch/vax/vsa/hdc9224.c
===================================================================
RCS file: /cvs/src/sys/arch/vax/vsa/hdc9224.c,v
retrieving revision 1.32
diff -u -p -r1.32 hdc9224.c
--- ./arch/vax/vsa/hdc9224.c    22 Sep 2010 01:18:57 -0000      1.32
+++ ./arch/vax/vsa/hdc9224.c    22 Sep 2010 05:04:21 -0000
@@ -164,6 +164,7 @@ void hdattach(struct device *, struct de
 void hdcintr(void *);
 int hdc_command(struct hdcsoftc *, int);
 void hd_readgeom(struct hdcsoftc *, struct hdsoftc *);
+int hdgetdisklabel(dev_t, hdsoftc *, struct disklabel *, int);
 #ifdef HDDEBUG
 void hdc_printgeom( struct hdgeom *);
 #endif
@@ -337,6 +338,14 @@ hdmatch(parent, vcf, aux)
 
 #define        HDMAJOR 19
 
+int
+hdgetdisklabel(dev_t dev, hdsoftc *sc, struct disklabel *lp, int spoofonly)
+{
+       hdmakelabel(lp, &hd->sc_xbn);
+
+       return readdisklabel(DISKLABEL(dev), hdstrategy, lp, spoofonly);
+}
+
 void
 hdattach(struct device *parent, struct device *self, void *aux)
 {
@@ -360,9 +369,8 @@ hdattach(struct device *parent, struct d
        hd_readgeom(sc, hd);
        disk_printtype(hd->sc_drive, hd->sc_xbn.media_id);
        dl = hd->sc_disk.dk_label;
-       hdmakelabel(dl, &hd->sc_xbn);
-       error = readdisklabel(MAKEDISKDEV(HDMAJOR, hd->sc_dev.dv_unit, 
RAW_PART),
-           hdstrategy, dl, 0);
+       error = hdgetdisklabel(MAKEDISKDEV(HDMAJOR, hd->sc_dev.dv_unit, 
RAW_PART),
+           hd, dl, 0);
        printf("%s: %luMB, %lu sectors\n",
            hd->sc_dev.dv_xname, DL_GETDSIZE(dl) / (1048576 / DEV_BSIZE),
            DL_GETDSIZE(dl));
@@ -700,6 +708,10 @@ hdioctl(dev_t dev, u_long cmd, caddr_t a
        int error = 0;
 
        switch (cmd) {
+       case DIOCGPDINFO:
+               hdgetdisklabel(dev, hd, (struct disklabel *)addr, 1);
+               break;
+
        case DIOCGDINFO:
                bcopy(lp, addr, sizeof (struct disklabel));
                break;
Index: ./dev/flash.c
===================================================================
RCS file: /cvs/src/sys/dev/flash.c,v
retrieving revision 1.18
diff -u -p -r1.18 flash.c
--- ./dev/flash.c       22 Sep 2010 01:18:57 -0000      1.18
+++ ./dev/flash.c       22 Sep 2010 05:04:21 -0000
@@ -850,9 +850,14 @@ flashioctl(dev_t dev, u_long cmd, caddr_
        }
 
        switch (cmd) {
+       case DIOCGPDINFO:
+               flashgetdisklabel(dev, sc, (struct disklabel *)data, 1);
+               break
+
        case DIOCGDINFO:
                *(struct disklabel *)data = *sc->sc_dk.dk_label;
                break;
+
        default:
                error = ENOTTY;
                break;

Reply via email to