From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 27 20:32:20 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 986631065672; Wed, 27 Jan 2010 20:32:20 +0000 (UTC) (envelope-from fernando.apesteguia@gmail.com) Received: from mail-ew0-f218.google.com (mail-ew0-f218.google.com [209.85.219.218]) by mx1.freebsd.org (Postfix) with ESMTP id 05E508FC1B; Wed, 27 Jan 2010 20:32:19 +0000 (UTC) Received: by ewy10 with SMTP id 10so1698475ewy.3 for ; Wed, 27 Jan 2010 12:32:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=p/j/3wfDA/B/2SKpzM55MErA90cR4t/MdvUrpmUSflk=; b=axj0G4zwPZKwg9r1QizyEl/7gExlw/Gse3gImfvXqjJ8Fr0K7Rf6jkxwhivLnznwde aZ+rVLi9l3lAY2wQLpED+F0yzG3lCQPCI3+0+4mrXdTGBg9xvXI2L9+kktgQUaLVXjv2 uwj3lBdkSDex0xc3S+LihaoT6KeXAEboioNTU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=Wl62pMFsLTGB9smoid1Om+rY4TNSlACLAfIhO197hsCy4yLmMzNduYsqAlumPuLE1o eM4R4A2h9NXa5CxhRXTFdy6FaIoYcxnhFyYa8zF3SRmt8OHrUkxmiRBAU7nV39RG0x1r voejx52UmBXfN6Rsqt94uH7RaG2TQ1ja3D5pQ= MIME-Version: 1.0 Received: by 10.213.46.82 with SMTP id i18mr1486731ebf.50.1264624338011; Wed, 27 Jan 2010 12:32:18 -0800 (PST) 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> Date: Wed, 27 Jan 2010 21:32:17 +0100 Message-ID: <1bd550a01001271232r3131a00ci8cf08e0a4ff21816@mail.gmail.com> From: =?ISO-8859-1?Q?Fernando_Apestegu=EDa?= To: John Baldwin Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org Subject: Re: [PATCH] linprocfs dofilesystems X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jan 2010 20:32:20 -0000 2010/1/27 John Baldwin : > On Tuesday 26 January 2010 4:52:35 pm Fernando Apestegu=EDa wrote: >> 2010/1/15 John Baldwin : >> > 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 >