tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Max. number of subdirectories dump



On 2013-08-18 17:50, Johnny Billquist wrote:
On 2013-08-18 17:38, Joerg Sonnenberger wrote:
On Sun, Aug 18, 2013 at 05:36:47PM +0200, Johnny Billquist wrote:
There is nothing in the directory entry that even tells if the entry
is a directory or just a plain file, unless I remember wrong. And
they are not sorted so that all directories comes first...

There is a type tag for each directory entry.

That's what I get for just trying to remember instead of actually
checking. :-)

By the way. Sorry for spinning a little offtopic right now.
Looking at 2.11BSD, it looks like this:

struct  direct {
        ino_t   d_ino;                  /* inode number of entry */
        u_short d_reclen;               /* length of this record */
        u_short d_namlen;               /* length of string in d_name */
char d_name[MAXNAMLEN+1]; /* name must be no longer than this */
};

(MAXNAMLEN is 63 for 2.11BSD, by the way...)

In NetBSD (fairly current):

struct dirent {
        ino_t d_fileno;                 /* file number of entry */
        uint16_t d_reclen;              /* length of this record */
        uint16_t d_namlen;              /* length of string in d_name */
        uint8_t  d_type;                /* file type, see below */
#if defined(_NETBSD_SOURCE)
#define MAXNAMLEN 511 /* must be kept in sync with NAME_MAX */ char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
#else
char d_name[511 + 1]; /* name must be no longer than this */
#endif
};


So obviously I'm only (as always) just a few years behind... :-D

It's an obvious optimization to keep type already in the directory itself. But is there any other reason why it was added there? It obviously means you have the same information in two places, with all the obvious risks of having the data out of sync, and potential mess from that... (I'm assuming the information is still in the inode anyway, since it could be interesting with hard links otherwise. By the way, this would assume that hard links must check what kind of thing you are adding a link to, so that your new directory entry gets the right type?)

        Johnny

--
Johnny Billquist                  || "I'm on a bus
                                  ||  on a psychedelic trip
email: bqt%softjar.se@localhost             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol


Home | Main Index | Thread Index | Old Index