From owner-freebsd-hackers Fri May 26 10:48:28 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from kweetal.tue.nl (kweetal.tue.nl [131.155.2.7]) by hub.freebsd.org (Postfix) with ESMTP id BD20B37BFFA for ; Fri, 26 May 2000 10:48:11 -0700 (PDT) (envelope-from marcov@toad.stack.nl) Received: from hermes.tue.nl [131.155.2.46] by kweetal.tue.nl (8.9.3) for id TAA06467 (ESMTP); Fri, 26 May 2000 19:48:06 +0200 (MDT) Received: from deathstar (n49.dial.tue.nl [131.155.209.48]) by hermes.tue.nl (Postfix) with ESMTP id A065C2E803 for ; Fri, 26 May 2000 19:48:05 +0200 (CEST) From: "Marco van de Voort" To: hackers@freebsd.org Date: Fri, 26 May 2000 19:49:21 +0100 Subject: Re: getdirentries() and /proc In-reply-to: X-mailer: Pegasus Mail for Win32 (v3.12b) Message-Id: <20000526174805.A065C2E803@hermes.tue.nl> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > 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