Google Custom Search

fs_interface.h File Reference

Provides an interface for file system modules. More...


Classes

struct  file_io_vec
 Structure that describes the io vector of a file. More...
struct  file_system_module_info
 Kernel module interface for file systems. More...

Defines

#define B_CURRENT_FS_API_VERSION   "/v1"
 Constant that defines the version of the file system API that your filesystem conforms to.
#define FS_WRITE_FSINFO_NAME   0x0001
 Passed to file_system_module_info::write_fs_info().

Typedefs

typedef void * fs_cookie
typedef void * fs_vnode
typedef void * fs_volume

Enumerations

enum  write_stat_mask {
  FS_WRITE_STAT_MODE = 0x0001,
  FS_WRITE_STAT_UID = 0x0002,
  FS_WRITE_STAT_GID = 0x0004,
  FS_WRITE_STAT_SIZE = 0x0008,
  FS_WRITE_STAT_ATIME = 0x0010,
  FS_WRITE_STAT_MTIME = 0x0020,
  FS_WRITE_STAT_CRTIME = 0x0040
}
 This mask is used in file_system_module_info::write_stat() to determine which values need to be written. More...

Functions

status_t get_vnode (dev_t mountID, ino_t vnodeID, fs_vnode *_privateNode)
 Retrieves the private data handle for the node with the given ID.
status_t get_vnode_removed (dev_t mountID, ino_t vnodeID, bool *removed)
 Returns whether the specified vnode is marked removed.
status_t new_vnode (dev_t mountID, ino_t vnodeID, fs_vnode privateNode)
 Create the vnode with ID vnodeID and associates it with the private data handle privateNode, but leaves is in an unpublished state.
status_t notify_listener (int op, dev_t device, ino_t parentNode, ino_t toParentNode, ino_t node, const char *name)
status_t publish_vnode (dev_t mountID, ino_t vnodeID, fs_vnode privateNode)
 Creates the vnode with ID vnodeID and associates it with the private data handle privateNode or just marks it published.
status_t put_vnode (dev_t mountID, ino_t vnodeID)
 Surrenders a reference to the specified vnode.
status_t read_file_io_vec_pages (int fd, const struct file_io_vec *fileVecs, size_t fileVecCount, const struct iovec *vecs, size_t vecCount, uint32 *_vecIndex, size_t *_vecOffset, size_t *_bytes)
status_t read_pages (int fd, off_t pos, const struct iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter)
status_t remove_vnode (dev_t mountID, ino_t vnodeID)
 Marks the specified vnode removed.
status_t unremove_vnode (dev_t mountID, ino_t vnodeID)
 Clears the "removed" mark of the specified vnode.
status_t write_file_io_vec_pages (int fd, const struct file_io_vec *fileVecs, size_t fileVecCount, const struct iovec *vecs, size_t vecCount, uint32 *_vecIndex, size_t *_vecOffset, size_t *_bytes)
status_t write_pages (int fd, off_t pos, const struct iovec *vecs, size_t count, size_t *_numBytes, bool fsReenter)
Notification Functions
The following functions are used to implement the node monitor functionality in your file system. Whenever one of the below mentioned events occur, you have to call them.

The node monitor will then notify all registered listeners for the nodes that changed.

status_t notify_attribute_changed (dev_t device, ino_t node, const char *attribute, int32 cause)
 Notifies listeners that an attribute of a file system entry has been changed.
status_t notify_entry_created (dev_t device, ino_t directory, const char *name, ino_t node)
 Notifies listeners that a file system entry has been created.
status_t notify_entry_moved (dev_t device, ino_t fromDirectory, const char *fromName, ino_t toDirectory, const char *toName, ino_t node)
 Notifies listeners that a file system entry has been moved to another directory.
status_t notify_entry_removed (dev_t device, ino_t directory, const char *name, ino_t node)
 Notifies listeners that a file system entry has been removed.
status_t notify_query_entry_created (port_id port, int32 token, dev_t device, ino_t directory, const char *name, ino_t node)
 Notifies listeners that an entry has entered the result set of a live query.
status_t notify_query_entry_removed (port_id port, int32 token, dev_t device, ino_t directory, const char *name, ino_t node)
 Notifies listeners that an entry has left the result set of a live query.
status_t notify_stat_changed (dev_t device, ino_t node, uint32 statFields)
 Notifies listeners that certain statFields of a file system entry were updated.


Detailed Description

Provides an interface for file system modules.

See the introduction to file system modules for a guide on how to get started with writing file system modules.


Define Documentation

#define B_CURRENT_FS_API_VERSION   "/v1"

Constant that defines the version of the file system API that your filesystem conforms to.

The module name that exports the interface to your file system has to end with this constant as in:

 "file_systems/myfs" B_CURRENT_FS_API_VERSION 


