Chris Costello wrote:

> On Saturday, September 08, 2001, Maxim Sobolev wrote:
> > I don't like idea to hardcode the same string ("procfs"), with the
> > same meaning in several places across kernel. As for your proposition
> > to use f_fstypename to set v_tag, it is even more bogus because
> > value of the f_fstypename is supplied from the user level, so
> > potentially it could be anything and we can't make any reasonable
> > assumptions about mapping between its value and type of the filesystem
> > in question.
>
>    How do you figure?  The contents if `f_fstypename' must match
> a configured file system exactly, so it could _not_ be anything.
> To quote sys/kern/vfs_syscalls.c:mount():

Oh, yes, you are correct obviously (don't know what I was thinking about). In this
case, it looks like v_tag is redundant, because f_fstypename could be used instead
in a few places where v_tag is abused (the same applies to the statfs.f_type
because essentually it is the same thing as v_tag). Poul, what do you think about
it? In the meantime, I found another place in the kernel where VT_* macros are
[ab]used - it is Linuxlator, attached please find patches to fix it - please
review.

-Maxim
Index: linux_stats.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linux/linux_stats.c,v
retrieving revision 1.37
diff -d -u -r1.37 linux_stats.c
--- linux_stats.c       2001/09/12 08:36:57     1.37
+++ linux_stats.c       2001/09/18 11:52:02
@@ -187,10 +187,6 @@
        l_int           f_spare[6];
 };
 
-#ifndef VT_NWFS
-#define        VT_NWFS VT_TFS  /* XXX - bug compat. with sys/fs/nwfs/nwfs_node.h */
-#endif
-
 #define        LINUX_CODA_SUPER_MAGIC  0x73757245L
 #define        LINUX_EXT2_SUPER_MAGIC  0xEF53L
 #define        LINUX_HPFS_SUPER_MAGIC  0xf995e849L
@@ -202,34 +198,30 @@
 #define        LINUX_PROC_SUPER_MAGIC  0x9fa0L
 #define        LINUX_UFS_SUPER_MAGIC   0x00011954L     /* XXX - UFS_MAGIC in Linux */
 
-/*
- * ext2fs uses the VT_UFS tag. A mounted ext2 filesystem will therefore
- * be seen as an ufs filesystem.
- */
 static long
-bsd_to_linux_ftype(int tag)
+bsd_to_linux_ftype(const char *fstypename)
 {
 
-       switch (tag) {
-       case VT_CODA:
+       if (strcmp(fstypename, "coda") == 0)
                return (LINUX_CODA_SUPER_MAGIC);
-       case VT_HPFS:
+       else if (strcmp(fstypename, "hpfs") == 0)
                return (LINUX_HPFS_SUPER_MAGIC);
-       case VT_ISOFS:
+       else if (strcmp(fstypename, "cd9660") == 0)
                return (LINUX_ISOFS_SUPER_MAGIC);
-       case VT_MSDOSFS:
+       else if (strcmp(fstypename, "msdosfs") == 0)
                return (LINUX_MSDOS_SUPER_MAGIC);
-       case VT_NFS:
+       else if (strcmp(fstypename, "nfs") == 0)
                return (LINUX_NFS_SUPER_MAGIC);
-       case VT_NTFS:
+       else if (strcmp(fstypename, "ntfs") == 0)
                return (LINUX_NTFS_SUPER_MAGIC);
-       case VT_NWFS:
+       else if (strcmp(fstypename, "nwfs") == 0)
                return (LINUX_NCP_SUPER_MAGIC);
-       case VT_PROCFS:
+       else if (strcmp(fstypename, "procfs") == 0)
                return (LINUX_PROC_SUPER_MAGIC);
-       case VT_UFS:
+       else if (strcmp(fstypename, "ufs") == 0)
                return (LINUX_UFS_SUPER_MAGIC);
-       }
+       else if (strcmp(fstypename, "ext2fs") == 0)
+               return (LINUX_EXT2_SUPER_MAGIC);
 
        return (0L);
 }
@@ -265,7 +257,7 @@
        if (error)
                return error;
        bsd_statfs->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
-       linux_statfs.f_type = bsd_to_linux_ftype(bsd_statfs->f_type);
+       linux_statfs.f_type = bsd_to_linux_ftype(bsd_statfs->f_fstypename);
        linux_statfs.f_bsize = bsd_statfs->f_bsize;
        linux_statfs.f_blocks = bsd_statfs->f_blocks;
        linux_statfs.f_bfree = bsd_statfs->f_bfree;
@@ -301,7 +293,7 @@
        if (error)
                return error;
        bsd_statfs->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
-       linux_statfs.f_type = bsd_to_linux_ftype(bsd_statfs->f_type);
+       linux_statfs.f_type = bsd_to_linux_ftype(bsd_statfs->f_fstypename);
        linux_statfs.f_bsize = bsd_statfs->f_bsize;
        linux_statfs.f_blocks = bsd_statfs->f_blocks;
        linux_statfs.f_bfree = bsd_statfs->f_bfree;

Reply via email to