vfs/fs.h header reference
[Virtual File System module]

The source code of this header can be browsed online.

Description [link] 

Filesystems are drivers to the low-level aspects of a given filesystem. They basically manipulate 3 structures:

  • struct vfs_fs_s: A filesystem state. It is unique for an open filesystem. This structure is used to mount a filesystem in another (with vfs_mount).

  • struct vfs_node_s: A filesystem-level node. It represents an actual node in a filesystem. This type is filesystem-implementation dependant, VFS sees it as an abstract type. Is is also refcounted through node_refnew and node_refdrop function pointers of struct vfs_fs_ops_s.

  • struct vfs_file_s: An open file descriptor. It is created by node_open (in struct vfs_fs_ops_s) and must be closed on finish.

Filesystems may be read-only, or even read-write only at the file-level. This means operations like lookup, move, link and others are not possible. If so, corresponding entries in struct vfs_fs_ops_s may be NULL.

Members [link] 

Types [link] 

  • typedef bool_t (vfs_fs_can_unmount_t)(struct vfs_fs_s *fs)
  • typedef void (vfs_fs_cleanup_t)(struct vfs_fs_s *fs)
  • typedef error_t (vfs_fs_create_t)(struct vfs_fs_s *fs, enum vfs_node_type_e type, struct vfs_node_s **node)
  • typedef error_t (vfs_fs_link_t)(struct vfs_node_s *node, struct vfs_node_s *parent, const char *name, size_t namelen, struct vfs_node_s **rnode)
  • typedef error_t (vfs_fs_lookup_t)(struct vfs_node_s *ref, const char *name, size_t namelen, struct vfs_node_s **node, char *mangled_name)
  • typedef error_t (vfs_fs_move_t)(struct vfs_node_s *node, struct vfs_node_s *parent, const char *name, size_t namelen)
  • typedef void (vfs_fs_node_cleanup_t)(struct vfs_node_s *node)
  • typedef error_t (vfs_fs_node_open_t)(struct vfs_node_s *node, enum vfs_open_flags_e flags, struct vfs_file_s **file)
  • struct vfs_fs_ops_s
  • struct vfs_fs_s
  • typedef error_t (vfs_fs_stat_t)(struct vfs_node_s *node, struct vfs_stat_s *stat)
  • typedef error_t (vfs_fs_unlink_t)(struct vfs_node_s *parent, const char *name, size_t namelen)

Functions [link] 

Macros [link] 

Members detail [link] 

#define VFS_FS_CAN_UNMOUNT(x) [link] 

This macro is declared in vfs/fs.h source file, line 126.

this macro defines the fs unmountable test prototype

#define VFS_FS_CLEANUP(x) [link] 

This macro is declared in vfs/fs.h source file, line 316.

This macro defines the fs cleanup prototype

#define VFS_FS_CREATE(x) [link] 

This macro is declared in vfs/fs.h source file, line 199.

this macro defines the fs create operation prototype

#define VFS_FS_LINK(x) [link] 

This macro is declared in vfs/fs.h source file, line 219.

this macro defines the fs link operation prototype

#define VFS_FS_LOOKUP(x) [link] 

This macro is declared in vfs/fs.h source file, line 169.

this macro defines the fs lookup operation prototype

#define VFS_FS_MOVE(x) [link] 

This macro is declared in vfs/fs.h source file, line 255.

this macro defines the fs move operation prototype

#define VFS_FS_NODE_CLEANUP(x) [link] 

This macro is declared in vfs/fs.h source file, line 323.

This macro defines the VFS node cleanup prototype

#define VFS_FS_NODE_OPEN(x) [link] 

This macro is declared in vfs/fs.h source file, line 145.

this macro defines the fs node open operation prototype

#define VFS_FS_STAT(x) [link] 

This macro is declared in vfs/fs.h source file, line 297.

this macro defines the fs stat operation prototype

#define VFS_FS_UNLINK(x) [link] 

This macro is declared in vfs/fs.h source file, line 276.

this macro defines the fs unlink operation prototype

#define _VFS_FS_H_ [link] 

This macro is declared in vfs/fs.h source file, line 52.

typedef bool_t (vfs_fs_can_unmount_t)(struct vfs_fs_s *fs) [link] 

This typedef is declared in vfs/fs.h source file, line 143.

This function asks the file system whether its current internal state allows it to be unmounted. This function should take opened files, directories and anonymous nodes into account.

This function does not have to ensure the filesystem will stay unmountable. Ensuring nobody takes new references on the file system being unmounted is VFS's job.

