Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jan 2010 21:32:17 +0100
From:      =?ISO-8859-1?Q?Fernando_Apestegu=EDa?= <fernando.apesteguia@gmail.com>
To:        John Baldwin <jhb@freebsd.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: [PATCH] linprocfs dofilesystems
Message-ID:  <1bd550a01001271232r3131a00ci8cf08e0a4ff21816@mail.gmail.com>
In-Reply-To: <201001270856.24324.jhb@freebsd.org>
References:  <1bd550a01001080919p20ec1b20t82b3761705cd1ff3@mail.gmail.com> <201001151110.29417.jhb@freebsd.org> <1bd550a01001261352h1ecc22dbh8fd2dcf9c8ac51c5@mail.gmail.com> <201001270856.24324.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
2010/1/27 John Baldwin <jhb@freebsd.org>:
> On Tuesday 26 January 2010 4:52:35 pm Fernando Apestegu=EDa wrote:
>> 2010/1/15 John Baldwin <jhb@freebsd.org>:
>> > On Friday 08 January 2010 12:19:29 pm Fernando Apestegu=EDa wrote:
>> >> Hi all,
>> >>
>> >> This patch implements the "filesystems" file in the linux proc fs.
>> >> I have used it for some time without seeing any problems. Let me
>> >> know in case this is useful.
>> >>
>> >> Tested against 8.0-RELEASE-p1
>> >
>> > This patch is not correct. =A0It seems that /proc/filesystems is a lis=
t of
>> > available filesystems, not a list of mounted filesystems. =A0E.g.:
>> >
>> >> cat /proc/filesystems
>> > nodev =A0 sysfs
>> > nodev =A0 rootfs
>> > nodev =A0 bdev
>> > nodev =A0 proc
>> > nodev =A0 sockfs
>> > nodev =A0 binfmt_misc
>> > nodev =A0 usbfs
>> > nodev =A0 usbdevfs
>> > nodev =A0 futexfs
>> > nodev =A0 tmpfs
>> > nodev =A0 pipefs
>> > nodev =A0 eventpollfs
>> > nodev =A0 devpts
>> > =A0 =A0 =A0 =A0ext2
>> > nodev =A0 ramfs
>> > nodev =A0 hugetlbfs
>> > =A0 =A0 =A0 =A0iso9660
>> > nodev =A0 relayfs
>> > nodev =A0 mqueue
>> > =A0 =A0 =A0 =A0ext3
>> > nodev =A0 rpc_pipefs
>> > nodev =A0 nfs
>> > nodev =A0 nfs4
>> > nodev =A0 autofs
>> >
>> > To do the same thing in FreeBSD you would need to walk the vfsconf lis=
t
>> > instead. =A0However, I'm not sure it is worth it to add this unless th=
ere
>> > are apps people commonly use that need it.
>>
>> You are right. I have another patch to do the right thing. However as
>> you pointed
>> out maybe it is not useful after all. Is it possible to delete the PR?
>>
>> Sorry for the noise
>>
>> PS: My current patch does not distinguish between common filesystems
>> and pseudo filesystems, where could I find that info?
>>
>> Cheers
>
> Hmm, I'm not sure if there is an easy way to distinguish psuedo filesyste=
ms
> from device-backed filesystems. =A0Hmm, maybe the VFCF_SYNTHETIC flag? =
=A0If
> you have an updated patch I'm ok with reviewing it. =A0What programs are =
you
> using that use this file in linprocfs?

I don't need the file right now. I did it for completeness although it
could help to
procinfo[1] gsysinfo[2] and a personal application I wrote some time ago[3]=
.
I am not a kernel developer, but I found this interesting as an exercise.
That is the main reason I tried to implement this file.

The new patch is attached. VFCF_SYNTHETIC seems to work fine as this patch =
shows
in my system:

$ cat /compat/linux/proc/filesystems
nodev	procfs
	cd9660
	nfs
nodev	devfs
	ufs
	msdosfs
nodev	linprocfs
	ntfs

I suspect using procfs is not the most portable way of gathering
information in a UNIX system
Am I right? If so, what is the preferred way? Using sysctl?

Thanks.

/* Patch begin */
--- linprocfs.c.orig	2009-10-25 02:10:29.000000000 +0100
+++ linprocfs.c	2010-01-27 21:10:08.000000000 +0100
@@ -1227,6 +1227,24 @@
 	return (0);
 }

+/*
+ * Filler function for proc/filesystems
+ */
+
+static int
+linprocfs_dofilesystems(PFS_FILL_ARGS)
+{
+	struct vfsconf *vfsp;
+
+	TAILQ_FOREACH(vfsp, &vfsconf, vfc_list) {
+		if (vfsp->vfc_flags & VFCF_SYNTHETIC)
+			sbuf_printf(sb, "nodev");
+		sbuf_printf(sb, "\t%s\n", vfsp->vfc_name);
+	}
+
+	return(0);
+}
+
 #if 0
 /*
  * Filler function for proc/modules
@@ -1266,6 +1284,8 @@
 	    NULL, NULL, NULL, PFS_RD);
 	pfs_create_file(root, "meminfo", &linprocfs_domeminfo,
 	    NULL, NULL, NULL, PFS_RD);
+	pfs_create_file(root, "filesystems", &linprocfs_dofilesystems,
+	    NULL, NULL, NULL, PFS_RD);
 #if 0
 	pfs_create_file(root, "modules", &linprocfs_domodules,
 	    NULL, NULL, NULL, PFS_RD);
/* Patch end*/


[1] http://linux.die.net/man/8/procinfo
[2] http://sourceforge.net/projects/gsysinfo/
[3] http://lkmonitor.sf.net





>
> --
> John Baldwin
>



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