Path: utzoo!attcan!uunet!ncrlnk!ncrcae!hubcap!gatech!uflorida!mailrus!iuvax!pur-ee!ea.ecn.purdue.edu!housel From: housel@en.ecn.purdue.edu (Peter S. Housel) Newsgroups: comp.os.minix Subject: Re: directory(3) Message-ID: <7488@ea.ecn.purdue.edu> Date: 16 Dec 88 18:38:01 GMT References: <575@uvicctr.UUCP> Sender: housel@ea.ecn.purdue.edu Reply-To: housel@en.ecn.purdue.edu (Peter S. Housel) Organization: Purdue University Engineering Computer Network Lines: 20 In-reply-to: tholm@uvicctr.UUCP (Terrence W. Holm) There is a problem with these routines as distributed here. readdir() will always fail in a large directory (approx. 1K or larger). The reason is that getdents() can't be allowed to overflow the per-DIR buffer (which is of size DIRBUF) by reading one directory block of size DIRBLKSIZ. By default, DIRBLKSIZ is 4096, so it is possible to read in more directory data in one read() than can be converted in one step. getdents() cannot return having only converted part of a directory block. (The comment in dirent.h says that DIRBUF should be larger than the "filesystem buffer size," but it doesn't explain why.) Probably the best solution is to compile getdents.c with a "-DDIRBLKSIZ=512" compiler flag. This also has the effect of reducing the memory requirements of programs that call these routines. By the way, when and where was this latest version posted? I must have missed it... -Peter S. Housel- housel@en.ecn.purdue.edu ...!pur-ee!housel