Author: imp
Date: Tue Jan  6 05:28:37 2015
New Revision: 276737
URL: https://svnweb.freebsd.org/changeset/base/276737

Log:
  Remove old ioctl use and support, once and for all.

Modified:
  head/sbin/fsck_ffs/setup.c
  head/sbin/fsirand/fsirand.c
  head/sbin/newfs/newfs.c
  head/sbin/newfs_msdos/newfs_msdos.c
  head/share/man/man4/cd.4
  head/share/man/man4/mcd.4
  head/sys/geom/geom_bsd.c
  head/sys/geom/part/g_part_bsd.c
  head/sys/sys/disklabel.h

Modified: head/sbin/fsck_ffs/setup.c
==============================================================================
--- head/sbin/fsck_ffs/setup.c  Tue Jan  6 05:28:22 2015        (r276736)
+++ head/sbin/fsck_ffs/setup.c  Tue Jan  6 05:28:37 2015        (r276737)
@@ -59,8 +59,6 @@ struct bufarea asblk;
 #define POWEROF2(num)  (((num) & ((num) - 1)) == 0)
 
 static void badsb(int listerr, const char *s);
-static int calcsb(char *dev, int devfd, struct fs *fs);
-static struct disklabel *getdisklabel(char *s, int fd);
 
 /*
  * Read in a superblock finding an alternate if necessary.
@@ -178,7 +176,7 @@ setup(char *dev)
         */
        if (readsb(1) == 0) {
                skipclean = 0;
-               if (bflag || preen || calcsb(dev, fsreadfd, &proto) == 0)
+               if (bflag || preen)
                        return(0);
                if (reply("LOOK FOR ALTERNATE SUPERBLOCKS") == 0)
                        return (0);
@@ -437,7 +435,6 @@ badsb(int listerr, const char *s)
 void
 sblock_init(void)
 {
-       struct disklabel *lp;
 
        fswritefd = -1;
        fsmodified = 0;
@@ -448,89 +445,5 @@ sblock_init(void)
        asblk.b_un.b_buf = Malloc(SBLOCKSIZE);
        if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
                errx(EEXIT, "cannot allocate space for superblock");
-       if ((lp = getdisklabel(NULL, fsreadfd)))
-               real_dev_bsize = dev_bsize = secsize = lp->d_secsize;
-       else
-               dev_bsize = secsize = DEV_BSIZE;
-}
-
-/*
- * Calculate a prototype superblock based on information in the disk label.
- * When done the cgsblock macro can be calculated and the fs_ncg field
- * can be used. Do NOT attempt to use other macros without verifying that
- * their needed information is available!
- */
-static int
-calcsb(char *dev, int devfd, struct fs *fs)
-{
-       struct disklabel *lp;
-       struct partition *pp;
-       char *cp;
-       int i, nspf;
-
-       cp = strchr(dev, '\0') - 1;
-       if (cp == (char *)-1 || ((*cp < 'a' || *cp > 'h') && !isdigit(*cp))) {
-               pfatal("%s: CANNOT FIGURE OUT FILE SYSTEM PARTITION\n", dev);
-               return (0);
-       }
-       lp = getdisklabel(dev, devfd);
-       if (isdigit(*cp))
-               pp = &lp->d_partitions[0];
-       else
-               pp = &lp->d_partitions[*cp - 'a'];
-       if (pp->p_fstype != FS_BSDFFS) {
-               pfatal("%s: NOT LABELED AS A BSD FILE SYSTEM (%s)\n",
-                       dev, pp->p_fstype < FSMAXTYPES ?
-                       fstypenames[pp->p_fstype] : "unknown");
-               return (0);
-       }
-       if (pp->p_fsize == 0 || pp->p_frag == 0 ||
-           pp->p_cpg == 0 || pp->p_size == 0) {
-               pfatal("%s: %s: type %s fsize %d, frag %d, cpg %d, size %d\n",
-                   dev, "INCOMPLETE LABEL", fstypenames[pp->p_fstype],
-                   pp->p_fsize, pp->p_frag, pp->p_cpg, pp->p_size);
-               return (0);
-       }
-       memset(fs, 0, sizeof(struct fs));
-       fs->fs_fsize = pp->p_fsize;
-       fs->fs_frag = pp->p_frag;
-       fs->fs_size = pp->p_size;
-       fs->fs_sblkno = roundup(
-               howmany(lp->d_bbsize + lp->d_sbsize, fs->fs_fsize),
-               fs->fs_frag);
-       nspf = fs->fs_fsize / lp->d_secsize;
-       for (fs->fs_fsbtodb = 0, i = nspf; i > 1; i >>= 1)
-               fs->fs_fsbtodb++;
-       dev_bsize = lp->d_secsize;
-       if (fs->fs_magic == FS_UFS2_MAGIC) {
-               fs->fs_fpg = pp->p_cpg;
-               fs->fs_ncg = howmany(fs->fs_size, fs->fs_fpg);
-       } else /* if (fs->fs_magic == FS_UFS1_MAGIC) */ {
-               fs->fs_old_cpg = pp->p_cpg;
-               fs->fs_old_cgmask = 0xffffffff;
-               for (i = lp->d_ntracks; i > 1; i >>= 1)
-                       fs->fs_old_cgmask <<= 1;
-               if (!POWEROF2(lp->d_ntracks))
-                       fs->fs_old_cgmask <<= 1;
-               fs->fs_old_cgoffset = roundup(howmany(lp->d_nsectors, nspf),
-                   fs->fs_frag);
-               fs->fs_fpg = (fs->fs_old_cpg * lp->d_secpercyl) / nspf;
-               fs->fs_ncg = howmany(fs->fs_size / lp->d_secpercyl,
-                   fs->fs_old_cpg);
-       }
-       return (1);
-}
-
-static struct disklabel *
-getdisklabel(char *s, int fd)
-{
-       static struct disklabel lab;
-
-       if (ioctl(fd, DIOCGDINFO, (char *)&lab) < 0) {
-               if (s == NULL)
-                       return ((struct disklabel *)NULL);
-               pwarn("ioctl (GCINFO): %s\n", strerror(errno));
-               errx(EEXIT, "%s: can't read disk label", s);
-       }
-       return (&lab);
+       dev_bsize = secsize = DEV_BSIZE;
 }

Modified: head/sbin/fsirand/fsirand.c
==============================================================================
--- head/sbin/fsirand/fsirand.c Tue Jan  6 05:28:22 2015        (r276736)
+++ head/sbin/fsirand/fsirand.c Tue Jan  6 05:28:37 2015        (r276737)
@@ -36,7 +36,6 @@ static const char rcsid[] =
 #endif /* not lint */
 
 #include <sys/param.h>
-#include <sys/disklabel.h>
 #include <sys/resource.h>
 
 #include <ufs/ufs/dinode.h>
@@ -120,22 +119,12 @@ fsirand(char *device)
        char sbuf[SBLOCKSIZE], sbuftmp[SBLOCKSIZE];
        int i, devfd, n, cg;
        u_int32_t bsize = DEV_BSIZE;
-       struct disklabel label;
 
        if ((devfd = open(device, printonly ? O_RDONLY : O_RDWR)) < 0) {
                warn("can't open %s", device);
                return (1);
        }
 
-       /* Get block size (usually 512) from disklabel if possible */
-       if (!ignorelabel) {
-               if (ioctl(devfd, DIOCGDINFO, &label) < 0)
-                       warn("can't read disklabel, using sector size of %d",
-                           bsize);
-               else
-                       bsize = label.d_secsize;
-       }
-
        dp1 = NULL;
        dp2 = NULL;
 

Modified: head/sbin/newfs/newfs.c
==============================================================================
--- head/sbin/newfs/newfs.c     Tue Jan  6 05:28:22 2015        (r276736)
+++ head/sbin/newfs/newfs.c     Tue Jan  6 05:28:37 2015        (r276737)
@@ -117,11 +117,9 @@ static u_char   bootarea[BBSIZE];
 static int     is_file;                /* work on a file, not a device */
 static char    *dkname;
 static char    *disktype;
-static int     unlabeled;
 
 static void getfssize(intmax_t *, const char *p, intmax_t, intmax_t);
 static struct disklabel *getdisklabel(char *s);
-static void rewritelabel(char *s, struct disklabel *lp);
 static void usage(void);
 static int expand_number_int(const char *buf, int *num);
 
@@ -402,12 +400,6 @@ main(int argc, char *argv[])
                        pp->p_size *= secperblk;
        }
        mkfs(pp, special);