Enumeration Type Documentation

This mask is used in file_system_module_info::write_stat() to determine which values need to be written.

Enumerator:
FS_WRITE_STAT_MODE  The mode parameter should be updated.
FS_WRITE_STAT_UID  The UID field should be updated.
FS_WRITE_STAT_GID  The GID field should be updated.
FS_WRITE_STAT_SIZE  The size field should be updated. If the actual size is less than the new provided file size, the file should be set to the new size and the extra space should be filled with zeros.
FS_WRITE_STAT_ATIME  The access time should be updated.
FS_WRITE_STAT_MTIME  The 'last modified' field should be updated.
FS_WRITE_STAT_CRTIME  The 'creation time' should be updated.


Function Documentation

status_t get_vnode ( dev_t  mountID,
ino_t  vnodeID,
fs_vnode *  _privateNode 
)

Retrieves the private data handle for the node with the given ID.

If the function is successful, the caller owns a reference to the vnode. The reference can be surrendered by calling put_vnode().

Parameters:
mountID The ID of the volume.
vnodeID The ID of the node.
_privateNode Pointer to a pre-allocated variable the private data handle shall be written to.
Returns:
B_OK if everything went fine, another error code otherwise.

status_t get_vnode_removed ( dev_t  mountID,
ino_t  vnodeID,
bool *  removed 
)

Returns whether the specified vnode is marked removed.

The caller must own a reference to the vnode or at least ensure that a reference to the vnode exists.

Parameters:
mountID The ID of the volume.
vnodeID The ID of the node.
removed Pointer to a pre-allocated variable set to true, if the node is marked removed, to false otherwise.
Returns:
B_OK if everything went fine, another error code otherwise.

status_t new_vnode ( dev_t  mountID,
ino_t  vnodeID,
fs_vnode  privateNode 
)

Create the vnode with ID vnodeID and associates it with the private data handle privateNode, but leaves is in an unpublished state.

The effect of the function is similar to publish_vnode(), but the vnode remains in an unpublished state, with the effect that a subsequent remove_vnode() will just delete the vnode and not invoke the file system's remove_vnode() when the final reference is put down.

If the vnode shall be kept, publish_vnode() has to be invoked afterwards to mark the vnode published. The combined effect is the same as only invoking publish_vnode().

You'll usually use this function to secure a vnode ID from being reused while you are in the process of creating the entry. Note that this function will panic in case you call it for an existing vnode ID.

The function fails, if the vnode does already exist.

Parameters:
mountID The ID of the volume.
vnodeID The ID of the node.
privateNode The private data handle to be associated with the node.
Returns:
B_OK if everything went fine, another error code otherwise.

status_t publish_vnode ( dev_t  mountID,
ino_t  vnodeID,
fs_vnode  privateNode 
)

Creates the vnode with ID vnodeID and associates it with the private data handle privateNode or just marks it published.

If the vnode does already exist and has been published, the function fails. If it has not been published yet (i.e. after a successful new_vnode()), the function just marks the vnode published. If the vnode did not exist at all before, it is created and published.

If the function is successful, the caller owns a reference to the vnode. A sequence of new_vnode() and publish_vnode() results in just one reference as well. The reference can be surrendered by calling put_vnode().

This call is equivalent to the former R5 new_vnode() function.

Parameters:
mountID The ID of the volume.
vnodeID The ID of the node.
privateNode The private data handle to be associated with the node.
Returns:
B_OK if everything went fine, another error code otherwise.

status_t put_vnode ( dev_t  mountID,
ino_t  vnodeID 
)

Surrenders a reference to the specified vnode.

Parameters:
mountID The ID of the volume.
vnodeID The ID of the node.
Returns:
B_OK if everything went fine, another error code otherwise.

status_t remove_vnode ( dev_t  mountID,
ino_t  vnodeID 
)

Marks the specified vnode removed.

The caller must own a reference to the vnode or at least ensure that a reference to the vnode exists. The function does not surrender a reference, though.

As soon as the last reference to the vnode has been surrendered, the VFS invokes the file system's remove_vnode() hook.

Parameters:
mountID The ID of the volume.
vnodeID The ID of the node.
Returns:
B_OK if everything went fine, another error code otherwise.

status_t unremove_vnode ( dev_t  mountID,
ino_t  vnodeID 
)

Clears the "removed" mark of the specified vnode.

The caller must own a reference to the vnode or at least ensure that a reference to the vnode exists.

The function is usually called when the caller, who has invoked remove_vnode() before realizes that it is not possible to remove the node (e.g. due to an error).

Parameters:
mountID The ID of the volume.
vnodeID The ID of the node.
Returns:
B_OK if everything went fine, another error code otherwise.


The Haiku Book pre-R1 - fs_interface.h File Reference
Generated on 14 Feb 2008