PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches

Virtual node. More...

Collaboration diagram for Vnode:

Detailed Description

Virtual node.

A vnode represents the actual data and metadata of a file. It is referenced by dentries, which represent the name or "location" of the file but a vnode can appear in multiple dentries due to hardlinks or mounts.

Note
Despite the name vnodes are in no way "nodes" in any kind of tree structure, that would be the dentries.

Synchronization

Vnodes have an additional purpose within the Virtual File System (VFS) as they act as the primary means of synchronization. All dentries synchronize upon their vnodes mutex, open files synchronize upon the mutex of the underlying vnode and operations like create, remove, etc synchronize upon the vnode mutex of the parent directory.

Data Structures

struct  vnode_t
 vnode structure. More...
 
struct  vnode_ops_t
 vnode operations structure. More...
 

Functions

vnode_tvnode_new (superblock_t *superblock, vtype_t type, const vnode_ops_t *ops, const file_ops_t *fileOps)
 Create a new vnode.
 
void vnode_truncate (vnode_t *vnode)
 Truncate the vnode.
 

Function Documentation

◆ vnode_new()

vnode_t * vnode_new ( superblock_t superblock,
vtype_t  type,
const vnode_ops_t ops,
const file_ops_t fileOps 
)

Create a new vnode.

Does not associate the vnode with a dentry, that is done when a dentry is made positive with dentry_make_positive().

There is no vnode_free() instead use UNREF().

Parameters
superblockThe superblock the vnode belongs to.
typeThe vnode type.
opsThe vnode operations.
fileOpsThe file operations for files opened on this vnode.
Returns
On success, the new vnode. On failure, returns NULL and errno is set.

Definition at line 51 of file vnode.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vnode_truncate()

void vnode_truncate ( vnode_t vnode)

Truncate the vnode.

The filesystem should implement the actual truncation in the vnode ops truncate function, this is just a helper to call it.

Parameters
vnodeThe vnode to truncate.

Definition at line 75 of file vnode.c.

Here is the call graph for this function:
Here is the caller graph for this function: