Currently, I'm looking at implementing 3 COMBOOT API calls for
directories, opendir, readdir, and closedir. In order to track
progress within the directory, I'll need to keep track of the current
sector number that is being read and the offset within the sector for
the next file entry to read. I'm contemplating if I should also keep
track of the starting sector of the directory (in case we need to
rewinddir()).
At the moment, I'm first looking at SYSLINUX (the other disk
derivatives are next). It has a struc open_file_t and an array
containing these strucs Files. Should I create a new struc,
open_dir_t to house the needed data elements, or reuse the existing
struc? If I should reuse open_file_t, how should I and should I
allocate a new array Dirs or reuse Files? If I don't reuse
open_file_t, Dirs will be a necessity.
My first thoughts are that if I reuse open_file_t, that file_sector
holds the current sector number, file_left holds the starting sector
number and file_bytesleft holds the sector offset. I just noticed the
struc dir_t in ISOLINUX but I don't think that it would be appropriate
for storing the open directories.
If I create open_dir_t, this is what I think first:
;
; Directory structure. This holds the information for each currently
open directory.
;
struc open_dir_t
dir_sector resd 1 ; Current sector number (0 = structure free)
dir_offset resd 1 ; Current position within dir_sector
dir_sector_start resd 1 ; Starting sector number (for rewinddir()
resd 1 ; Unused; for alignment/future use
endstruc
If I create a new array Dirs, I would think that it should be sized by
another constant MAX_OPEN_DIR, defined by MAX_OPEN_DIR_LG2, which
should be less than MAX_OPEN_LG2. I'm thinking around 4 (=16
directories; =256 Bytes) for now.
I have a feeling that what I'm embarking on may cause issues with
non-ASCII character sets (on the console or in the filesystem) down
the road, especially when the two are different, but I'm looking at
that as something to examine later.
--
"No one ever says, 'I can't read that ASCII E-mail you sent
me.'"