Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!batcomputer!itsgw!steinmetz!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.unix.wizards Subject: Re: Reading directories Keywords: heterogeneity, NFS Message-ID: <296@auspex.UUCP> Date: 24 Oct 88 17:14:35 GMT References: <30506@bbn.COM> <884@yabbie.rmit.oz> <331@talos.UUCP> Reply-To: guy@auspex.UUCP (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 27 >It is clear why directories should not be arbitrarily writable but I >don't see any such reason why they shouldn't be readable. The portable >directory reading routines could use the existing read(2) system call, >instead of adding (yet another) system call just to read directories. It would probably have been possible, in principle, to have "read()" on a directory not give you the raw data in the directory file, but give you the directory entries in a "standard" format; over NFS, it would do a NFS "readdir" call rather than a "read" call. However, that wasn't what was done; I don't know the reason why not, but one possibility I can think of is that they wanted SunOS 1.x binaries to still be able to read directories on local files (so that your 1.x binaries weren't immediately obsolete, and you or the vendor would have time to recompile. Thus, instead of modifying "read()" in that fashion, they added "getdirentries". You can probably make philosophical arguments either way, but they're irrelevant because 1) either way works well enough, and neither one works significantly better (as several people have pointed out, old programs that "knew" what directory entries looked like would break if they thought they looked like V7-style directories, so keeping "read()" wouldn't have let them continue to work) and 2) Sun already introduced "getdirentries", and AT&T added "getdents" in S5R3 (which Sun picked up in SunOS 4.0), so the choice has already been made. Adding "yet another" system call is hardly *ipso facto* a bad thing.