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().
errno.dev_t dev_for_path(const char *path)
B_ENTRY_NOT_FOUND.,path does not exist, or is NULL or an empty string.B_BAD_VALUE. path is null or an empty string.B_NAME_TOO_LONG. path is too long.B_NO_MEMORY. Insufficient memory to complete the operation.B_FILE_ERROR. A file system error prevented the operation from succeeding.dev_t next_dev(int32 *pos)
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.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); } }
B_BAD_VALUE. No matching device found.int fs_stat_dev(dev_t dev, fs_info *info)
struct {} fs_info
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.errno() function to determine what error in particular occurred.fs_info structure is defined as:typedef struct fs_info { dev_t dev; ino_t root; uint32 flags; off_t block_size; off_t io_size; off_t total_blocks; off_t free_blocks; off_t total_nodes; off_t free_nodes; char device_name[128]; char volume_name[B_FILE_NAME_LENGTH]; char fsh_name[B_OS_NAME_LENGTH]; };
dev. The device number of the device.root. The inode of the root of the device.flags. Flags describing the device's capabilities.block_size. The fundamental block size of the device.io_size. Optimal I/O size of the device.total_blocks. The total number of blocks on the device.free_blocks. The number of free (unused) blocks on the device.total_nodes. The total number of nodes on the device.free_nodes. The number of free (unused) nodes on the device.device_name. Name of the device holding the file system.volume_name. Name of the volume contained by the device.fsh_name. Name of the file system handler for the device.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.B_OK. The device was found; info contains valid information.B_BAD_VALUE. dev doesn't identify an existing device.