Public Attributes | |
| uint32 | flags |
| uint32(* | get_supported_operations )(partition_data *partition, uint32 mask) |
Standard Operations | |
| status_t(* | access )(fs_volume fs, fs_vnode vnode, int mode) |
| Checks whether the current user is allowed to access the node in the specified way. | |
| status_t(* | create_symlink )(fs_volume fs, fs_vnode dir, const char *name, const char *path, int mode) |
| Create a new symbolic link. | |
| status_t(* | deselect )(fs_volume fs, fs_vnode vnode, fs_cookie cookie, uint8 event, selectsync *sync) |
| Deselects the specified vnode from a previous select() call. | |
| status_t(* | fsync )(fs_volume fs, fs_vnode vnode) |
| Synchronize the buffers with the on disk data. | |
| status_t(* | ioctl )(fs_volume fs, fs_vnode vnode, fs_cookie cookie, ulong op, void *buffer, size_t length) |
| Perform file system specific operations. | |
| status_t(* | link )(fs_volume fs, fs_vnode dir, const char *name, fs_vnode vnode) |
| Create a new hard link. | |
| status_t(* | read_stat )(fs_volume fs, fs_vnode vnode, struct stat *stat) |
| Retrieves the stat data for a given node. | |
| status_t(* | read_symlink )(fs_volume fs, fs_vnode link, char *buffer, size_t *_bufferSize) |
| Read the value of a symbolic link. | |
| status_t(* | rename )(fs_volume fs, fs_vnode fromDir, const char *fromName, fs_vnode toDir, const char *toName) |
| Rename and/or relocate a vnode. | |
| status_t(* | select )(fs_volume fs, fs_vnode vnode, fs_cookie cookie, uint8 event, uint32 ref, selectsync *sync) |
| Selects the specified vnode with the specified events. | |
| status_t(* | set_flags )(fs_volume fs, fs_vnode vnode, fs_cookie cookie, int flags) |
| Set the open mode flags for an opened file. | |
| status_t(* | unlink )(fs_volume fs, fs_vnode dir, const char *name) |
| Remove a node or directory. | |
| status_t(* | write_stat )(fs_volume fs, fs_vnode vnode, const struct stat *stat, uint32 statMask) |
| Update the stats for a vnode. | |
VM file access | |
| bool(* | can_page )(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
| Undocumented. TODO. | |
| status_t(* | read_pages )(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes, bool reenter) |
| Undocumented. TODO. | |
| status_t(* | write_pages )(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, const iovec *vecs, size_t count, size_t *_numBytes, bool reenter) |
| Undocumented. TODO. | |
File Operations | |
| status_t(* | close )(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
| Closes the given node cookie. | |
| status_t(* | create )(fs_volume fs, fs_vnode dir, const char *name, int openMode, int perms, fs_cookie *_cookie, ino_t *_newVnodeID) |
| Create a new file. | |
| status_t(* | free_cookie )(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
| Frees the given node cookie. | |
| status_t(* | open )(fs_volume fs, fs_vnode vnode, int openMode, fs_cookie *_cookie) |
| Opens the given node. | |
| status_t(* | read )(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, void *buffer, size_t *length) |
| Reads data from a file. | |
| status_t(* | write )(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, const void *buffer, size_t *length) |
| Write data to a file. | |
Attribute Operations | |
| status_t(* | close_attr )(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
| Close access to an attribute. | |
| status_t(* | create_attr )(fs_volume fs, fs_vnode vnode, const char *name, uint32 type, int openMode, fs_cookie *_cookie) |
| Create a new attribute. | |
| status_t(* | free_attr_cookie )(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
| Free the cookie of an attribute. | |
| status_t(* | open_attr )(fs_volume fs, fs_vnode vnode, const char *name, int openMode, fs_cookie *_cookie) |
| Open an existing attribute. | |
| status_t(* | read_attr )(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, void *buffer, size_t *length) |
| Read attribute data associated with cookie. | |
| status_t(* | read_attr_stat )(fs_volume fs, fs_vnode vnode, fs_cookie cookie, struct stat *stat) |
| Get the stats for an attribute. | |
| status_t(* | remove_attr )(fs_volume fs, fs_vnode vnode, const char *name) |
| Remove an attribute. | |
| status_t(* | rename_attr )(fs_volume fs, fs_vnode fromVnode, const char *fromName, fs_vnode toVnode, const char *toName) |
| Rename and/or relocate an attribute. | |
| status_t(* | write_attr )(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, const void *buffer, size_t *length) |
| Write attribute data associated with cookie. | |
| status_t(* | write_attr_stat )(fs_volume fs, fs_vnode vnode, fs_cookie cookie, const struct stat *stat, int statMask) |
| Update the stats of an attribute. | |
Attribute Directory Operations | |
| status_t(* | close_attr_dir )(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
| Close a 'directory' of attributes for a vnode. | |
| status_t(* | free_attr_dir_cookie )(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
| Free the cookie to an attribute 'directory'. | |
| status_t(* | open_attr_dir )(fs_volume fs, fs_vnode vnode, fs_cookie *_cookie) |
| Open a 'directory' of attributes for a vnode. | |
| status_t(* | read_attr_dir )(fs_volume fs, fs_vnode vnode, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num) |
| Read the next one or more attribute directory entries. | |
| status_t(* | rewind_attr_dir )(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
| Rewind the attribute directory iterator to the first entry. | |
Directory Operations | |
| status_t(* | close_dir )(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
| Closes the given directory cookie. | |
| status_t(* | create_dir )(fs_volume fs, fs_vnode parent, const char *name, int perms, ino_t *_newVnodeID) |
| Create a new directory. | |
| status_t(* | free_dir_cookie )(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
| Frees the given directory cookie. | |
| status_t(* | open_dir )(fs_volume fs, fs_vnode vnode, fs_cookie *_cookie) |
| Opens the given directory node. | |
| status_t(* | read_dir )(fs_volume fs, fs_vnode vnode, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num) |
| Reads the next one or more directory entries. | |
| status_t(* | remove_dir )(fs_volume fs, fs_vnode parent, const char *name) |
| Remove a directory. | |
| status_t(* | rewind_dir )(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
| Resets the directory cookie to the first entry of the directory. | |
Index Directory and Operation | |
| status_t(* | close_index_dir )(fs_volume fs, fs_cookie cookie) |
| Close a 'directory' of indeces. | |
| status_t(* | create_index )(fs_volume fs, const char *name, uint32 type, uint32 flags) |
| Create a new index. | |
| status_t(* | free_index_dir_cookie )(fs_volume fs, fs_cookie cookie) |
| Free the cookie to the index 'directory'. | |
| status_t(* | open_index_dir )(fs_volume fs, fs_cookie *cookie) |
| Open the list of an indeces as a directory. | |
| status_t(* | read_index_dir )(fs_volume fs, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num) |
| Read the next one or more index entries. | |
| status_t(* | read_index_stat )(fs_volume fs, const char *name, struct stat *stat) |
| Read the stat of the index with a name. | |
| status_t(* | remove_index )(fs_volume fs, const char *name) |
| Remove the index with name. | |
| status_t(* | rewind_index_dir )(fs_volume fs, fs_cookie cookie) |
| Reset the index directory cookie to the first entry of the directory. | |
Query Operations | |
| status_t(* | close_query )(fs_volume fs, fs_cookie cookie) |
| Close a 'directory' of a query. | |
| status_t(* | free_query_cookie )(fs_volume fs, fs_cookie cookie) |
| Free a cookie of a query. | |
| status_t(* | open_query )(fs_volume fs, const char *query, uint32 flags, port_id port, uint32 token, fs_cookie *_cookie) |
| Open a query as a 'directory'. | |
| status_t(* | read_query )(fs_volume fs, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num) |
| Read the next one or more entries matching the query. | |
| status_t(* | rewind_query )(fs_volume fs, fs_cookie cookie) |
| Reset the query cookie to the first entry of the results. | |
Special Operations | |
| status_t(* | defragment )(int fd, partition_id partition, disk_job_id job) |
| Undocumented. TODO. | |
| status_t(* | initialize )(int fd, partition_id partition, const char *name, const char *parameters, off_t partitionSize, disk_job_id job) |
| Undocumented. TODO. | |
| status_t(* | move )(int fd, partition_id partition, off_t offset, disk_job_id job) |
| Undocumented. TODO. | |
| status_t(* | repair )(int fd, partition_id partition, bool checkOnly, disk_job_id job) |
| Undocumented. TODO. | |
| status_t(* | resize )(int fd, partition_id partition, off_t size, disk_job_id job) |
| Undocumented. TODO. | |
| status_t(* | set_content_name )(int fd, partition_id partition, const char *name, disk_job_id job) |
| Undocumented. TODO. | |
| status_t(* | set_content_parameters )(int fd, partition_id partition, const char *parameters, disk_job_id job) |
| Undocumented. TODO. | |
Scanning | |
| void(* | free_identify_partition_cookie )(partition_data *partition, void *cookie) |
| Undocumented. TODO. | |
| void(* | free_partition_content_cookie )(partition_data *partition) |
| Undocumented. TODO. | |
| float(* | identify_partition )(int fd, partition_data *partition, void **cookie) |
| Undocumented. TODO. | |
| status_t(* | scan_partition )(int fd, partition_data *partition, void *cookie) |
| Undocumented. TODO. | |
Cache File Access | |
| status_t(* | get_file_map )(fs_volume fs, fs_vnode vnode, off_t offset, size_t size, struct file_io_vec *vecs, size_t *_count) |
| Fills the vecs with the extents of the file data stream. | |
VNode Operations | |
| status_t(* | get_vnode )(fs_volume fs, ino_t id, fs_vnode *_vnode, bool reenter) |
| Creates the private data handle to be associated with the node referred to by id. | |
| status_t(* | get_vnode_name )(fs_volume fs, fs_vnode vnode, char *buffer, size_t bufferSize) |
| Return the file name of a vnode. | |
| status_t(* | lookup )(fs_volume fs, fs_vnode dir, const char *name, ino_t *_id, int *_type) |
| Looks up the node a directory entry refers to. | |
| status_t(* | put_vnode )(fs_volume fs, fs_vnode vnode, bool reenter) |
| Deletes the private data handle associated with the specified node. | |
| status_t(* | remove_vnode )(fs_volume fs, fs_vnode vnode, bool reenter) |
| Deletes the private data handle associated with the specified node. | |
Data members | |
| module_info | info |
| Your module_info object which is required for all modules. | |
| const char * | pretty_name |
| A NULL-terminated string with a 'pretty' name for you file system. | |
General Operations | |
| status_t(* | mount )(dev_t id, const char *device, uint32 flags, const char *args, fs_volume *_fs, ino_t *_rootVnodeID) |
| Mount a volume according to the specified parameters. | |
| status_t(* | read_fs_info )(fs_volume fs, struct fs_info *info) |
| Retrieves general information about the volume. | |
| status_t(* | sync )(fs_volume fs) |
| Synchronize the cached data with the contents of the disk. | |
| status_t(* | unmount )(fs_volume fs) |
| Unmounts the given volume. | |
| status_t(* | write_fs_info )(fs_volume fs, const struct fs_info *info, uint32 mask) |
| Update filesystem information on the volume. | |
Shadow Partition Modification | |
| status_t(* | shadow_changed )(partition_data *partition, partition_data *child, uint32 operation) |
| Undocumented. TODO. | |
Capability Querying | |
| bool(* | validate_initialize )(partition_data *partition, char *name, const char *parameters) |
| Undocumented. TODO. | |
| bool(* | validate_move )(partition_data *partition, off_t *start) |
| Undocumented. TODO. | |
| bool(* | validate_resize )(partition_data *partition, off_t *size) |
| Undocumented. TODO. | |
| bool(* | validate_set_content_name )(partition_data *partition, char *name) |
| Undocumented. TODO. | |
| bool(* | validate_set_content_parameters )(partition_data *partition, const char *parameters) |
| Undocumented. TODO. | |
See the introduction to file system modules for an introduction to writing file systems.
| status_t(* file_system_module_info::access)(fs_volume fs, fs_vnode vnode, int mode) |
Checks whether the current user is allowed to access the node in the specified way.
mode is a bitwise combination of:
R_OK: Read access.W_OK: Write access.X_OK: Execution.
If the current user does not have any of the access permissions represented by the set bits, the function shall return B_NOT_ALLOWED. As a special case, if the volume is read-only and write access is requested, B_READ_ONLY_DEVICE shall be returned. If the requested access mode complies with the user's access permissions, the function shall return B_OK.
For most FSs the permissions a user has are defined by the st_mode, st_uid, and st_gid fields of the node's stat data. As a special exception, the root user (geteuid() == 0) does always have read and write permissions, execution permission only when at least one of the execution permission bits are set.
| fs | The volume handle. | |
| vnode | The node handle. | |
| mode | The access mode mask. |
| B_OK | The user has the permissions to access the node in the requested way. | |
| B_READ_ONLY_DEVICE | The volume is read-only, but the write access has been requested. | |
| B_NOT_ALLOWED | The user does not have all permissions to access the node in the requested way. |
| bool(* file_system_module_info::can_page)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
Undocumented. TODO.
TODO: In both the dos and the bfs implementations this thing simply returns false... Is there anything more to it? This call might be removed in the future - it's currently unused.
| status_t(* file_system_module_info::close)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
Closes the given node cookie.
The hook is invoked, when closing the node has been requested. At this point other threads might still use the cookie, i.e. still execute hooks to which the cookie has been passed. If the FS supports blocking I/O operations, this hook should make sure to unblock all currently blocking threads performing an operation using the cookie, and mark the cookie such that no further threads will block using it.
For many FSs this hook is a no-op - it's mandatory to be exported, though.
| fs | The volume handle. | |
| vnode | The node handle. | |
| cookie | The node cookie as returned by open(). |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::close_attr)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
Close access to an attribute.
Note that you should not delete the cookie yet, you should do that when the VFS calls free_attr_cookie().
| fs | The file system provided cookie to the volume. | |
| vnode | The file system provided cookie to the vnode. | |
| cookie | The cookie you associated to this attribute. |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::close_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
Close a 'directory' of attributes for a vnode.
Note that you should free the cookie in the free_attr_dir_cookie() call.
| fs | The file system provided cookie to the volume. | |
| vnode | The vnode on which the 'directory' was opened. | |
| cookie | The cookie associated with this 'directory'. |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::close_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
Closes the given directory cookie.
Generally the situation is similar to the one described for close(). In practice it is a bit, though, since directory cookies are exclusively used for directory iteration, and it normally doesn't make sense to have multiple threads read the same directory concurrently. Furthermore reading a directory should not block. Therefore for most FSs this hook is a no-op.
| fs | The volume handle. | |
| vnode | The node handle. | |
| cookie | The directory cookie as returned by open_dir(). |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::close_index_dir)(fs_volume fs, fs_cookie cookie) |
Close a 'directory' of indeces.
Note that you should free the cookie in the free_index_dir_cookie() call.:
| fs | The file system provided cookie to the volume. | |
| cookie | The cookie associated with this 'directory'. |
| status_t(* file_system_module_info::close_query)(fs_volume fs, fs_cookie cookie) |
Close a 'directory' of a query.
Note that you should free the cookie in the free_query_cookie() call.
| fs | The file system provided cookie to the volume. | |
| cookie | The cookie that refers to this query. |
B_OK if the creation succeeded, or return an error otherwise. | status_t(* file_system_module_info::create)(fs_volume fs, fs_vnode dir, const char *name, int openMode, int perms, fs_cookie *_cookie, ino_t *_newVnodeID) |
Create a new file.
Your implementation shall check whether it is possible to create the node. You will need to take the user's permissions into account. When you create a new file, you will also have to open it. This means also checking the permissions the user requires to open the file according to the mode. See open() for the possible values of mode.
| fs | The file system provided cookie associated with this volume. | |
| dir | The file system provided cookie associated with the directory where the file should appear. | |
| name | The name of the new file. | |
| openMode | The mode associated to the file. | |
| perms | The permissions the new file should have. | |
| [out] | _cookie | In case of success, the you can store your file system data for this node in this variable. |
| [out] | _newVnodeID | In case of success, you can store the new vnode id in this variable. |
B_OK if creating the new node succeeded, and if you put data in both _cookie and _newVnodeID. Else you should return an error code. | status_t(* file_system_module_info::create_attr)(fs_volume fs, fs_vnode vnode, const char *name, uint32 type, int openMode, fs_cookie *_cookie) |
Create a new attribute.
If the attribute already exists, you should open it in truncated mode.
| fs | The file system provided cookie to the volume. | |
| vnode | The file system provided cookie to the vnode. | |
| name | The name of the attribute. | |
| type | The type_code of the attribute. | |
| openMode | The openMode of the associated attribute. | |
| [out] | _cookie | A pointer where you can store an associated file system cookie. |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::create_dir)(fs_volume fs, fs_vnode parent, const char *name, int perms, ino_t *_newVnodeID) |
Create a new directory.
Your implementation should make sure that the directory actually can be created in the parent directory. You will have to check if the user has permissions to actually write to the parent. If not, this function should fail (probably with B_NOT_ALLOWED, or in case of a read-only filesystem, with B_READ_ONLY_DEVICE). If the operation succeeds, you should put the new vnode id in _newVnodeID.
| fs | The file system provided cookie associated with this volume. | |
| parent | The file system provided cookie associated with the parent node. | |
| name | The name the new directory should have. | |
| perms | The permissions the new directory should have. | |
| [out] | _newVnodeID | If creating the directory succeeds, than you should put the new vnode id in this variable. |
B_OK. Else you should return with an error code. | status_t(* file_system_module_info::create_index)(fs_volume fs, const char *name, uint32 type, uint32 flags) |
Create a new index.
| fs | The file system provided handle to the volume. | |
| name | The name of the new index. | |
| type | The type of index. BFS implements the following types:
| |
| flags | There are currently no extra flags specified. This parameter can be ignored. |
B_OK if the creation succeeded, or return an error otherwise. | status_t(* file_system_module_info::create_symlink)(fs_volume fs, fs_vnode dir, const char *name, const char *path, int mode) |
Create a new symbolic link.
Your implementation should check if the user has permission to perform this operation.
| fs | The file system provided cookie associated with this volume. | |
| dir | The file system provided cookie associated with the directory the symbolic link should be created in. | |
| name | The name of the new symbolic link. | |
| path | The path of the original inode the symbolic link should refer to. | |
| mode | The mode that this symbolic link should be created in. (TODO what exactly?) |
B_OK if you succeeded, or an error code if you failed. | status_t(* file_system_module_info::deselect)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, uint8 event, selectsync *sync) |
Deselects the specified vnode from a previous select() call.
This function is called by the VFS whenever a select() or poll() function exits that previously called file_system_module_info::select() on that vnode.
| status_t(* file_system_module_info::free_attr_cookie)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
Free the cookie of an attribute.
The VFS calls this hook when all operations on the attribute have ceased.
| fs | The file system provided cookie to the volume. | |
| vnode | The file system provided cookie to the vnode. | |
| cookie | The cookie to the attribute that should be freed. |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::free_attr_dir_cookie)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
Free the cookie to an attribute 'directory'.
| fs | The file system provided cookie to the volume. | |
| vnode | The vnode on which the 'directory' was opened. | |
| cookie | The cookie associated that should be freed. |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::free_cookie)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
Frees the given node cookie.
The hook is invoked after close(), when no other thread uses or is going to use the cookie. All resources associated with the cookie must be freed.
| fs | The volume handle. | |
| vnode | The node handle. | |
| cookie | The node cookie as returned by open(). |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::free_dir_cookie)(fs_volume fs, fs_vnode vnode, fs_cookie cookie) |
Frees the given directory cookie.
The hook is invoked after close_dir(), when no other thread uses or is going to use the cookie. All resources associated with the cookie must be freed.
| fs | The volume handle. | |
| vnode | The node handle. | |
| cookie | The directory cookie as returned by open_dir(). |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::free_index_dir_cookie)(fs_volume fs, fs_cookie cookie) |
Free the cookie to the index 'directory'.
| fs | The file system provided cookie for the volume. | |
| cookie | The cookie that should be freed. |
| status_t(* file_system_module_info::free_query_cookie)(fs_volume fs, fs_cookie cookie) |
Free a cookie of a query.
| fs | The file system provided cookie to the volume. | |
| cookie | The cookie that should be freed. |
B_OK if the creation succeeded, or return an error otherwise. | status_t(* file_system_module_info::fsync)(fs_volume fs, fs_vnode vnode) |
Synchronize the buffers with the on disk data.
| fs | The file system provided cookie associated with this volume. | |
| vnode | The file system provided cookie associated with the vnode. |
B_OK if the operation succeeded, or else an error code. | status_t(* file_system_module_info::get_file_map)(fs_volume fs, fs_vnode vnode, off_t offset, size_t size, struct file_io_vec *vecs, size_t *_count) |
Fills the vecs with the extents of the file data stream.
This function is called only when you are using the file cache, but if you use it, its implementation is mandatory.
TODO: complete me
| status_t(* file_system_module_info::get_vnode)(fs_volume fs, ino_t id, fs_vnode *_vnode, bool reenter) |
Creates the private data handle to be associated with the node referred to by id.
Invoked by the VFS when it creates the vnode for the respective node. When the VFS no longer needs the vnode in memory (for example when memory is becoming tight), it will your file_system_module_info::put_vnode(), or file_system_module_info::remove_vnode() in case the vnode has been marked removed.
| fs | The volume handle. | |
| id | The ID of the node. | |
| _vnode | Pointer to a pre-allocated variable the node handle shall be written to. | |
| reenter | true if the hook invocation has been caused by the FS itself, e.g. by invoking get_vnode(). |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::get_vnode_name)(fs_volume fs, fs_vnode vnode, char *buffer, size_t bufferSize) |
Return the file name of a vnode.
Note that you don't have to implement this call if it can't be easily done; it's completely optional. If you don't implement it, you'll have to export a NULL pointer for this function in the module definition. In this case, the VFS will find the name by iterating over its parent directory.
| fs | The file system provided cookie associated with this volume. | |
| vnode | The file system provided cookie associated with this vnode. | |
| buffer | The buffer that the name can be copied into. | |
| bufferSize | The size of the buffer. |
| B_OK | You successfully copied the file name into the buffer. | |
| other errors | There was some error looking up or copying the name. |
| status_t(* file_system_module_info::ioctl)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, ulong op, void *buffer, size_t length) |
Perform file system specific operations.
You can implement a customized API using this call. This can be extremely handy for debugging purposes. There are no obligatory operations for you to implement.
If you don't want to use this feature, you don't have to implement it.
| fs | The file system provided cookie associated with this volume. | |
| vnode | The file system provided cookie associated with the vnode (if applicable). | |
| cookie | The file system provided cookie associated with, for example, an open file (if applicable). | |
| op | The operation code. You will have to define them yourself. | |
| buffer | A buffer (if applicable). | |
| length | The size of the buffer. |
| status_t(* file_system_module_info::link)(fs_volume fs, fs_vnode dir, const char *name, fs_vnode vnode) |
Create a new hard link.
You should make sure the user has the proper permissions.
The virtual file system will request the creation of symbolic links with create_symlink().
If you don't implement this function, the VFS will return EROFS when a hard link is requested.
| fs | The file system provided cookie associated with this volume. | |
| dir | The cookie associated to the directory where the link should be saved. | |
| name | The name the link should have. | |
| vnode | The vnode the new link should resolve to. |
| B_OK | The hard link is properly created. | |
| B_NOT_ALLOWED | The user does not have the proper permissions. | |
| other errors | Another error occured. |
| status_t(* file_system_module_info::lookup)(fs_volume fs, fs_vnode dir, const char *name, ino_t *_id, int *_type) |
Looks up the node a directory entry refers to.
The VFS uses this hook to resolve path names to vnodes. It is used quite often and should be implemented efficiently.
If the parameter dir does not specify a directory, the function shall fail. It shall also fail, if it is a directory, but does not contain an entry with the given name name. Otherwise the function shall invoke get_vnode() for the node the entry refers to and pass back the ID and the type of the node in _id and _type respectively.
Note that a directory must contain the special entries "." and "..", referring to the same directory and the parent directory respectively. lookup() must resolve the nodes accordingly. ".." for the root directory of the volume shall be resolved to the root directory itself.
| fs | The volume handle. | |
| dir | The node handle of the directory. | |
| name | The name of the directory entry. | |
| _id | Pointer to a pre-allocated variable the ID of the found node shall be written to. | |
| _type | Pointer to a pre-allocated variable the type of the found node shall be written to. The type is encoded as in the st_mode field of a struct stat (bitwise anded with S_IFMT). |
| B_OK | Everything went fine. | |
| B_ENTRY_NOT_FOUND | The given directory does not contain an entry with the given name. |
| status_t(* file_system_module_info::mount)(ino_t id, const char *device, uint32 flags, const char *args, fs_volume *_fs, ino_t *_rootVnodeID) |
Mount a volume according to the specified parameters.
Invoked by the VFS when it has been requested to mount the volume. The FS is supposed to perform whatever one-time initialization is necessary for the volume. It is required to create a volume handle for the volume and pass it back in _fs. Moreover it must invoke publish_vnode() for the root node of the volume and pass the ID of the volume back in _rootVnodeID.
A disk-based FS will need to check whether device is not NULL, open it, and analyze whether the device or image file actually represents a volume of that FS type.
If mounting the volume fails for whatever reason, the hook must return an error code other than B_OK. In this case all resources allocated by the hook must be freed before returning. If and only if B_OK is returned, the unmount() hook will be invoked at a later point when unmounting the volume.
| id | The ID of the volume to be mounted. It should be saved in the FS's volume private data (volume handle). | |
| device | The path to the device (or image file) representing the volume to be mounted. Can be NULL. | |
| flags | Flags:
| |
| args | Null-terminated string in driver settings format, containing FS specific parameters. | |
| _fs | Pointer to a pre-allocated variable the volume handle shall be written to. | |
| _rootVnodeID | Pointer to a pre-allocated variable the ID of the volume's root directory shall be written to. |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::open)(fs_volume fs, fs_vnode vnode, int openMode, fs_cookie *_cookie) |
Opens the given node.
The function shall check whether it is possible to open the node according to the mode specified by openMode (also considering the user's access permissions), create a node cookie, and store it in the variable _cookie points to.
The open mode openMode is encoded in the same way as the parameter of the POSIX function open(), i.e. it is either O_RDONLY, O_WRONLY, or O_RDWR, bitwise or'ed with flags. The only relevant flags for this hook are O_TRUNC and O_NONBLOCK.
| fs | The volume handle. | |
| vnode | The node handle. | |
| openMode | The open mode. | |
| _cookie | Pointer to a pre-allocated variable the node cookie shall be written to. |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::open_attr)(fs_volume fs, fs_vnode vnode, const char *name, int openMode, fs_cookie *_cookie) |
Open an existing attribute.
| fs | The file system provided cookie to the volume. | |
| vnode | The file system provided cookie to the vnode. | |
| name | The name of the attribute. | |
| openMode | The mode in which you want to open the attribute data. | |
| [out] | _cookie | A pointer where you can store an associated file system cookie. |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::open_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie *_cookie) |
Open a 'directory' of attributes for a vnode.
See Generic Concepts on directories and iterators. Basically, the VFS uses the same way of traversing through attributes as it traverses through a directory.
| fs | The file system provided cookie to the volume. | |
| vnode | The vnode on which the file system wants to read the attributes. | |
| [out] | _cookie | Pointer where the file system can store a directory cookie if the attribute directory is succesfully opened. |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::open_dir)(fs_volume fs, fs_vnode vnode, fs_cookie *_cookie) |
Opens the given directory node.
If the specified node is not a directory, or if the current user does not have the permissions to read the directory, the function shall fail. Otherwise it shall allocate a directory cookie and store it in the variable _cookie points to. A subsequent read_dir() using the cookie shall start reading the first entry of the directory.
| fs | The volume handle. | |
| vnode | The node handle. | |
| _cookie | Pointer to a pre-allocated variable the directory cookie shall be written to. |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::open_index_dir)(fs_volume fs, fs_cookie *_cookie) |
Open the list of an indeces as a directory.
See Generic Concepts on directories and iterators. Basically, the VFS uses the same way of traversing through indeces as it traverses through a directory.
| fs | The file system provided cookie to the volume. | |
| [out] | _cookie | Pointer where the file system can store a directory cookie if the index directory is succesfully opened. |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::open_query)(fs_volume fs, const char *query, uint32 flags, port_id port, uint32 token, fs_cookie *_cookie) |
Open a query as a 'directory'.
TODO: query expressions should be documented and also the format for sending query updates over the port should be updated.
See Generic Concepts on directories and iterators. Basically, the VFS uses the same way of traversing through indeces as it traverses through a directory.
| fs | The file system provided cookie to the volume. | |
| query | The string that represents a query. | |
| flags | Either one of these flags:
| |
| port | The id of the port where updates need to be sent to in case the query is live. | |
| token | A token that should be attached to the messages sent over the port. | |
| [out] | _cookie | The cookie that will be used as 'directory' to traverse through the results of the query. |
B_OK if the creation succeeded, or return an error otherwise. | const char * file_system_module_info::pretty_name |
A NULL-terminated string with a 'pretty' name for you file system.
Note, if a system wide disk device type constant exists for your file system, it should equal this identifier.
| fn status_t(* file_system_module_info::put_vnode)(fs_volume fs, fs_vnode vnode, bool reenter) |
Deletes the private data handle associated with the specified node.
Invoked by the VFS when it deletes the vnode for the respective node and the node is not marked removed.
| fs | The volume handle. | |
| vnode | The node handle. | |
| reenter | true if the hook invocation has been caused by the FS itself, e.g. by invoking put_vnode(). |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::read)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, void *buffer, size_t *length) |
Reads data from a file.
This function should fail if
The number of bytes to be read is stored in the variable pointed to by length. If less data is available at file position pos, or if pos if greater than the size of the file, only as many data as available shall be read, the function shall store the number of bytes actually read into the variable pointed to by length, and return B_OK.
| fs | The volume handle. | |
| vnode | The node handle. | |
| cookie | The node cookie as returned by open(). | |
| pos | The file position where to start reading data. | |
| buffer | Pointer to a pre-allocated buffer the read data shall be written to. | |
| length | Pointer to a pre-allocated variable containing the size of the buffer when invoked, and into which the size of the data actually read shall be written. |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::read_attr)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, off_t pos, void *buffer, size_t *length) |
Read attribute data associated with cookie.
Read until the buffer with size length is full, or until you are out of data, in which case you should update length.
| fs | The file system provided cookie to the volume. | |
| vnode | The file system provided cookie to the vnode. | |
| cookie | The cookie you associated to this attribute. | |
| pos | The position to start reading from. | |
| buffer | The buffer the data should be copied in. | |
| length | The length of the buffer. Update this variable to the actual amount of bytes read. |
B_OK if everything went fine, another error code otherwise. | status_t(* file_system_module_info::read_attr_dir)(fs_volume fs, fs_vnode vnode, fs_cookie cookie, struct dirent *buffer, size_t bufferSize, uint32 *_num) |
Read the next one or more attribute directory entries.
This method should perform the same tasks as read_dir(), except that the '.' and '..' entries do not have to be present.
| status_t(* |