Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!linus!decvax!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.unix-wizards Subject: Re: help with dir. structure sysV vs. 4.2BSD Message-ID: <2657@sun.uucp> Date: Sat, 17-Aug-85 05:48:09 EDT Article-I.D.: sun.2657 Posted: Sat Aug 17 05:48:09 1985 Date-Received: Mon, 19-Aug-85 22:02:54 EDT References: <1290@cwruecmp.UUCP> Organization: Sun Microsystems, Inc. Lines: 34 > In K&P's book "The Unix Programming Enviroment" > a spelling correction algorithym is presented to > use with such things as paginators. (see spname > in the index.) It is written for sysV/4.1 directory > structures. I am having trouble converting it to 4.2 > > It uses a low level read (shown below; it is in > mindist() ) to look at the directory. I believe this > is the line which gives me trouble. Using low level reads to look at the directory is the wrong thing to do on any 4.2BSD system; it's also not the best thing to do on the V7 file system, either. If you use the "directory library", either in its V7 file system form or its 4.2 file system form, you can move your code between systems using the two different file systems without change. See DIRECTORY(3) for a writeup on this library. The library was originally written for 4.1aBSD, which used the V7 file system, and programs were converted to use it; later, a 4.2BSD version was written. The V7 file system version was posted to net.sources by Kirk McKusick a long time ago, and is available in the distributions of several bits of software like "sendmail" and the RTI/4.2BSD UUCP. Another V7 file system version was posted by Doug Gwyn more recently. Everybody out there offering a UNIX with a V7 file system (this means you, AT&T) should provide the directory library with their system, and rewrite their programs to use it. It's easy, it's fun, and it fixes at least two known bugs in S5 utilities, since "readdir" always null-terminates the file name, while the filename isn't necessarily terminated in the raw directory structure (this causes "ls -C" to screw up its pagination if it encounters a 14-character file name, and I believe it also screwed up "make" or the shell). Guy Harris