Parameter list:

  • fs: Fs state to probe for unmounting

The return value is 1 if file system can be unmounted, else 0

This declaration involves expansion of the VFS_FS_CAN_UNMOUNT macro.

See also VFS_FS_CAN_UNMOUNT.

void vfs_fs_cleanup(struct vfs_fs_s *fs) [link] 

This function is declared in vfs/fs.h source file, line 119.

This function free resources allocated by vfs_fs_init.

typedef void (vfs_fs_cleanup_t)(struct vfs_fs_s *fs) [link] 

This typedef is declared in vfs/fs.h source file, line 320.

This typedef free resources associated with a file system.

This declaration involves expansion of the VFS_FS_CLEANUP macro.

typedef error_t (vfs_fs_create_t)(struct vfs_fs_s *fs, enum vfs_node_type_e type, struct vfs_node_s **node) [link] 

This typedef is declared in vfs/fs.h source file, line 217.

This function creates a new anonymous node in a given file system.

Parameter list:

  • fs: The fs state
  • type: Node type
  • node: Returned created node

The return value is 0 on success, or an error code

This function transfers the ownership of *node to the caller

This declaration involves expansion of the VFS_FS_CREATE macro.

See also VFS_FS_CREATE, vfs_node_anon_create and vfs_create.

void vfs_fs_destroy(struct vfs_fs_s *fs) [link] 

This function is declared in vfs/fs.h source file, line 124.

This function calls the vfs_fs_ops_s::cleanup and the vfs_fs_cleanup functions then free the fs object. This is called when the fs refcount reaches 0.

void vfs_fs_dump_stats(struct vfs_fs_s *fs) [link] 

This function is declared in vfs/fs.h source file, line 330.

error_t vfs_fs_init(struct vfs_fs_s *fs, const struct vfs_fs_ops_s *ops, bool_t ro) [link] 

This function is declared in vfs/fs.h source file, line 112.

This function initializes common fields of a file system object. It is mandatory to call vfs_fs_root_set once after this call.

typedef error_t (vfs_fs_link_t)(struct vfs_node_s *node, struct vfs_node_s *parent, const char *name, size_t namelen, struct vfs_node_s **rnode) [link] 

This typedef is declared in vfs/fs.h source file, line 252.

This function links a node in a parent directory node. Filesystem may not support linking operation on all node types, or may not support linking at all. The only operation expected to succeed everywhere is linking an anonymous node created with vfs_fs_create_t.

As nodes must be unique in the VFS, the node present at destination point on link after the operation (rnode) may be different from the passed node (node).

Parameter list:

  • node: Node to attach in parent
  • parent: Parent directory node to attach node in
  • name: Name to lookup for, it may not end with '\0'.
  • namelen: Length of name, excluding any '\0'
  • rnode: Actually attached node, may be node or another new node.
  • mangled_name: Mangled name of returned node. The buffer is CONFIG_VFS_NAMELEN long.

The return value is 0 on success, or an error code

This function transfers the ownership of *rnode to the caller, even if *rnode is actually node

This declaration involves expansion of the VFS_FS_LINK macro.

See also VFS_FS_LINK and vfs_node_link.

typedef error_t (vfs_fs_lookup_t)(struct vfs_node_s *ref, const char *name, size_t namelen, struct vfs_node_s **node, char *mangled_name) [link] 

This typedef is declared in vfs/fs.h source file, line 196.

This function searches for a given name in a directory node. This function is only valid for directory nodes.

This function must not create new nodes in the actual file system.

Parameter list:

  • ref: Reference directory node
  • name: Name to lookup for, it may not end with '\0'.
  • namelen: Length of name, excluding any '\0'
  • node: Returned node if found. File system must not insert the node in the ref's children hash
  • mangled_name: Mangled name of returned node. The buffer is #CONFIG_VFS_NAMELEN long.

The return value is 0 on success, or an error code

This function transfers the ownership of *node to the caller

This declaration involves expansion of the VFS_FS_LOOKUP macro.

See also VFS_FS_LOOKUP, vfs_lookup and vfs_node_lookup.

typedef error_t (vfs_fs_move_t)(struct vfs_node_s *node, struct vfs_node_s *parent, const char *name, size_t namelen) [link] 

This typedef is declared in vfs/fs.h source file, line 273.

This function moves a node in another parent directory node.

Parameter list:

  • node: Node to attach in parent
  • parent: Parent directory to attach node in
  • name: Name to set for new node name, it may not end with '\0'.
  • namelen: Length of name, excluding any '\0'

