On Sat, Aug 08, 2020 at 01:13:20PM +1000, Jonathan Gray wrote:
> On Fri, Aug 07, 2020 at 12:59:00PM -0700, jo...@armadilloaerospace.com wrote:
> > Perform an explicit check for the unsupported exFAT MSDOS filesystem
> > instead of letting it fail mysteriously when it gets cluster sizes
> > of 0 from the normal fields.
> > 
> > This causes mount_msdos to report:
> > mount_msdos: /dev/sd1i on /root/mnt: filesystem not supported by kernel
> > 
> > Instead of the more obscure:
> > mount_msdos: /dev/sd1i on /root/mnt: Inapropriate file type or format
> > 
> > Index: msdosfs_vfsops.c
> > ===================================================================
> > RCS file: /cvs/src/sys/msdosfs/msdosfs_vfsops.c,v
> > retrieving revision 1.93
> > diff -u -p -r1.93 msdosfs_vfsops.c
> > --- msdosfs_vfsops.c        24 Jan 2020 03:49:34 -0000      1.93
> > +++ msdosfs_vfsops.c        7 Aug 2020 19:52:04 -0000
> > @@ -298,6 +298,12 @@ msdosfs_mountfs(struct vnode *devvp, str
> >     b50 = (struct byte_bpb50 *)bsp->bs50.bsBPB;
> >     b710 = (struct byte_bpb710 *)bsp->bs710.bsBPB;
> >  
> > +   /* No support for exFAT filesystems */
> > +   if (!strncmp("EXFAT", bsp->bs33.bsOemName, 5)) {
> > +           error = EOPNOTSUPP;
> > +           goto error_exit;
> > +   }
> > +
> >     pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK | M_ZERO);
> >     pmp->pm_mountp = mp;
> 
> The microsoft specification states it is EXFAT followed by three spaces
> 
>       if (!memcmp("EXFAT   ", bsp->bs33.bsOemName, 8)) {
> 
> may be more suitable here.

Thinking about this some more the problem is really the choice of errno.
It used to be EINVAL but was changed to EFTYPE in

----------------------------
revision 1.7
date: 1997/06/20 14:04:30;  author: kstailey;  state: Exp;  lines: +7 -7;
Change errno cause by mounting invalid filesystems from EINVAL to EFTYPE.
----------------------------

mount_msdos(8) knows about EINVAL and will print "not an MSDOS filesystem"

On reading mount(2) EOPNOTSUPP would be suitable for when the kernel
did not have msdos support built in not when the blocks found are not
msdos.

So either mount_msdos gains a EFTYPE case or we go back to EINVAL.

Index: sys/msdosfs/msdosfs_vfsops.c
===================================================================
RCS file: /cvs/src/sys/msdosfs/msdosfs_vfsops.c,v
retrieving revision 1.93
diff -u -p -r1.93 msdosfs_vfsops.c
--- sys/msdosfs/msdosfs_vfsops.c        24 Jan 2020 03:49:34 -0000      1.93
+++ sys/msdosfs/msdosfs_vfsops.c        9 Aug 2020 09:22:31 -0000
@@ -321,7 +321,7 @@ msdosfs_mountfs(struct vnode *devvp, str
        pmp->pm_BlkPerSec = pmp->pm_BytesPerSec / DEV_BSIZE;
 
        if (!pmp->pm_BytesPerSec || !SecPerClust) {
-               error = EFTYPE;
+               error = EINVAL;
                goto error_exit;
        }
 
@@ -451,7 +451,7 @@ msdosfs_mountfs(struct vnode *devvp, str
         * must be a power of 2
         */
        if (pmp->pm_bpcluster ^ (1 << pmp->pm_cnshift)) {
-               error = EFTYPE;
+               error = EINVAL;
                goto error_exit;
        }
 
Index: sys/ufs/ffs/ffs_vfsops.c
===================================================================
RCS file: /cvs/src/sys/ufs/ffs/ffs_vfsops.c,v
retrieving revision 1.185
diff -u -p -r1.185 ffs_vfsops.c
--- sys/ufs/ffs/ffs_vfsops.c    24 Jun 2020 22:03:45 -0000      1.185
+++ sys/ufs/ffs/ffs_vfsops.c    9 Aug 2020 09:24:58 -0000
@@ -754,14 +754,6 @@ ffs_mountfs(struct vnode *devvp, struct 
                fs = (struct fs *) bp->b_data;
                sbloc = sbtry[i];
 
-#if 0
-               if (fs->fs_magic == FS_UFS2_MAGIC) {
-                       printf("ffs_mountfs(): Sorry, no UFS2 support (yet)\n");
-                       error = EFTYPE;
-                       goto out;
-               }
-#endif
-
                /*
                 * Do not look for an FFS1 file system at SBLOCK_UFS2. Doing so
                 * will find the wrong super-block for file systems with 64k
@@ -813,7 +805,7 @@ ffs_mountfs(struct vnode *devvp, struct 
                printf("ffs_mountfs(): obsolete rotational table format, "
                    "please use fsck_ffs(8) -c 1\n");
 #endif
-               error = EFTYPE;
+               error = EINVAL;
                goto out;
        }
 

Reply via email to