Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs Drop two uses of disk label data.



details:   https://anonhg.NetBSD.org/src/rev/1ef507b0e8f7
branches:  trunk
changeset: 751171:1ef507b0e8f7
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Tue Jan 26 21:29:48 2010 +0000

description:
Drop two uses of disk label data.

msdosfs and cd9660 are the only filesystems that verify the filesystem
type in the label. This is the wrong place, sanity checks should only
rely on the inner structure of the filesystem (like signatures or
magic numbers).

msdosfs also used the device type information from the label to
deduce a filesystem parameter heuristically for the gemdos variant.
If there is no information inside the filesystem data itself, this
should be an explicit mount option.

diffstat:

 sys/fs/cd9660/cd9660_vfsops.c   |   7 +++----
 sys/fs/msdosfs/msdosfs_vfsops.c |  25 ++++++-------------------
 2 files changed, 9 insertions(+), 23 deletions(-)

diffs (114 lines):

diff -r 4cd4a2b2f093 -r 1ef507b0e8f7 sys/fs/cd9660/cd9660_vfsops.c
--- a/sys/fs/cd9660/cd9660_vfsops.c     Tue Jan 26 21:27:54 2010 +0000
+++ b/sys/fs/cd9660/cd9660_vfsops.c     Tue Jan 26 21:29:48 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_vfsops.c,v 1.69 2010/01/08 11:35:08 pooka Exp $ */
+/*     $NetBSD: cd9660_vfsops.c,v 1.70 2010/01/26 21:29:48 mlelstv Exp $       */
 
 /*-
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.69 2010/01/08 11:35:08 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.70 2010/01/26 21:29:48 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -368,8 +368,7 @@
        iso_bsize = ISO_DEFAULT_BLOCK_SIZE;
 
        error = VOP_IOCTL(devvp, DIOCGDINFO, &label, FREAD, FSCRED);
-       if (!error &&
-           label.d_partitions[DISKPART(dev)].p_fstype == FS_ISO9660) {
+       if (!error) {
                /* XXX more sanity checks? */
                sess = label.d_partitions[DISKPART(dev)].p_cdsession;
        } else {
diff -r 4cd4a2b2f093 -r 1ef507b0e8f7 sys/fs/msdosfs/msdosfs_vfsops.c
--- a/sys/fs/msdosfs/msdosfs_vfsops.c   Tue Jan 26 21:27:54 2010 +0000
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c   Tue Jan 26 21:29:48 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_vfsops.c,v 1.77 2010/01/25 15:30:44 mlelstv Exp $      */
+/*     $NetBSD: msdosfs_vfsops.c,v 1.78 2010/01/26 21:29:48 mlelstv Exp $      */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.77 2010/01/25 15:30:44 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.78 2010/01/26 21:29:48 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -471,7 +471,7 @@
        struct byte_bpb710 *b710;
        u_int8_t SecPerClust;
        int     ronly, error, tmp;
-       int     bsize, dtype, fstype, secsize;
+       int     bsize, secsize;
        u_int64_t psize;
 
        /* Flush out any old buffers remaining from a previous use. */
@@ -485,9 +485,7 @@
 
        /*
         * We need the disklabel to calculate the size of a FAT entry
-        * later on. Also make sure the partition contains a filesystem
-        * of type FS_MSDOS. This doesn't work for floppies, so we have
-        * to check for them too.
+        * later on.
         *
         * There might still be parts of the msdos fs driver which assume
         * that the size of a disk block will always be 512 bytes.
@@ -496,16 +494,12 @@
        error = VOP_IOCTL(devvp, DIOCGPART, &dpart, FREAD, NOCRED);
        if (error == 0) {
                secsize = dpart.disklab->d_secsize;
-               dtype = dpart.disklab->d_type;
-               fstype = dpart.part->p_fstype;
                psize = dpart.part->p_size;
        } else {
                struct dkwedge_info dkw;
                struct disk *pdk;
                error = VOP_IOCTL(devvp, DIOCGWEDGEINFO, &dkw, FREAD, NOCRED);
                secsize = 512;  /* XXX */
-               dtype = DTYPE_FLOPPY; /* XXX */
-               fstype = FS_MSDOS;
                psize = -1;
                if (error) {
                        if (error != ENOTTY) {
@@ -520,16 +514,13 @@
                                goto error_exit;
                        }
                        secsize = DEV_BSIZE << pdk->dk_blkshift;
-                       fstype = strcmp(dkw.dkw_ptype, DKW_PTYPE_FAT) == 0 ?
-                           FS_MSDOS : -1;
                        psize = dkw.dkw_size;
                }
        }
        if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
                bsize = secsize;
                if (bsize != 512) {
-                       DPRINTF(("bsize %d dtype %d fstype %d\n", bsize, dtype,
-                           fstype));
+                       DPRINTF(("Invalid block bsize %d for gemdos\n", bsize));
                        error = EINVAL;
                        goto error_exit;
                }
@@ -696,11 +687,7 @@
        pmp->pm_fatsize = pmp->pm_FATsecs * pmp->pm_BytesPerSec;
 
        if (argp->flags & MSDOSFSMNT_GEMDOSFS) {
-               if (pmp->pm_nmbrofclusters <= (0xff0 - 2)
-                     && (dtype == DTYPE_FLOPPY
-                         || (dtype == DTYPE_VND
-                               && (pmp->pm_Heads == 1 || pmp->pm_Heads == 2)))
-                   ) {
+               if (pmp->pm_nmbrofclusters <= (0xff0 - 2)) {
                        pmp->pm_fatmask = FAT12_MASK;
                        pmp->pm_fatmult = 3;
                        pmp->pm_fatdiv = 2;



Home | Main Index | Thread Index | Old Index