[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DogCows or Polymorphism in the Hurd

From: Ludovic Courtès
Subject: Re: DogCows or Polymorphism in the Hurd
Date: Mon, 06 Feb 2006 14:03:28 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)


(Only quickly reading the thread, so I hope my answer makes sense

Marcus Brinkmann <address@hidden> writes:

> However, it happens that in Unix, Directories and Files are not only
> very distinct objects, but they are also understand by a wide range of
> applications simultaneously.  Ie, many applications look at a node in
> the filesystem, decide if it is a file _or_ a directory, and then take
> an appropriate action.  All applications that can traverse a filesystem
> belong into this group, for example ls, rm, grep, find, etc.  This is
> the most prominent group, but I would expect there to be isolated cases
> of other applications that do this (maybe Apache?  Input welcome here).

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.  ;-)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]