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

The source code of this header can be browsed online.

Description  

Core file system node

Members  

Types  

Functions  

  • error_t vfs_mount(struct vfs_node_s *mountpoint, struct vfs_fs_s *fs)
  • bool_t vfs_node__refdec(struct vfs_node_s *node, const char *func)
  • struct vfs_node_s * vfs_node__refinc(struct vfs_node_s *node, const char *func)
  • error_t vfs_node_anon_create(struct vfs_fs_s *fs, enum vfs_node_type_e type, struct vfs_node_s **node)
  • void vfs_node_cleanup(struct vfs_node_s *node)
  • void vfs_node_destroy(struct vfs_node_s *node)
  • struct vfs_fs_s * vfs_node_get_fs(struct vfs_node_s *node)
  • ssize_t vfs_node_get_name(struct vfs_node_s *node, char *name, size_t namelen)
  • struct vfs_node_s * vfs_node_get_parent(struct vfs_node_s *node)
  • error_t vfs_node_init(struct vfs_node_s *node, struct vfs_fs_s *fs, enum vfs_node_type_e type, const char *name, size_t name_size)
  • error_t vfs_node_link(struct vfs_node_s *node, struct vfs_node_s *parent, const char *fullname, size_t fullnamelen, struct vfs_node_s **rnode)
  • error_t vfs_node_lookup(struct vfs_node_s *parent, const char *fullname, size_t fullnamelen, struct vfs_node_s **node)
  • error_t vfs_node_move(struct vfs_node_s *node, struct vfs_node_s *parent, const char *fullname, size_t fullnamelen)
  • error_t vfs_node_open(struct vfs_node_s *node, enum vfs_open_flags_e flags, struct vfs_file_s **file)
  • error_t vfs_node_stat(struct vfs_node_s *node, struct vfs_stat_s *stat)
  • error_t vfs_node_unlink(struct vfs_node_s *parent, const char *fullname, size_t fullnamelen)
  • error_t vfs_umount(struct vfs_node_s *mountpoint)

Members detail  

#define GCT_CONTAINER_ALGO_vfs_dir_hash  

This macro is declared in vfs/node.h source file, line 41.

#define _VFS_NODE_H_  

This macro is declared in vfs/node.h source file, line 28.

typedef void * vfs_dir_hash_entry_t  

This typedef is declared in vfs/node.h source file, line 126.

typedef struct vfs_node_s * vfs_dir_hash_item_t  

This typedef is declared in vfs/node.h source file, line 181.

typedef void * vfs_dir_hash_root_t  

This typedef is declared in vfs/node.h source file, line 126.

struct vfs_dirent_s  

This struct is declared in vfs/node.h source file, line 232.

FieldDescription
char name[CONFIG_VFS_NAMELEN+1];Name of the directory entry, asciiZ
enum vfs_node_type_e type;Type of node
size_t size;Size of file in bytes, or count of children nodes excluding "." and ".."

error_t vfs_mount(struct vfs_node_s *mountpoint, struct vfs_fs_s *fs)  

this function mounts a file system inside another, replacing the mountpoint node in the VFS. mountpoint must be a directory.

Parameter list:

  • mountpoint: directory that must be replaced with fs's root.
  • fs: new filesystem to attach at mountpoint

The return value is 0 if mounted correctly

bool_t vfs_node__refdec(struct vfs_node_s *node, const char *func)  

This function is declared in vfs/node.h source file, line 192.

struct vfs_node_s * vfs_node__refinc(struct vfs_node_s *node, const char *func)  

This function is declared in vfs/node.h source file, line 186.

error_t vfs_node_anon_create(struct vfs_fs_s *fs, enum vfs_node_type_e type, struct vfs_node_s **node)  

this function creates a new anonymous node in a given FS.

It relies on the vfs_fs_create_t fs drivers operation, refer for details. this function transfers the ownership of node to caller.

See also vfs_create.

void vfs_node_cleanup(struct vfs_node_s *node)  

This function frees resources allocated by vfs_node_init.

void vfs_node_destroy(struct vfs_node_s *node)  

This function calls the vfs_node_s::close and the vfs_node_cleanup functions then free the node object. This is called when the node refcount reaches 0.

struct vfs_fs_s * vfs_node_get_fs(struct vfs_node_s *node)  

ssize_t vfs_node_get_name(struct vfs_node_s *node, char *name, size_t namelen)  

struct vfs_node_s * vfs_node_get_parent(struct vfs_node_s *node)  

error_t vfs_node_init(struct vfs_node_s *node, struct vfs_fs_s *fs, enum vfs_node_type_e type, const char *name, size_t name_size)  

This function initializes common fields of a VFS node object. Name may be NULL or 0-sized.

error_t vfs_node_link(struct vfs_node_s *node, struct vfs_node_s *parent, const char *fullname, size_t fullnamelen, struct vfs_node_s **rnode)  

this function links a node in a given parent. As a node must be unique in the VFS, node may be cloned in order to be attached where wanted. Thus the actually attached node returned in rnode may be different from node.

Parameter list:

  • node: Node to attach
  • parent: Where to attach a new child
  • fullname: Name of the new node, may be a long file system entry name but will be shortened for use as vfs node name.
  • fullnamelen: Length of name of the new node
  • rnode: Actually attached node

