|
PatchworkOS
|
Index node. More...
Data Structures | |
| struct | inode_t |
| Inode structure. More... | |
| struct | inode_ops_t |
Enumerations | |
| enum | inode_flags_t { INODE_NONE = 0 } |
| Inode flags. More... | |
Functions | |
| 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. | |
| 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. | |
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 note that a inode can appear in multiple dentries due to hardlinks or becouse of mountpoints.
So despite the name they are in no way "nodes" in some kind of tree structure, this confused me for a long time when first learning about filesystems.
| enum inode_flags_t |
| 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 DEREF().
| superblock | The superblock the inode belongs to. |
| number | The inode number. |
| type | The inode type. |
| ops | The inode operations. |
| fileOps | The file operations for files opened on this inode. |
NULL and errno is set. Definition at line 42 of file inode.c.
References inode_t::accessTime, superblock_ops_t::allocInode, inode_t::blocks, inode_t::changeTime, inode_t::createTime, DEREF, EINVAL, ERR, errno, inode_t::fileOps, fileOps, inode_t::flags, inode_free(), INODE_NONE, inode_t::linkCount, malloc(), map_entry_init(), inode_t::mapEntry, inode_t::modifyTime, inode_t::mutex, mutex_init(), NULL, inode_t::number, inode_t::ops, superblock_t::ops, ops, inode_t::private, inode_t::ref, REF, ref_init(), inode_t::size, inode_t::superblock, timer_unix_epoch(), inode_t::type, and vfs_add_inode().
Referenced by ramfs_inode_new(), sysfs_dir_new(), sysfs_file_new(), sysfs_mount(), and sysfs_mount_new().
| void inode_notify_access | ( | inode_t * | inode | ) |
Notify the inode that it has been accessed.
This updates the access time.
| inode | The inode to notify. |
Definition at line 93 of file inode.c.
References inode_t::accessTime, inode_t::mutex, MUTEX_SCOPE, NULL, and timer_unix_epoch().
Referenced by vfs_getdents(), vfs_ioctl(), vfs_mmap(), vfs_open(), vfs_open2(), and vfs_read().
| void inode_notify_change | ( | inode_t * | inode | ) |
Notify the inode that its metadata has changed.
This updates the change time.
| inode | The inode to notify. |
Definition at line 119 of file inode.c.
References inode_t::changeTime, inode_t::mutex, MUTEX_SCOPE, NULL, and timer_unix_epoch().
Referenced by vfs_link(), and vfs_remove().
| void inode_notify_modify | ( | inode_t * | inode | ) |
Notify the inode that its content has been modified.
This updates the modify time and change time.
| inode | The inode to notify. |
Definition at line 106 of file inode.c.
References inode_t::changeTime, inode_t::modifyTime, inode_t::mutex, MUTEX_SCOPE, NULL, and timer_unix_epoch().
Referenced by vfs_link(), and vfs_write().
| 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.
| inode | The inode to truncate. |
Definition at line 131 of file inode.c.
References assert, inode_t::mutex, MUTEX_SCOPE, NULL, inode_t::ops, RFLAGS_INTERRUPT_ENABLE, rflags_read(), and inode_ops_t::truncate.
Referenced by vfs_open(), and vfs_open2().