[PATCH] linprocfs dofilesystems
Fernando Apesteguía
fernando.apesteguia at gmail.com
Wed Jan 27 20:32:20 UTC 2010
2010/1/27 John Baldwin <jhb at freebsd.org>:
> On Tuesday 26 January 2010 4:52:35 pm Fernando Apesteguía wrote:
>> 2010/1/15 John Baldwin <jhb at freebsd.org>:
>> > On Friday 08 January 2010 12:19:29 pm Fernando Apesteguía 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. It seems that /proc/filesystems is a list of
>> > available filesystems, not a list of mounted filesystems. E.g.:
>> >
>> >> cat /proc/filesystems
>> > nodev sysfs
>> > nodev rootfs
>> > nodev bdev
>> > nodev proc
>> > nodev sockfs
>> > nodev binfmt_misc
>> > nodev usbfs
>> > nodev usbdevfs
>> > nodev futexfs
>> > nodev tmpfs
>> > nodev pipefs
>> > nodev eventpollfs
>> > nodev devpts
>> > ext2
>> > nodev ramfs
>> > nodev hugetlbfs
>> > iso9660
>> > nodev relayfs
>> > nodev mqueue
>> > ext3
>> > nodev rpc_pipefs
>> > nodev nfs
>> > nodev nfs4
>> > nodev autofs
>> >
>> > To do the same thing in FreeBSD you would need to walk the vfsconf list
>> > instead. However, I'm not sure it is worth it to add this unless there
>> > 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 filesystems
> from device-backed filesystems. Hmm, maybe the VFCF_SYNTHETIC flag? If
> you have an updated patch I'm ok with reviewing it. What 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
>
More information about the freebsd-hackers
mailing list