Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.os.misc Subject: Re: What constitutes a good OS? Message-ID: <5361@auspex.auspex.com> Date: 18 Jan 91 18:26:56 GMT References: <41907@nigel.ee.udel.edu> <1991Jan17.004509.5435@kithrup.COM> <41998@nigel.ee.udel.edu> Organization: Auspex Systems, Santa Clara Lines: 48 >They were plain text files in the sense that you used the same open(),read() >and close() system calls to get a list of file names as you did to get >info out of a plain text file. Err, umm, no, you didn't - at least not in V6 and later (the claim was made in an earlier posting that "early in the evolution of UNIX", directories were plain-text files, so maybe it was true then). The way you get info out of a plain text file is that you open the file and read text from it. The way you get a list of file names out of a V7-style directory is that you open the file and read *directory entries* from it, extracting the names from the directory entries. There was never any guarantee that you could, for example, see if there's a file named "foobar" in the directory "bletch" by doing "grep foobar bletch". It might work if you were lucky, or it might not. >Now, instead, one uses readdir, opendir, etc. The reason one uses "readdir()", "opendir()", etc. is that having the format of directories known by programs that read directories meant that those programs had to be rewhacked when Berkeley changed the directory format. They actually introduced those routines *before* they changed the directory format; they wrote a version of those routines, which was implemented using "open()", "read()", and "close()", that ran on 4.1BSD-flavored systems that still had a V7-flavored file system with V7-style directories. They then implemented a version, which was *also* implemented using "open()", "read()", and "close()", to read BSD-style directories. Later, Sun added the "getdirentries()" call, which asks the particular file system type to return directory entries in a file-system-independent format (yes, it happened to look like the format of 4.2BSD directory entries - but not all the file systems atop which it was implemented used that format internally, e.g. the MS-DOS file system). This was done to let a program read directories on any mountable file system type, as SunOS in 2.0 added the VFS mechanism to let you have multiple file system types (the original ones Sun did were the BSD file system/UFS, NFS, and the MS-DOS file system; the latter was only a consulting special until SunOS 4.1.1). "readdir()" used that call (and later "getdents()"); "opendir()" still uses "open()". So, unless you have a fairly odd notion of what "plain text file" means, directories weren't plain text files in V6/V7/4.1BSD.