The return value is 0 on success, or an error code

This declaration involves expansion of the VFS_FS_MOVE macro.

See also VFS_FS_MOVE and vfs_node_move.

typedef void (vfs_fs_node_cleanup_t)(struct vfs_node_s *node) [link] 

This typedef is declared in vfs/fs.h source file, line 327.

This typedef free resources associated with a fs node.

This declaration involves expansion of the VFS_FS_NODE_CLEANUP macro.

typedef error_t (vfs_fs_node_open_t)(struct vfs_node_s *node, enum vfs_open_flags_e flags, struct vfs_file_s **file) [link] 

This typedef is declared in vfs/fs.h source file, line 166.

This function opens a node for read/write operations.

Parameter list:

  • node: Node to open. It may be an anonymous node (not present in any directory)
  • flags: Mode to open the file in
  • file: Returned file descriptor on success

The return value is 0 on success, or an error code

Some checks are already performed on and node type, see vfs_node_open for details. This function transfers the ownership of *file to the caller.

This declaration involves expansion of the VFS_FS_NODE_OPEN macro.

See also VFS_FS_NODE_OPEN, vfs_node_open and vfs_open.

struct vfs_fs_ops_s [link] 

This struct is declared in vfs/fs.h source file, line 333.

FieldDescription
vfs_fs_node_open_t * node_open;mandatory
vfs_fs_lookup_t * lookup;mandatory
vfs_fs_create_t * create;optional, may be NULL
vfs_fs_link_t * link;optional, may be NULL
vfs_fs_move_t * move;optional, may be NULL
vfs_fs_unlink_t * unlink;optional, may be NULL
vfs_fs_stat_t * stat;mandatory
vfs_fs_can_unmount_t * can_unmount;mandatory
vfs_fs_cleanup_t * cleanup;optional, may be NULL
vfs_fs_node_cleanup_t * node_cleanup;optional, may be NULL

void vfs_fs_root_set(struct vfs_fs_s *fs, struct vfs_node_s *root) [link] 

This function is declared in vfs/fs.h source file, line 116.

This function sets root node for file system. This may be called only once from fs open function .

struct vfs_fs_s [link] 

This struct is declared in vfs/fs.h source file, line 67.

this struct is an opened filesystem state.

FieldDescription
struct vfs_node_s * root;Root node of the filesystem. This is filled when opening the filesystem
const struct vfs_fs_ops_s * ops;A pointer to supported operations table
uint8_t flag_ro:1;Whether filesystem is read-only
struct vfs_node_s * old_node;Mountpoint that was replaced with this filesystem's root on mount. NULL for non-mounted filesystems
atomic_t node_open_count; Statistics counter
atomic_t lookup_count; Statistics counter
atomic_t create_count; Statistics counter
atomic_t link_count; Statistics counter
atomic_t move_count; Statistics counter
atomic_t unlink_count; Statistics counter
atomic_t stat_count; Statistics counter
atomic_t node_create_count; Statistics counter
atomic_t node_destroy_count; Statistics counter
atomic_t file_open_count; Statistics counter
atomic_t file_close_count; Statistics counter

typedef error_t (vfs_fs_stat_t)(struct vfs_node_s *node, struct vfs_stat_s *stat) [link] 

This typedef is declared in vfs/fs.h source file, line 312.

This function retrieves informations about a given node. This node may be a file or a directory.

Parameter list:

  • node: Node to retrieve information about
  • stat: Stat buffer to store information into

The return value is 0 on success, or an error code

This declaration involves expansion of the VFS_FS_STAT macro.

See also VFS_FS_STAT, vfs_node_stat and vfs_stat.

typedef error_t (vfs_fs_unlink_t)(struct vfs_node_s *parent, const char *name, size_t namelen) [link] 

This typedef is declared in vfs/fs.h source file, line 293.

This function removes a node from the file system. Node may still be referenced or open, and may become a dandling anonymous file.

Parameter list:

  • parent: Directory node where to unlink a child
  • name: Name of child to unlink, it may not end with '\0'.
  • namelen: Length of name, excluding any '\0'

The return value is 0 on success, or an error code

This declaration involves expansion of the VFS_FS_UNLINK macro.

See also VFS_FS_UNLINK, vfs_node_unlink and vfs_unlink.

Valid XHTML 1.0 StrictGenerated by diaxen on Thu Aug 4 15:44:06 2022 using MkDoc