next up previous contents index
Next: 9.5.9 mknod: Create a Up: 9.5 oskit_dir: Directory Interface Previous: 9.5.7 rmdir: Remove a

9.5.8 getdirentries: Read one or more entries from this directory

 

SYNOPSIS

#include <oskit/fs/dir.h> #include <oskit/fs/dirents.h>

oskit_error_t oskit_dir_getdirentries(oskit_dir_t *d, oskit_u32_t *inout_ofs, oskit_u32_t nentries, [out] oskit_dirents_t **out_dirents);

DIRECTION

client OS tex2html_wrap_inline37485 filesystem library

DESCRIPTION

This method reads one or more entries from this directory. On entry, inout_ofs contains the offset of the first entry to be read. Before returning, this method updates the value at inout_ofs to contain the offset of the next entry after the last entry returned in out_dirents. The returned value of inout_ofs is opaque; it should only be used in subsequent calls to this method.

This method will return at least nentries entries if there are at least that many entries remaining in the directory; however, this method may return more entries.

The return value out_dirents will contain a pointer to an oskit_dirents_t COM object, which holds the individual directory entries. The number of actual entries returned can be determined with the oskit_dirents_getcount method. Each successive directory entry is accessed using the oskit_dirents_getnext method. Once all the entries have been read, the dirents COM object should be released with the oskit_dirents_release method.

The data structure to retrieve the individual entries is:

struct oskit_dirent  {

		oskit_size_t namelen;		/* name length */
		oskit_ino_t ino;		/* entry inode */
		char name[0];			/* entry name */
	 
};

The namelen field should be initialized to the amount of storage available for the name. Upon return from the getnext method, namelen will be set to the actual length of the name. The pointer that is passed should obviously be large enough to hold the size of the structure above, plus the additional size of the character array.

PARAMETERS

d
The directory to read.
inout_ofs
On entry, the offset of the first entry to read. On exit, the offset of the next entry to read.
nentries
The minimum desired number of entries.
out_dirents
The directory entries oskit_dirents_t COM object.

RETURNS

Returns 0 on success, or an error code specified in <oskit/error.h>, on error.


next up previous contents index
Next: 9.5.9 mknod: Create a Up: 9.5 oskit_dir: Directory Interface Previous: 9.5.7 rmdir: Remove a

Utah Flux Research Group