-       if (!unlabeled) {
-               if (realsectorsize != DEV_BSIZE)
-                       pp->p_size /= realsectorsize / DEV_BSIZE;
-               if (!Nflag && bcmp(pp, &oldpartition, sizeof(oldpartition)))
-                       rewritelabel(special, lp);
-       }
        ufs_disk_close(&disk);
        if (!jflag)
                exit(0);
@@ -451,9 +443,6 @@ getdisklabel(char *s)
                return &lab;
        }
 
-       if (ioctl(disk.d_fd, DIOCGDINFO, (char *)&lab) != -1)
-               return (&lab);
-       unlabeled++;
        if (disktype) {
                lp = getdiskbyname(disktype);
                if (lp != NULL)
@@ -462,25 +451,6 @@ getdisklabel(char *s)
        return (NULL);
 }
 
-void
-rewritelabel(char *s, struct disklabel *lp)
-{
-       if (unlabeled)
-               return;
-       lp->d_checksum = 0;
-       lp->d_checksum = dkcksum(lp);
-       if (is_file) {
-               bsd_disklabel_le_enc(bootarea + 0 /* labeloffset */ +
-                       1 /* labelsoffset */ * sectorsize, lp);
-               lseek(disk.d_fd, 0, SEEK_SET);
-               if (write(disk.d_fd, bootarea, BBSIZE) != BBSIZE)
-                       errx(1, "cannot write label");
-               return;
-       }
-       if (ioctl(disk.d_fd, DIOCWDINFO, (char *)lp) == -1)
-               warn("ioctl (WDINFO): %s: can't rewrite disk label", s);
-}
-
 static void
 usage()
 {

Modified: head/sbin/newfs_msdos/newfs_msdos.c
==============================================================================
--- head/sbin/newfs_msdos/newfs_msdos.c Tue Jan  6 05:28:22 2015        
(r276736)
+++ head/sbin/newfs_msdos/newfs_msdos.c Tue Jan  6 05:28:37 2015        
(r276737)
@@ -829,28 +829,26 @@ getdiskinfo(int fd, const char *fname, c
     if (lp == NULL) {
        if (bpb->bpbBytesPerSec)
            dlp.d_secsize = bpb->bpbBytesPerSec;
-       if (ioctl(fd, DIOCGDINFO, &dlp) == -1) {
-           if (bpb->bpbBytesPerSec == 0 && ioctl(fd, DIOCGSECTORSIZE,
-                                                 &dlp.d_secsize) == -1)
-               err(1, "cannot get sector size");
-
-           dlp.d_secperunit = ms / dlp.d_secsize;
-
-           if (bpb->bpbSecPerTrack == 0 && ioctl(fd, DIOCGFWSECTORS,
-                                                 &dlp.d_nsectors) == -1) {
-               warn("cannot get number of sectors per track");
-               dlp.d_nsectors = 63;
-           }
-           if (bpb->bpbHeads == 0 &&
-               ioctl(fd, DIOCGFWHEADS, &dlp.d_ntracks) == -1) {
-               warn("cannot get number of heads");
-               if (dlp.d_secperunit <= 63*1*1024)
-                   dlp.d_ntracks = 1;
-               else if (dlp.d_secperunit <= 63*16*1024)
-                   dlp.d_ntracks = 16;
-               else
-                   dlp.d_ntracks = 255;
-           }
+       if (bpb->bpbBytesPerSec == 0 && ioctl(fd, DIOCGSECTORSIZE,
+                                             &dlp.d_secsize) == -1)
+           err(1, "cannot get sector size");
+
+       dlp.d_secperunit = ms / dlp.d_secsize;
+
+       if (bpb->bpbSecPerTrack == 0 && ioctl(fd, DIOCGFWSECTORS,
+                                             &dlp.d_nsectors) == -1) {
+           warn("cannot get number of sectors per track");
+           dlp.d_nsectors = 63;
+       }
+       if (bpb->bpbHeads == 0 &&
+           ioctl(fd, DIOCGFWHEADS, &dlp.d_ntracks) == -1) {
+           warn("cannot get number of heads");
+           if (dlp.d_secperunit <= 63*1*1024)
+               dlp.d_ntracks = 1;
+           else if (dlp.d_secperunit <= 63*16*1024)
+               dlp.d_ntracks = 16;
+           else
+               dlp.d_ntracks = 255;
        }
 
        hs = (ms / dlp.d_secsize) - dlp.d_secperunit;

Modified: head/share/man/man4/cd.4
==============================================================================
--- head/share/man/man4/cd.4    Tue Jan  6 05:28:22 2015        (r276736)
+++ head/share/man/man4/cd.4    Tue Jan  6 05:28:37 2015        (r276737)
@@ -101,16 +101,6 @@ in the header files
 and
 .In sys/disklabel.h .
 .Bl -tag -width CDIOCREADSUBCHANNEL
-.It Dv DIOCGDINFO
-.It Dv DIOCSDINFO
-.Pq Li "struct disklabel"
-Read or write the in-core copy of the disklabel for the
-drive.
-The disklabel is initialized with information
-read from the scsi inquiry commands, and should be the same as
-the information printed at boot.
-This structure is defined in the header file
-.In sys/disklabel.h .
 .It Dv CDIOCPLAYTRACKS
 .Pq Li "struct ioc_play_track"
 Start audio playback given a track address and length.

Modified: head/share/man/man4/mcd.4
==============================================================================
--- head/share/man/man4/mcd.4   Tue Jan  6 05:28:22 2015        (r276736)
+++ head/share/man/man4/mcd.4   Tue Jan  6 05:28:37 2015        (r276737)
@@ -56,12 +56,8 @@ The
 driver responds to disk-specific
 .Fn ioctl
 commands, namely the
-.Dv DIOCGDINFO ,
-.Dv DIOCGPART ,
-.Dv DIOCWDINFO ,
-and
-.Dv DIOCSDINFO ,
-commands.
+.Dv DIOCGPART
+command.
 Other disk-specific
 .Fn ioctl
 commands will return an error.

Modified: head/sys/geom/geom_bsd.c
==============================================================================
--- head/sys/geom/geom_bsd.c    Tue Jan  6 05:28:22 2015        (r276736)
+++ head/sys/geom/geom_bsd.c    Tue Jan  6 05:28:37 2015        (r276737)
@@ -305,8 +305,8 @@ g_bsd_hotwrite(void *arg, int flag)
        gsp = gp->softc;
        ms = gsp->softc;
        gsl = &gsp->slices[bp->bio_to->index];
-       p = (u_char*)bp->bio_data + ms->labeloffset 
-           - (bp->bio_offset + gsl->offset);
+       p = (u_char*)bp->bio_data + ms->labeloffset -
+           (bp->bio_offset + gsl->offset);
        error = g_bsd_modify(gp, p);
        if (error) {
                g_io_deliver(bp, EPERM);
@@ -315,93 +315,6 @@ g_bsd_hotwrite(void *arg, int flag)
        g_slice_finish_hot(bp);
 }
 
-/*-
- * This start routine is only called for non-trivial requests, all the
- * trivial ones are handled autonomously by the slice code.
- * For requests we handle here, we must call the g_io_deliver() on the
- * bio, and return non-zero to indicate to the slice code that we did so.
- * This code executes in the "DOWN" I/O path, this means:
- *    * No sleeping.
- *    * Don't grab the topology lock.
- *    * Don't call biowait, g_getattr(), g_setattr() or g_read_data()
- */
-static int
-g_bsd_ioctl(struct g_provider *pp, u_long cmd, void *data, int fflag, struct 
thread *td)
-{
-       struct g_geom *gp;
-       struct g_bsd_softc *ms;
-       struct g_slicer *gsp;
-       u_char *label;
-       int error;
-
-       gp = pp->geom;
-       gsp = gp->softc;
-       ms = gsp->softc;
-
-       switch(cmd) {
-       case DIOCGDINFO:
-               /* Return a copy of the disklabel to userland. */
-               bsd_disklabel_le_dec(ms->label, data, MAXPARTITIONS);
-               return(0);
-       case DIOCBSDBB: {
-               struct g_consumer *cp;
-               u_char *buf;
-               void *p;
-               int error, i;
-               uint64_t sum;
-
-               if (!(fflag & FWRITE))
-                       return (EPERM);
-               /* The disklabel to set is the ioctl argument. */
-               buf = g_malloc(BBSIZE, M_WAITOK);
-               p = *(void **)data;
-               error = copyin(p, buf, BBSIZE);
-               if (!error) {
-                       /* XXX: Rude, but supposedly safe */
-                       DROP_GIANT();
-                       g_topology_lock();
-                       /* Validate and modify our slice instance to match. */
-                       error = g_bsd_modify(gp, buf + ms->labeloffset);
-                       if (!error) {
-                               cp = LIST_FIRST(&gp->consumer);
-                               if (ms->labeloffset == ALPHA_LABEL_OFFSET) {
-                                       sum = 0;
-                                       for (i = 0; i < 63; i++)
-                                               sum += le64dec(buf + i * 8);
-                                       le64enc(buf + 504, sum);
-                               }
-                               error = g_write_data(cp, 0, buf, BBSIZE);
-                       }
-                       g_topology_unlock();
-                       PICKUP_GIANT();
-               }
-               g_free(buf);
-               return (error);
-       }
-       case DIOCSDINFO:
-       case DIOCWDINFO: {
-               if (!(fflag & FWRITE))
-                       return (EPERM);
-               label = g_malloc(LABELSIZE, M_WAITOK);
-               /* The disklabel to set is the ioctl argument. */
-               bsd_disklabel_le_enc(label, data);
-
-               DROP_GIANT();
-               g_topology_lock();
-               /* Validate and modify our slice instance to match. */
-               error = g_bsd_modify(gp, label);
-               if (error == 0 && cmd == DIOCWDINFO)
-                       error = g_bsd_writelabel(gp, NULL);
-               g_topology_unlock();
-               PICKUP_GIANT();
-               g_free(label);
-               return(error);
-       }
-       default:
-               return (ENOIOCTL);
-       }
-}
-
 static int
 g_bsd_start(struct bio *bp)
 {
@@ -698,7 +611,6 @@ static struct g_class g_bsd_class = {
        .taste = g_bsd_taste,
        .ctlreq = g_bsd_config,
        .dumpconf = g_bsd_dumpconf,
-       .ioctl = g_bsd_ioctl,
 };
 
 DECLARE_GEOM_CLASS(g_bsd_class, g_bsd);

Modified: head/sys/geom/part/g_part_bsd.c
==============================================================================
--- head/sys/geom/part/g_part_bsd.c     Tue Jan  6 05:28:22 2015        
(r276736)
+++ head/sys/geom/part/g_part_bsd.c     Tue Jan  6 05:28:37 2015        
(r276737)
@@ -83,8 +83,6 @@ static const char *g_part_bsd_type(struc
 static int g_part_bsd_write(struct g_part_table *, struct g_consumer *);
 static int g_part_bsd_resize(struct g_part_table *, struct g_part_entry *,
     struct g_part_parms *);
-static int g_part_bsd_ioctl(struct g_part_table *, struct g_provider *,
-    u_long cmd, void *data, int fflag, struct thread *td);
 
 static kobj_method_t g_part_bsd_methods[] = {
        KOBJMETHOD(g_part_add,          g_part_bsd_add),
@@ -100,7 +98,6 @@ static kobj_method_t g_part_bsd_methods[
        KOBJMETHOD(g_part_read,         g_part_bsd_read),
        KOBJMETHOD(g_part_type,         g_part_bsd_type),
        KOBJMETHOD(g_part_write,        g_part_bsd_write),
-       KOBJMETHOD(g_part_ioctl,        g_part_bsd_ioctl),
        { 0, 0 }
 };
 
@@ -497,38 +494,6 @@ g_part_bsd_type(struct g_part_table *bas
        return (buf);
 }
 
-/*-
- * This start routine is only called for non-trivial requests, all the
- * trivial ones are handled autonomously by the slice code.
- * For requests we handle here, we must call the g_io_deliver() on the
- * bio, and return non-zero to indicate to the slice code that we did so.
- * This code executes in the "DOWN" I/O path, this means:
- *    * No sleeping.
- *    * Don't grab the topology lock.
- *    * Don't call biowait, g_getattr(), g_setattr() or g_read_data()
- */
-static int
-g_part_bsd_ioctl(struct g_part_table *basetable, struct g_provider *pp,
-    u_long cmd, void *data, int fflag, struct thread *td)
-{
-
-       switch (cmd)
-       {
-       case DIOCGDINFO:
-       {
-               struct g_part_bsd_table *table;
-               u_char *p;
-
-               table = (struct g_part_bsd_table *)basetable;
-               p = table->bbarea + pp->sectorsize;
-               return (bsd_disklabel_le_dec(p, data, MAXPARTITIONS));
-       }
-       default:
-               return (ENOIOCTL);
-
-       }
-}
-
 static int
 g_part_bsd_write(struct g_part_table *basetable, struct g_consumer *cp)
 {

Modified: head/sys/sys/disklabel.h
==============================================================================
--- head/sys/sys/disklabel.h    Tue Jan  6 05:28:22 2015        (r276736)
+++ head/sys/sys/disklabel.h    Tue Jan  6 05:28:37 2015        (r276737)
@@ -284,15 +284,8 @@ static const char *fstypenames[] = {
 #define        D_CHAIN         0x10            /* can do back-back transfers */
 
 /*
- * Disklabel-specific ioctls.
- *
  * NB: <sys/disk.h> defines ioctls from 'd'/128 and up.
  */
-               /* get and set disklabel */
-#define DIOCGDINFO     _IOR('d', 101, struct disklabel)/* get */
-#define DIOCSDINFO     _IOW('d', 102, struct disklabel)/* set */
-#define DIOCWDINFO     _IOW('d', 103, struct disklabel)/* set, update disk */
-#define DIOCBSDBB      _IOW('d', 110, void *)  /* write bootblocks */
 
 /*
  * Functions for proper encoding/decoding of struct disklabel into/from
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to