Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!ut-sally!pyramid!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c,net.unix Subject: Re: reading directory under SYSTEM V Message-ID: <6883@sun.uucp> Date: Thu, 4-Sep-86 12:17:57 EDT Article-I.D.: sun.6883 Posted: Thu Sep 4 12:17:57 1986 Date-Received: Fri, 5-Sep-86 03:19:38 EDT References: <5770001@acf2.UUCP> Followup-To: net.unix Organization: Sun Microsystems, Inc. Lines: 37 Xref: mnetor net.lang.c:5785 net.unix:5375 > Cound anybody suggest a method of reading directory information from a C > program under SYSTEM V UNIX? I need something equivalent to the opendir and > readdir functionality supplied under BSD. This is a UNIX question, not a C question (adding the phrase "from a C program" does not magically transform a question about UNIX into a question about C), so I'm moving discussion to "net.unix". The opendir/readdir/etc. code was originally written for the V7 file system, as used by 4.1BSD (for which it was originally written) and S5. The V7 file system version was posted to the net by Kirk McKusick a while ago (I mailed a copy to the person who asked the question originally). Unfortunately, the file that is included by most 4.2 programs that defines the data structures used by the directory library is , which is aready used to define the native directory structure on systems with the V7 file system. This means you can't conveniently drop the new "dir.h" include file into such a system and avoid the need for #ifdefs when building a program for systems with the V7 and with the 4.2BSD file system. The IEEE 1003.1 standard has a slightly modified version of the directory library routines. They include , which is not part of V7, 4BSD, S3, or S5 prior to S5R3, so it can be dropped into such a system (I hope nobody else has added a different include file with the same name). S5R3 provides a 1003.1-compatible version of the directory library. The only other difference between the two versions of the directory library is that the original one calls the directory entry structure "struct direct", which collides with the "struct direct" specifying the format of directories on disk, as specified in , while the new one calls it "struct dirent" to avoid this collision. Systems using the 4.2BSD file system need merely provide a that specifies a "struct dirent" identical to a "struct direct" in order to provide a 1003.1-compatible version of the directory library routines. -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com (or guy@sun.arpa)