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

Gene Cumm gene.cumm at gmail.com
Sun Mar 1 14:31:23 PST 2009


On Sun, Mar 1, 2009 at 9:02 AM, Jeffrey Hutzelman <jhutz at cmu.edu> wrote:
> --On Saturday, February 28, 2009 07:08:38 PM -0500 Gene Cumm
> <gene.cumm at gmail.com> wrote:
>
>> I'm looking for comments on what to return from readdir in DL or DX.
>> Currently, the data in DL is misaligned (patch coming soon, along with
>> at least two more) but it also got me thinking about the fact that
>> some filesystems, I believe, actually store st_mode directly in the
>> filesystem.  I'm thinking that using DX to return st_mode may prove
>> more useful in the long run than just returning d_type.
>>
>> Looking at com32/lib/sys/fstat.c, a regular file has an access mode of
>> 0444 (Read for all).  I would think that that should probably be the
>> return value for any filesystem that does not implement Unix-style
>> access modes.  Additionally, the access mode of a file from a
>> filesystem implementing ACMs should be examined also.  Ideas include
>> OR with 0444, replace with 0444, AND with 0444 or just as is.
>
> Since you don't have anything resembling UNIX users, there's no use for
> UNIX access modes and really very little point in emulating them, other
> than for informational purposes.  So...

It's either emulate them at the COMBOOT level or the COM32 level.  The
COM32 APIs I've built have been aimed at a Unix-like environment in
that the APIs are compatible.  Not multi-user, of course.  I'd either
have to stick with a Unix-compatible format at the COMBOOT level or
make my own for all file systems at the COMBOOT level.

The other part of the reasoning was that implementing it for EXTLINUX
would be essentially no code (copy data to register and done).

Hmm... new thought: Unix-style in DX and either native or custom format in HDX.

> If the filesystem stores a UNIX mode, it should be reported as-is.
> Otherwise, report everything as either 777 or 555, depending on whether the
> file is writable or not (that is, for filesystems like FAT that have a
> "readonly" bit, report that by turning off the 222 bits.

Except for the fact that fstat() already uses 0444.  That would sort
of break the pattern if 0111 was added.

> There's no point in trying to understand more complex access lists; the
> result won't be very informative, and it'll never be used for actual access
> control, so IMHO there's not much point in faking it.

True, it would result in (almost) a wasted 8 bits of data returned (9-1).

> I would also note that returning the UNIX mode from readdir is not nearly
> as useful as returning filetype information.  So if you have to choose,
> return the filetype.

Which filetype are you suggesting?  Unix struct dirent d_type, raw FAT
filetype (only useful for FAT, not ISO-9660 or EXT2/3) or a custom
format?  It needs to be usable for FAT, ISO-9660, EXT2/3 and any other
fielsystem that the Syslinux project may support in the future.

-Gene




More information about the Syslinux mailing list