Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Dec 2006 06:01:27 -0600
From:      "Scot Hetzel" <swhetzel@gmail.com>
To:        emulation@freebsd.org
Subject:   linuxolator: proc/filesystems implementation
Message-ID:  <790a9fff0612140401h7bf0bdb0idb1590120ae95e3f@mail.gmail.com>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Linux has a file in the procfs that shows all the loaded filesystem modules.

I have implemented the function that fills this file using the linprocfs module.

What the function does is look for specific kernel modules using
module_lookupbyname to create an entry in the proc/filesystems file:

# cat /compat/linux/proc/filesystems
            cd9660
nodev   devfs
nodev   bsdprocfs
            mfs
            msdosfs
            nfs
            nfs4
nodev   procfs
nodev   sysfs
            ufs
# kldload smbfs
# cat /compat/linux/proc/filesystems
            cd9660
nodev   devfs
nodev   bsdprocfs
            mfs
            msdosfs
            nfs
            nfs4
nodev   procfs
            smbfs
nodev   sysfs
            ufs

Unloading a filesystem kernel module will remove the entry from
proc/filesystems.

Scot

-- 
DISCLAIMER:
No electrons were mamed while sending this message. Only slightly bruised.

[-- Attachment #2 --]
Index: compat/linprocfs/linprocfs.c
===================================================================
RCS file: /home/ncvs/src/sys/compat/linprocfs/linprocfs.c,v
retrieving revision 1.101
diff -u -r1.101 linprocfs.c
--- compat/linprocfs/linprocfs.c	27 Nov 2006 21:10:55 -0000	1.101
+++ compat/linprocfs/linprocfs.c	29 Nov 2006 05:21:51 -0000
@@ -1031,6 +1031,65 @@
 }
 
 /*
+ * Filler function for proc/filesystems
+ *
+ * NOTE: The only problem is that as new filesystems are added, they
+ *       will need to be added to this list alpabetically, as the
+ *       list can't be updated dynamically.
+ */
+static int
+linprocfs_dofilesystems(PFS_FILL_ARGS)
+{
+
+#define FS_ADD(name, nodev, filesystem) \
+	if (module_lookupbyname(name) != NULL) \
+	    sbuf_printf(sb, "%s\t%s\n", \
+		nodev ? "nodev" : "", filesystem);
+
+	MOD_SLOCK;
+	/*
+	 * Print a list of the currently loaded kernel filesystem modules.
+	 *
+	 *	FreeBSD		No	Linux
+	 *	Kernel		Special Filesystem
+	 *	Module		Device	Name
+	 */
+	FS_ADD("cd9660",	0,	"cd9660");
+	FS_ADD("devfs",		1,	"devfs");
+	FS_ADD("ext2fs",	0,	"ext2fs");
+	FS_ADD("procfs",	1,	"bsdprocfs");	/* renamed procfs module to bsdprocfs */
+	FS_ADD("fdescfs",	1,	"fdescfs");
+	FS_ADD("g_md",		0,	"mfs");
+	FS_ADD("msdosfs",	0,	"msdosfs");
+
+	FS_ADD("nfs",		0,	"nfs");		/* XXX: Should No Special Device be 1 for nfs* */
+	FS_ADD("nfs4",		0,	"nfs4");
+
+	FS_ADD("ntfs",		0,	"ntfs");
+	FS_ADD("nullfs",	1,	"nullfs");
+
+	FS_ADD("nwfs",		0,	"nwfs");	/* XXX: Should No Special Device be 1 for nwfs */
+
+	FS_ADD("linprocfs",	1,	"procfs");	/* renamed to linux filesystem name */
+	FS_ADD("portalfs",	1,	"portalfs");
+	FS_ADD("reiserfs",	0,	"reiserfs");
+
+	FS_ADD("smbfs",		0,	"smbfs");	/* XXX: Should No Special Device be 1 for smbfs */
+
+	FS_ADD("linsysfs",	1,	"sysfs");	/* renamed to linux filesystem name */
+	FS_ADD("udf",		0,	"udf");
+	FS_ADD("ufs",		0,	"ufs");
+	FS_ADD("umapfs",	1,	"umapfs");
+	FS_ADD("unionfs",	1,	"unionfs");
+	FS_ADD("xfs",		0,	"xfs");
+	FS_ADD("zfs",		0,	"zfs");
+	MOD_SUNLOCK;
+#undef FS_ADD
+
+	return (0);
+}
+
+/*
  * Filler function for proc/cmdline
  */
 static int
@@ -1076,6 +1135,8 @@
 	    NULL, NULL, PFS_RD);
 	pfs_create_file(root, "devices", &linprocfs_dodevices,
 	    NULL, NULL, PFS_RD);
+	pfs_create_file(root, "filesystems", &linprocfs_dofilesystems,
+	    NULL, NULL, PFS_RD);
 	pfs_create_file(root, "loadavg", &linprocfs_doloadavg,
 	    NULL, NULL, PFS_RD);
 	pfs_create_file(root, "meminfo", &linprocfs_domeminfo,

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?790a9fff0612140401h7bf0bdb0idb1590120ae95e3f>