>>-rddir--fd--variable--length---------------------------------><
Function
rddir invokes the readdir callable service to read multiple
name entries from a directory and format the
information in the readdir callable service format. To format this
type of information in a stem, see readdir. The number
of entries read is returned in RETVAL.
Parameters
- fd
- The file descriptor (a number) for the directory to be read.
- variable
- The name of the buffer into which the directory entries are
to be read.
- length
- The size of the buffer. After the read completes, the length
of variable is the size of the buffer. The number of entries
is returned in RETVAL.
Usage notes
- You can use this command only with file descriptors opened using
the opendir syscall command. The rddir syscall command reads
a directory in the readdir callable service format. You can use opendir, rewinddir, and closedir together with the rddir syscall command, but not with the readdir syscall command.
Alternatively, you can use the readdir syscall command to
read an entire directory and format it in a stem.
- The buffer contains a variable number of variable-length directory
entries. Only full entries are placed in the buffer, up to the buffer
size specified, and the number of entries is returned.
- Each directory entry returned has the following format:
- 2-byte Entry_length
- The total entry length, including itself.
- 2-byte Name_length
- Length of the following Member_name subfield.
- Member_name
- A character field of length Name_length. This name is not null-terminated.
- File system specific data
- If name_length + 4 = entry_length, this subfield is not present.
The entries are packed together, and the length fields are
not aligned on any particular boundary.
- The buffer returned by one call to the readdir service must be
used again on the next call to the readdir service to continue reading
entries from where you left off. The buffer must not be altered between
calls, unless the directory has been rewound.
- The end of the directory is indicated in either of two ways:
- A RETVAL of 0 entries is returned.
- Some physical file systems may return a null name entry as the
last entry in the caller's buffer. A null name entry has an Entry_length
of 4 and a Name_length of 0.
The caller of the readdir service should check for both conditions.
Example
To read the entries from the directory with file descriptor 4 into
the buffer named
buf, which is 300 bytes long:
"rddir 4 buf 300"