[comp.unix.wizards] C on Directory

vm.cuny.edu>@adm.BRL.MIL (10/21/89)

From _Advanced_Unix_Programing_ by Marc Rochkind:

A directory has the following structure:

struct direct {
    ino_t  d_ino;
    char   d_name[DIRSIZE + 1]
} dlink;

ino_t and DIRSIZE are declared in "<sys/dir.h>"

Open/Read/Close Dir could be implemented as macros to open a file, read it with
this structure, and close it.

Patrick Spinler
pspinler%mkvax1@msus1.bitnet

guy@auspex.auspex.com (Guy Harris) (10/24/89)

>Open/Read/Close Dir could be implemented as macros to open a file, read it with
>this structure, and close it.

They already have been, but as subroutines, not macros.  Volume 9 of the
"comp.sources.unix" archive has "gwyn-dir-lib", which is an
implementation of the standard POSIX directory-access routines (which
are almost the same as the BSD ones, modulo some name-space cleanups -
"struct direct" became "struct dirent" to avoid collisions with any
"struct direct" that describes the on-disk format of directories, and
<sys/dir.h> became <dirent.h>).

gwyn@smoke.BRL.MIL (Doug Gwyn) (10/25/89)

In article <2557@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes:
>>Open/Read/Close Dir could be implemented as macros to open a file, read it with
>>this structure, and close it.
>They already have been, but as subroutines, not macros.  Volume 9 of the
>"comp.sources.unix" archive has "gwyn-dir-lib", which is an
>implementation of the standard POSIX directory-access routines ...

Thanks, but anybody who wants this package should get it from me,
not the archive, because the archive version has a couple of bugs.
(14-character file names on original UNIX filesystems are handled
wrong, also closedir() may be using storage that was free()d).

davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) (10/26/89)

In article <11410@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn) writes:

|  Thanks, but anybody who wants this package should get it from me,
|  not the archive, because the archive version has a couple of bugs.
|  (14-character file names on original UNIX filesystems are handled
|  wrong, also closedir() may be using storage that was free()d).

  How about a repost? This is one of the standard utilities and should
be valid in the archive. I suspect that enough people will ask for a
copy to make this necessary, anyway.
-- 
bill davidsen	(davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon