[talk] Why do directories not contain data?

Eitan Adler lists at eitanadler.com
Mon Jun 27 04:43:14 EDT 2016


On 26 June 2016 at 21:50, Thomas Levine <_ at thomaslevine.com> wrote:

> The directory of course contains references to its children, but that's
> not the information I'm thinking about accessing; I naively think that a
> directory should be able to contain both a list of children (that I can
> display with ls) and an arbitrary blob of unrelated data (that I can
> display with cat); why I have never seen a system that works like this?
>


In early unicies (UNIX Version 7 for example) there was only a single file
system with a fairly simple struct interface. As such, read() and write()
worked exactly as they do on regular files. There was no readdir(),
opendir() specific system calls.
Some unicies have retained bits of this, for example the ability to read()
a directory. It would be directly against the history for these unicies to
work as you describe. For systems that started more recently, I suspect
they did not want to invent new semantics where they could be easily
confused.

There are some elements of what you describe as 'extended attributes'
(typically stored in the directory inode) or 'resource forks' (typically
stored as additional, alternate data blocks).

-- 
Eitan Adler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nycbug.org/pipermail/talk/attachments/20160627/77bf48bc/attachment.html>


More information about the talk mailing list