1 1 . 1
T H E P O S I X A P I A N D C E X T E N S I O N S
187
The API follows closely what we've described in the lower levels. Each at-
tribute has a name, a type, and data associated with the name. The file system
can use the type code to determine if it is possible to index the attribute. The
fs write attr()
creates the named attribute if it does not exist. These two
functions round out the interface to attributes from the POSIX-style API.
Index Functions
The interface to the indexing features is only provided by a simple C language
interface. There is no corresponding C++ API to the indexing routines. This
is not a reflection on our language preference but rather is a realization that
little would have been gained by writing a C++ wrapper for these routines.
The indexing API provides routines to iterate over the list of indices on a
volume, and to create and delete indices. The routines to iterate over the list
of indices on a volume are
DIR
*fs_open_index_dir(dev_t dev);
struct dirent *fs_read_index_dir(DIR *dirp);
int
fs_rewind_index_dir(DIR *dirp);
int
fs_close_index_dir(DIR *dirp);
Again, the API is quite similar to the POSIX directory functions. The
fs
open index dir()
accepts a
dev t
argument, which is how the vnode layer
knows which volume to operate on. The entries returned from
fs read
index dir()
provide the name of each index. To obtain more information
about the index, the call is
int fs_stat_index(dev_t dev, char *name, struct index_info *info);
The
fs stat index()
call returns a stat-like structure about the named index.
The type, size, modification time, creation time, and ownership of the index
are all part of the
index info
structure.
Creating an index is done with
int fs_create_index(dev_t dev, char *name, int type, uint flags);
This function creates the named index on the volume specified. The
flags
argument is unused at this time but may specify additional options in the
future. The index has the data
type
indicated by the
type
argument. The
supported types are
integer (signed/unsigned, 32-/64-bit)
float
double
string
Practical File System Design:The Be File System
, Dominic Giampaolo
page 187