Path: utzoo!attcan!uunet!mcvax!ukc!reading!minster!forsyth From: forsyth@minster.york.ac.uk Newsgroups: comp.unix.wizards Subject: Re: Reading directories (was: Re: directory copying with cp; broken?) Message-ID: <593373118.8142@minster.york.ac.uk> Date: 20 Oct 88 17:51:58 GMT Organization: Department of Computer Science, University of York, England Lines: 19 There is no trouble with using read() to replace getdirentries (or whatever). Inodes (or vnodes in some cults) have a type. The kernel obviously knows when you are reading a directory, and can put whatever information it likes into your buffer. For instance, it could format the information in the same way as getdirentries does now, if that were a sensible format. Each file system type's read implementation would map its file system dependent structure into the portable one. In fact, the Newcastle Connection read() has been doing something similar for years! I once considered changing directory read() to return just the list of file names, separated by newlines. Then a simple ls X == cat X | sort. The representation is convenient for programs, portable, and completely hides file system dependent information. (Think carefully about pwd before rushing off to try this, though.) Any good scheme should not have odd restrictions: ``nbytes must be greater than or equal to the block size associated with the file...sizes less than this may cause errors on certain filesystems'' [getdirentries(2)].