LWN: Comments on "Creating Linux virtual filesystems" https://lwn.net/Articles/13325/ This is a special feed containing comments posted to the individual LWN article titled "Creating Linux virtual filesystems". en-us Fri, 19 Sep 2025 01:41:20 +0000 Fri, 19 Sep 2025 01:41:20 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Creating Linux virtual filesystems https://lwn.net/Articles/780400/ https://lwn.net/Articles/780400/ lumotwe <div class="FormattedComment"> <a rel="nofollow" href="https://gist.github.com/RadNi/9d8a074e6264c1664b97b8eee11b1d2a">https://gist.github.com/RadNi/9d8a074e6264c1664b97b8eee11...</a><br> <p> port to linux 4.15<br> </div> Thu, 21 Feb 2019 02:34:19 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/490543/ https://lwn.net/Articles/490543/ viro <div class="FormattedComment"> Several points:<br> <p> 1) return value of mount_single() is struct dentry *; so's that of -&gt;mount(). IOW, the body is correct, but declaration isn't - it should return struct dentry *, not struct super_block *.<br> <p> 2) use d_make_root() instead of d_alloc_root(); cleanup is easier with that one (and d_alloc_root() will be gone in 3.4 anyway). In this case it becomes simply<br> <p> root = lfs_make_inode (sb, S_IFDIR | 0755);<br> if (root) {<br> root-&gt;i_op = &amp;simple_dir_inode_operations;<br> root-&gt;i_fop = &amp;simple_dir_operations;<br> }<br> sb-&gt;s_root = d_make_root(root);<br> if (!sb-&gt;s_root)<br> return -ENOMEM;<br> lfs_create_files(sb, sb-&gt;s_root);<br> return 0;<br> <p> 3) simple_read_from_buffer() is your friend. Instead of<br> <p> len = snprintf(tmp, TMPSIZE, "%d\n", v);<br> if (*offset &gt; len)<br> return 0;<br> if (count &gt; len - *offset)<br> count = len - *offset;<br> /*<br> * Copy it back, increment the offset, and we're done.<br> */<br> if (copy_to_user(buf, tmp + *offset, count))<br> return -EFAULT;<br> *offset += count;<br> return count;<br> <p> just do<br> <p> len = snprintf(tmp, TMPSIZE, "%d\n", v);<br> return simple_read_from_buffer(buf, count, offset, tmp, len);<br> <p> and be done with that.<br> <p> 4) no need to open-code d_alloc_name(). Or simple_mkdir(), for that matter...<br> <p> </div> Wed, 04 Apr 2012 06:11:53 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/490539/ https://lwn.net/Articles/490539/ crxz0193 <div class="FormattedComment"> to make it work with the linux 3.0 change following:<br> /*<br> * Stuff to pass in when registering the filesystem.<br> */<br> static struct super_block *lfs_get_super(struct file_system_type *fst,<br> int flags, char *devname, void *data)<br> {<br> /* return get_sb_single(fst, flags, data, lfs_fill_super, mnt);*/<br> return mount_single(fst, flags, data, lfs_fill_super);<br> }<br> <p> static struct file_system_type lfs_type = {<br> .owner = THIS_MODULE,<br> .name = "lwnfs",<br> .mount = lfs_get_super,<br> /*.get_sb = lfs_get_super,*/<br> .kill_sb = kill_litter_super,<br> };<br> <p> </div> Wed, 04 Apr 2012 05:24:10 +0000 Creating Linux virtual filesystems a Question https://lwn.net/Articles/174180/ https://lwn.net/Articles/174180/ gjpc Thanks very much for this helpful article.<br> <p> I have a questions about mounted file systems within file systems.<br> <p> Let's say within a ext3 root file system I create a file system foo at mount point /fooRoot.<br> <p> I then create a node within the foo file system fooChild.<br> <p> I then create sub node to fooChild, fooGrand.<br> <p> Now I mount a ext2 file system on node fooGrand. <br> <p> When a user tries to fopen( "/fooRoot/fooChild/fooGrand/someFile", "r" ) will that open request somhow be cleared through the foo file system before handed to the ext2 file system?<br> <p> <p> Thu, 02 Mar 2006 18:48:36 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/78664/ https://lwn.net/Articles/78664/ domenpk You are not supposed to mkfs it, or associate it with a device, just &quot;mount -t lwnfs none /some/where&quot; should work Thu, 01 Apr 2004 20:12:49 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/76655/ https://lwn.net/Articles/76655/ mojozoox Ya alright i managed to tweak the filesystem to run on linux 2.4. But im unable to mount it ...<p>mkfs -t option does not seem to work with the lwnfs okay!<p>could somebody help on how to go about it to associate it to a device and then mount it to mountpoint. Mon, 22 Mar 2004 13:31:04 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/14016/ https://lwn.net/Articles/14016/ erich I'd like to see some experience reviews of replicating filesystems (preferrably based on such virtual filesystems) but also on Coda, OpenAFS, Intermezzo, SFS (which is non replicating, but a nice secure network file system).<br>Especially on such issues like reliable locking, ease of setup, speed of replication etc. I'd love to have a mail server on a replicating set of servers (using Maildir of course, not mbox). Preferably capable of disconnected operation - having one mail server in the US, one in Europe would be cool...<p>Greetings,<br>Erich<p>P.S. Thanks to HP, LWN and Bdale for the Debian Group Subscription. Tue, 29 Oct 2002 19:32:19 +0000 Split the difference https://lwn.net/Articles/13706/ https://lwn.net/Articles/13706/ esnyder I don't know; I liked the extra technical information, and would not really change the amount of code inline in the article. However, I did find myself wishing for a conclusion that offered some details on the kinds of (non-trivial) things that one might implement as virtual filesystems. While the counter-per-file was great to give a quick overview of how to implement something, I'm not sure I really got the big picture.<p>Count me in as voting for continued 'special interest' articles when time permits.<br> Thu, 24 Oct 2002 22:40:56 +0000 per process filesystem namespace https://lwn.net/Articles/13687/ https://lwn.net/Articles/13687/ brouhaha There's a simple solution to that: if a setuid program gets loaded when there is a per-process namespace active, the kernel can ignore the setuid bit and run it with no privileges.<p>AFAICT, that would allow non-privileged users to play with their namespace all they want, without compromising system integrity.<br> Thu, 24 Oct 2002 20:20:27 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/13603/ https://lwn.net/Articles/13603/ ekj Well a filesystem that lives in its own module doesn't bother anyone who doesn't load it. &quot;lwnfs&quot; now exists. It bothers noone. Those who want their linux-box to be able to count in kernel-mode can insmod it, the rest of us can go on our merry way.<p>:-) Thu, 24 Oct 2002 07:42:47 +0000 per process filesystem namespace https://lwn.net/Articles/13594/ https://lwn.net/Articles/13594/ brugolsky Al Viro also snuck it into 2.4.19. :-) It ought to be possible to allow non-root mounts on mount points where the user has write permission. As Jon noted, letting the user mount over, e.g., /etc/passwd, is incompatible with setuid executables.<p>I'm beginning to think about this because I want to start using Ron Minnich's implementation of 9P (v9fs.sourceforge.net) for various development and admin tasks.<p>Great article Jon -- once Al Viro adds union-mount, may a thousand<br>mini filesystems bloom. :-P Thu, 24 Oct 2002 02:11:41 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/13550/ https://lwn.net/Articles/13550/ airwin Thanks for that additional link. Wed, 23 Oct 2002 19:40:26 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/13540/ https://lwn.net/Articles/13540/ corbet Sorry you didn't like it...it was meant to be a far more technical piece than usually appears on the Kernel Page. The technical level of that page isn't changing, but I think it's worth putting in some more hardcore stuff occasionally. <p> <blockquote>"<i>The introduction gives the impression that we might end up with hundreds of special file systems in the near future, and I believe that would be an even worse mess than the current /proc. </i>"</blockquote> <p> That is a definite risk; the Linux system of the future could well have management issues that we don't see now. <p> <blockquote>"<i>Your conclusion then does give a tantalizing indication that there are other ways to export information than a special file system, but this needs expansion.</i>"</blockquote> <p> The device model was covered in some detail <a href="http://lwn.net/Articles/8287/">back in August</a>. Wed, 23 Oct 2002 18:38:22 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/13508/ https://lwn.net/Articles/13508/ airwin <p>Actually, I didn't like this article as much as the other posters here. To my mind the balance between introductory material (which most LWN readers can understand) and technical details (which most LWN readers cannot understand) is off. Here are my two suggestions:</p> <p>(1) I suggest you should have included the same technical details, but hide them in the link to your overall source code for the small subset of your readers who are interested. After all, the main point here is that libfs creates a boilerplate way of creating your own special file system; the details of the boilerplate are not that interesting until the day you actually want to create your own filesystem.</p> <p>(2) Please expand the introductory and concluding material. The introduction gives the impression that we might end up with hundreds of special file systems in the near future, and I believe that would be an even worse mess than the current /proc. Your conclusion then does give a tantalizing indication that there are other ways to export information than a special file system, but this needs expansion.</p> Wed, 23 Oct 2002 16:50:08 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/13493/ https://lwn.net/Articles/13493/ corbet No, the code is correct - <tt>lfs_create_file</tt> already gets a pointer to the counter as an argument, there's no need to indirect it again. Wed, 23 Oct 2002 15:16:10 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/13490/ https://lwn.net/Articles/13490/ nick.leroy Nice, informative article. Great!<p>However, if I'm not mistaken, isn't the following line incorrect, or did I miss something?<br> inode-&gt;u.generic_ip = counter;<br>Shouldn't it be (note the pointer to counter):<br> inode-&gt;u.generic_ip = &amp;counter;<p>Once again, great article.<p>-Nick<br> Wed, 23 Oct 2002 14:59:01 +0000 per process filesystem namespace https://lwn.net/Articles/13465/ https://lwn.net/Articles/13465/ corbet 2.5 has per-process namespaces, allowing the administrator to set up completely different views of the filesystem for different tasks. This capability remains restricted to root, though. If any user could set up any namespace they wanted, there would be a thousand ways to confuse setuid programs and take over the system. Wed, 23 Oct 2002 12:34:42 +0000 Subscriber needs https://lwn.net/Articles/13436/ https://lwn.net/Articles/13436/ veelo Agreed!<p>&gt; European Union<br>Make that Europe; it will take a couple of decades (or eternity) before all European countries have joined the Union... Maybe we should just stick to continents, I suspect LWN readers are spread over too many countries.<p>Bastiaan. Wed, 23 Oct 2002 10:04:07 +0000 per process filesystem namespace https://lwn.net/Articles/13435/ https://lwn.net/Articles/13435/ scottt On a somewhat related topic, I was under the impression that in 2.5 the VFS supports per process namespaces so a user without root priviledges can mount filesystems at will. Can someone confirm this ? Wed, 23 Oct 2002 06:05:05 +0000 Subscriber needs https://lwn.net/Articles/13433/ https://lwn.net/Articles/13433/ smoogen Thanks for the info. I think that having the number on the front page would be a useful thing. This is a new way of doing things and so people might start understanding that they cant just wait for others to support you. <p>While not on the page it would be interesting to see how the country breakdown is with something like:<p> % of subscriptions % of visitors (derived from IP)<br>United States <br>European Union<br>Japan<br>Canada<br>Mexico<p>Now that is something to be nationalistic about :)<br> Wed, 23 Oct 2002 04:38:29 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/13425/ https://lwn.net/Articles/13425/ roelofs So you wrote this article, Jonathan? That was a tad difficult to divine from the actual posting, even though you were the most likely suspect (as Kernel page editor and all)... Perhaps a subtitle or closing block or <I>something</I> with an attribution in the future? (Don't be shy about tooting your own horn, eh? You might consider naming a few names on the About page, too.) <P> Greg Wed, 23 Oct 2002 00:41:41 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/13415/ https://lwn.net/Articles/13415/ gregkh Ah, missed the <tt>kill_litter_super()</tt> reference, nice.<br> <br> But does this mean that if you unmount the fs, and then mount it again, the "counter" file is created from scratch, with a initialized value?<br> <br> If so, this might not be what you want for a fs that is tied to a driver. You might want to keep around the files between mounts, and not be forced to regenerate them all every mount time. This can be seen in <tt>usbfs</tt> where the files are created when a device is added or removed from the system. We don't walk all devices at mount time, although that might not be a bad idea...<br> <br> Anyway, this is a minor point, very nice article, it matches my upcoming <a href="http://linux.conf.au/speakers.html#gregkh">linux.conf.au talk and paper</a> quite well :)<br> <br> Oh, and for doing something like this for the 2.4 kernel, <a href="http://www.linuxjournal.com/article.php?sid=5633">this article</a> might help out a bit.<br> Tue, 22 Oct 2002 22:13:09 +0000 Subscriber needs https://lwn.net/Articles/13402/ https://lwn.net/Articles/13402/ corbet Last week, when we were just short of 2000, we set a goal of 4000 as a relatively stable place to be somewhere not too far into next year at the latest. We up to almost 2100 now, so progress is happening...but the rate of new subscriptions is (not surprisingly) dropping off; it's probably going to take some serious work to get that doubling. Tue, 22 Oct 2002 20:32:11 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/13401/ https://lwn.net/Articles/13401/ smoogen Really nice article. It helps me on looking at something different today. So how many more subscribers are needed for your employment needs? Tue, 22 Oct 2002 20:29:06 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/13392/ https://lwn.net/Articles/13392/ corbet Actually, it unloads just fine. Trust me, I loaded/unloaded it a lot of times before I was ready to write anything about it... Only had to reboot once, though&#160;:). I haven't followed it too far, but my understanding is that <tt>kill_litter_super()</tt> cleans up all of that junk at unmount time. Tue, 22 Oct 2002 19:50:54 +0000 Creating Linux virtual filesystems https://lwn.net/Articles/13390/ https://lwn.net/Articles/13390/ gregkh Nice article.<br> <br> Unfortunatly, your module is not able to be unloaded, right (I'm guessing as I haven't tried the code myself)? Problem is that nothing is removing the files that you have created, forcing the module count to always remain positive.<br> <br> To work around this, see the gyrations I had to do with <tt>get_mount</tt> and <tt>put_mount</tt> in the <tt>drivers/hotplug/pci_hotplug.c</tt> and <tt>drivers/usb/core/inode.c</tt> code. And patches to help port those two files to use libfs more are greatly appreciated :) Tue, 22 Oct 2002 19:23:06 +0000