PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches

Index node. More...

Collaboration diagram for Inode:

Detailed Description

Index node.

A inode 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 inode can appear in multiple dentries due to hardlinks or mounts.

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

Synchronization

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

Todo:
Implement actually writing/syncing dirty inodes, for now inodes should use the notify functions but they will never actually be "cleaned."

Data Structures

struct  inode_t
 Inode structure. More...
 
struct  inode_ops_t
 Inode operations structure. More...
 

Enumerations

enum  inode_flags_t { INODE_NONE = 0 }
 Inode flags. More...
 

Functions

inode_tinode_new (superblock_t *superblock, inode_number_t number, inode_type_t type, const inode_ops_t *ops, const file_ops_t *fileOps)
 Create a new inode.
 
void inode_notify_access (inode_t *inode)
 Notify the inode that it has been accessed.
 
void inode_notify_modify (inode_t *inode)
 Notify the inode that its content has been modified.
 
void inode_notify_change (inode_t *inode)
 Notify the inode that its metadata has changed.
 
void inode_truncate (inode_t *inode)
 Truncate the inode.
 

Enumeration Type Documentation

◆ inode_flags_t

Inode flags.

Enumerator
INODE_NONE 

None.

Definition at line 44 of file inode.h.

Function Documentation

◆ inode_new()

inode_t * inode_new ( superblock_t superblock,
inode_number_t  number,
inode_type_t  type,
const inode_ops_t ops,
const file_ops_t fileOps 
)

Create a new inode.

This DOES add the inode to the inode cache. It also does not associate the inode with a dentry, that is done when a dentry is made positive with dentry_make_positive().

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

Parameters
superblockThe superblock the inode belongs to.
numberThe inode number, for a generic filesystem vfs_id_get() can be used.
typeThe inode type.
opsThe inode operations.
fileOpsThe file operations for files opened on this inode.
Returns
On success, the new inode. On failure, returns NULL and errno is set.

Definition at line 41 of file inode.c.

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

◆ inode_notify_access()

void inode_notify_access ( inode_t inode)

Notify the inode that it has been accessed.

This updates the access time.

Parameters
inodeThe inode to notify.

Definition at line 85 of file inode.c.

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

◆ inode_notify_modify()

void inode_notify_modify ( inode_t inode)

Notify the inode that its content has been modified.

This updates the modify time and change time.

Parameters
inodeThe inode to notify.

Definition at line 97 of file inode.c.

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

◆ inode_notify_change()

void inode_notify_change ( inode_t inode)

Notify the inode that its metadata has changed.

This updates the change time.

Parameters
inodeThe inode to notify.

Definition at line 109 of file inode.c.

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

◆ inode_truncate()

void inode_truncate ( inode_t inode)

Truncate the inode.

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

Parameters
inodeThe inode to truncate.

Definition at line 120 of file inode.c.

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