The return value is 0 if created

this function transfers the ownership of rnode to caller, even if it is actually node.

See also vfs_fs_link_t and vfs_name_mangle.

error_t vfs_node_lookup(struct vfs_node_s *parent, const char *fullname, size_t fullnamelen, struct vfs_node_s **node)  

this function looks for a node named name as a child of parent. First looks up in the hash table. If name is not found, it calls the driver. '.' and '..' are not supported.

Parameter list:

  • parent: Node to look up from
  • name: Name of the node, must not contain any '/'. It may not end with a '\0' . May be eiter a full length file system name or a vfs shortened node name.
  • namelen: Length of node name
  • node: Returned node

The return value is 0 if found

this function transfers the ownership of node to caller.

See also vfs_fs_lookup_t, vfs_lookup and vfs_name_mangle.

error_t vfs_node_move(struct vfs_node_s *node, struct vfs_node_s *parent, const char *fullname, size_t fullnamelen)  

this function moves a node in a given parent.

Parameter list:

  • node: Node to attach to a new parent
  • parent: Where to attach node
  • fullname: Name of the new node, may be a long file system entry name but will be shortened for use as vfs node name.
  • fullnamelen: Length of name of the new node

The return value is 0 if created

See also vfs_fs_move_t and vfs_name_mangle.

error_t vfs_node_open(struct vfs_node_s *node, enum vfs_open_flags_e flags, struct vfs_file_s **file)  

this function opens an existing node in a given FS.

flags inform the file system about the actions intended on the file. VFS_OPEN_READ and VFS_OPEN_WRITE may be ored together. For directories, the only valid operation is VFS_OPEN_READ | VFS_OPEN_DIR.

this function fail if trying to open a file with VFS_OPEN_DIR flag present.

This function must only honor VFS_OPEN_READ, VFS_OPEN_WRITE and VFS_OPEN_DIR flags. Other flags must be ignored (even VFS_OPEN_CREATE and VFS_OPEN_APPEND).

This function must not create new files implicitely.

It relies on the vfs_fs_node_open_t fs drivers operation, refer for details. this function transfers the ownership of node to caller.

See also vfs_open and vfs_fs_node_open_t.

#define vfs_node_refdec(x)  

This macro is declared in vfs/node.h source file, line 197.

#define vfs_node_refinc(x)  

This macro is declared in vfs/node.h source file, line 196.

struct vfs_node_s  

This struct is declared in vfs/node.h source file, line 129.

this struct is a node in the VFS.

FieldDescription
struct vfs_fs_s * fs;File system the node is in
enum vfs_node_type_e type;
char name[CONFIG_VFS_NAMELEN];Name of the node in its parent directory structure. Anonymous (dandling) nodes should not have any name. Any unused characters in the name should be filled with '\0'
struct vfs_node_s * parent; Parent node.
Root has its own pointer here, dandling nodes have NULL.
Accesses to this value must be protected for atomicity with parent_lock.
Code external to VFS code MUST use vfs_node_get_parent.
lock_t parent_lock; Lock protecting accesses to parent
atomic_t lookup_count; Statistics counter
atomic_t open_count; Statistics counter
atomic_t close_count; Statistics counter
atomic_t stat_count; Statistics counter
vfs_dir_hash_root_t children; Children cache hash.
Accesses to this value must be protected through dir_semaphore.
struct semaphore_s dir_semaphore; Semaphore protecting children

See also vfs_dir_hash_item_t.

error_t vfs_node_stat(struct vfs_node_s *node, struct vfs_stat_s *stat)  

this function retrieves information about a given node.

Parameter list:

  • node: Node to retrieve information about
  • stat: User-provided buffer to hold node information

The return value is 0 if node was found, or an error

See also vfs_fs_stat_t and vfs_stat.

enum vfs_node_type_e  

This enum is declared in vfs/node.h source file, line 45.

IdentifierDescription
VFS_NODE_DIRA directory node
VFS_NODE_FILEA regular file node

error_t vfs_node_unlink(struct vfs_node_s *parent, const char *fullname, size_t fullnamelen)  

Unlinks a node from its parent.

Parameter list:

  • parent: Where to unlink a child
  • fullname: Name of the node, must not contain any '/'. It may not end with a '\0' . May be eiter a full length file system name or a vfs shortened node name.
  • fullnamelen: Length of name

The return value is 0 if unlinked correctly

See also vfs_fs_unlink_t and vfs_unlink.

struct vfs_stat_s  

This struct is declared in vfs/node.h source file, line 204.

this struct is the vfs_node_stat() operation response buffer.

FieldDescription
enum vfs_node_type_e type;File or directory
vfs_file_size_t size;File size in bytes, or directory entry count excluding "." and ".."
size_t nlink;Count of links to the data on disk

error_t vfs_umount(struct vfs_node_s *mountpoint)  

this function unmounts a file system. fs must not have any files left open. Old directory node will be restored in VFS.

Parameter list:

  • mountpoint: Mountpoint where to umount a file system

The return value is 0 if unmounted correctly

Valid XHTML 1.0 StrictGenerated by diaxen on Wed Oct 17 21:18:39 2018 using MkDoc