Date: Fri, 26 May 2000 19:49:21 +0100 From: "Marco van de Voort" <marcov@stack.nl> To: hackers@freebsd.org Subject: Re: getdirentries() and /proc Message-ID: <20000526174805.A065C2E803@hermes.tue.nl> In-Reply-To: <Pine.BSF.4.21.0005252046510.9634-100000@vger.bsdhome.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> > The man page for getdirentries() says: > > int > getdirentries(int fd, char *buf, int nbytes, long *basep) > > "The nbytes argument must be greater than or equal to the block > size associated with the file, see stat(2). Some filesys- > tems may not support these functions with buffers smaller than > this size." > > So ... what are we supposed to use for this? For special filesystems > like /proc, is any old value that is sufficiently large enough to hold > a few struct dirent's considered to be OK? Should I not use > 'getdirentries()', and opt instead for 'opendir()' and 'readdir()'? > > Any advice is appreciated. I also had this problem (when I created a readdir equivalent for a port of a non-libc using compiler). I checked libc, and libc always seems to use 1024 bytes (constant called DIRBLKSIZ) for nbytes. But I didn't try to search /proc yet. Also keep in mind that using getdirentries you could get duplicate entries (libc readdir sorts and removes duplicates first). I however don't know if this is just because of hardlinks (which most people don't use afaik) or also for regular filehandling. Marco van de Voort (MarcoV@Stack.nl or marco@freepascal.org) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000526174805.A065C2E803>