| The Storage Kit Table of Contents | The Storage Kit Index |
Declared in: be/kernel/fs_info.h
Library: libroot.so
From time to time, it can be useful to know certain information about the capabilities of the file system on a device. While the BVolume class provides you easy access to this information, it can occasionally be helpful to have more direct access to this information.
This section describes three C functions which can be used to obtain information about the file system on a device. One of these functions, fs_stat_dev(), returns this information given a device number. The other two functions, dev_for_path() and next_dev(), provide two ways to obtain a device number for use with fs_stat_dev().
Note that these functions don't set errno.
|
Given a pathname, returns the device number of the device on which the path is located. If the result is negative, it is a return code specifying an error.
RETURN CODES
|
The next_dev() function allows you to iterate through all devices, receiving their device numbers as a result each time. If the result is negative, it is an error code. When the end of the device list is reached, the return value B_BAD_VALUE is returned.
You should initially set pos to 0, then call next_dev() in a loop to obtain each device number until an error occurs. For example:
void ScanDevices(void) {
int pos;
pos = 0;
while(next_dev(&pos) >=0) {
do_something(pos);
}
}
RETURN CODES
|
fs_stat_dev() returns information about the specified device. This can be used in conjunction with next_dev() to scan all devices and record information your application requires.
This function returns 0 if the request was successful or -1 if an error occurred. Use the errno() function to determine what error in particular occurred.
The fs_info structure is defined as:
|
The structure's fields are:
The flags can be any combination of the following values, which specify the attributes of the file system on the device:
The information in the fs_info structure is guaranteed to be internally consistent, but the structure as a whole should be considered to be out-of-date as soon as you receive it. It provides a picture of a device as it exists just before the info-retrieving function returns. In particular, the number of free blocks and of free nodes can easily change immediately after you receive this information.
RETURN CODES
| The Storage Kit Table of Contents | The Storage Kit Index |
Copyright © 2000 Be, Inc. All rights reserved..