[syslinux] [RFC] COMBOOT: readdir: st_mode or d_type

Jeffrey Hutzelman jhutz at cmu.edu
Tue Mar 3 11:50:52 PST 2009


--On Tuesday, March 03, 2009 02:05:45 PM -0500 Gene Cumm 
<gene.cumm at gmail.com> wrote:

> Based upon this, it's debatable which way is better:
> 1) provide everything from readdir, providing better performance for
> FAT or ISO9660 in the case of a cache miss.
> 2) provide only the name but then also provide a stat() function, either
> by a) using open(), fstat(), close(), opendir() and closedir(), (simple
> implementation, costly execution) or
> b) providing a stat capability in the COMBOOT API;
> Either way, giving only names and a stat()/fstat() function only
> provides an advantage to EXT2 when only the names are requested (ls by
> itself, not long, not classified, etc).

It seems likely that the best thing is to do something like what the UNIX 
readdir() does; specifically, always return the name, and also return some 
other information if it is available cheaply.  Traditionally UNIX only 
handles the type this way, because it's the only thing that's ever 
available cheaply in UNIX filesystems, but there's no reason we can't 
return other information, given that it is likely to be easily available in 
FAT and 9660.

> As you've said, some file systems do store a basic type
> in the dirent but it looks like EXT2 is not one of them.

EXT2 _is_ one of them, if EXT2_FEATURE_INCOMPAT_FILETYPE is set.  I don't 
know offhand how old this feature is, but I'm going to guess that it's 
pretty old at this point and present in most filesystems.

> At the moment, the COM32 C struct dirent can hold all of this
> information, far more than most UNIX systems.  Thinking about what
> you've said, it may be beneficial to either remove those members or
> insert a flag stating if they're valid.  Doing so would mean that for
> FAT and ISO9660, the data could be in a dirent but EXT2 might require
> a stat()/fstat() call.

Yes, I think that's a good idea.  Note that d_type encodes this information 
through the use of a special value, DT_UNKNOWN, when the information is not 
available.

-- Jeff




More information about the Syslinux mailing list