commit: 4f1c0176ebeff09061afcbc04bf9662f3d13d057
parent c9d17fa2d730553cd67c74ece7a968766a7283e3
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sat, 6 May 2023 14:28:40 +0200
notes/unix-defects: /dev not being a virtual fs
Diffstat:
1 file changed, 11 insertions(+), 0 deletions(-)
diff --git a/notes/unix-defects.xhtml b/notes/unix-defects.xhtml
@@ -77,6 +77,17 @@
</ul>
</p>
+ <h3 id="devtmpfs"><code>/dev</code> isn't a virtual filesystem</h3>
+ <ul>
+ <li>Special files present in <code>/dev</code> need to be present anywhere. But it means remote filesystems, removable storage, … can contain device files with different permissions. Don't forget <code>nodev</code> mount option on basically everything.</li>
+ <li>You must be root, or on linux have the <code>CAP_MKNOD</code> capability, to create <code>/dev</code> special files. This forces things like creating an initramfs to have root.</li>
+ <li>Files present in <code>/dev</code> can be regular files, so you can accidentally end up with <code>/dev/null</code> taking over memory space as various programs write into it.</li>
+ </ul>
+ <p>Should be noted that Linux's <code>devtmpfs</code> somehow fixed <em>none</em> of the above.</p>
+ <p>
+ <code>/dev</code> should be a virtual filesystem, say something that points to a device manager like udev or the kernel itself. Similarly to how it's done for <code>/proc</code> and <code>/sys</code> on Linux.
+ </p>
+
<h2>See Also</h2>
<ul>
<li><a href="https://utcc.utoronto.ca/~cks/space/blog/unix/CLibraryAPIRequiresC">The Unix C library API can only be reliably used from C</a></li>