At Mon, 06 Feb 2006 14:03:28 +0100, [EMAIL PROTECTED] (Ludovic Courtès) wrote: > On GNU/Linux with, say, an ext[23] filesystem, a directory does not > implement the file interface, only the directory interface. Thus, for > instance, `cat DIR' returns `EISDIR'. > > On some other systems (e.g., Tru64 with AdvFS IIRC), directories do > implement both interfaces. So there, one can `cat' the contents of a > directory and it just shows its ``binary content''. > > This difference doesn't preclude good behavior of `grep', `find' and > friends. This is because those programs call `stat ()' before actually > accessing the node, and look at the value of `S_ISDIR ()' _before_ > looking at the value of `S_ISREG ()'. In OO terms: they check for the > most specialized type first. > > IOW, the `st_mode' field can be viewed as a poor man's type system. ;-)
Unfortunately, the actual behaviour of these utilities seems to be much more complex than you describe. For example, "rm -fR foo" first may try to simply unlink() foo, without a stat. Then, when it recurses, it may look at the directory entry's "d_type" field. As it happens, on the Hurd, d_type contains the type of the _underlying_ node, not of the translated node, d'oh! In the presence of hybrid or translated nodes, these tools can behave in a difficult to predict way. Thanks, Marcus _______________________________________________ L4-hurd mailing list [email protected] http://lists.gnu.org/mailman/listinfo/l4-hurd
