PatchworkOS
Loading...
Searching...
No Matches
inode.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/fs/path.h>
4#include <kernel/sync/mutex.h>
5#include <kernel/utils/map.h>
6#include <kernel/utils/ref.h>
7
8#include <stdatomic.h>
9#include <stdint.h>
10#include <sys/io.h>
11#include <sys/proc.h>
12#include <time.h>
13
14// TODO: Implement actually writing/syncing dirty inodes, for now inodes should use the notify functions but they will
15// never actually be "cleaned."
16
17typedef struct inode inode_t;
18typedef struct inode_ops inode_ops_t;
19typedef struct superblock superblock_t;
20typedef struct file_ops file_ops_t;
21typedef struct dentry dentry_t;
22
42typedef enum
43{
46
73
80typedef struct inode_ops
81{
87 uint64_t (*lookup)(inode_t* dir, dentry_t* target);
91 uint64_t (*create)(inode_t* dir, dentry_t* target, path_flags_t flags);
92 void (*truncate)(inode_t* target);
93 uint64_t (*link)(dentry_t* old, inode_t* dir, dentry_t* target);
97 uint64_t (*remove)(inode_t* parent, dentry_t* target, path_flags_t flags);
98 void (*cleanup)(inode_t* inode);
100
116inode_t* inode_new(superblock_t* superblock, inode_number_t number, inode_type_t type, const inode_ops_t* ops,
117 const file_ops_t* fileOps);
118
126void inode_notify_access(inode_t* inode);
127
135void inode_notify_modify(inode_t* inode);
136
144void inode_notify_change(inode_t* inode);
145
154void inode_truncate(inode_t* inode);
155
void inode_notify_change(inode_t *inode)
Notify the inode that its metadata has changed.
Definition inode.c:119
void inode_notify_modify(inode_t *inode)
Notify the inode that its content has been modified.
Definition inode.c:106
void inode_notify_access(inode_t *inode)
Notify the inode that it has been accessed.
Definition inode.c:93
inode_flags_t
Inode flags.
Definition inode.h:43
void inode_truncate(inode_t *inode)
Truncate the inode.
Definition inode.c:131
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.
Definition inode.c:42
@ INODE_NONE
None.
Definition inode.h:44
path_flags_t
Path flags.
Definition path.h:83
inode_type_t
Inode type enum.
Definition io.h:344
uint64_t inode_number_t
Inode number enum.
Definition io.h:353
uint64_t link(const char *oldPath, const char *newPath)
System call for creating a hardlink.
Definition link.c:9
static socket_family_ops_t ops
Definition local.c:505
static file_ops_t fileOps
Definition ramfs.c:99
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
_PUBLIC int remove(const char *filename)
Definition remove.c:6
Directory entry structure.
Definition dentry.h:83
File operations structure.
Definition file.h:57
Inode structure.
Definition inode.h:54
uint64_t blocks
Definition inode.h:61
mutex_t mutex
Definition inode.h:70
ref_t ref
Definition inode.h:55
time_t accessTime
Unix time stamp for the last inode access.
Definition inode.h:62
time_t createTime
Unix time stamp for the inode creation.
Definition inode.h:65
time_t modifyTime
Unix time stamp for last file content alteration.
Definition inode.h:63
inode_type_t type
Constant after creation.
Definition inode.h:57
inode_number_t number
Constant after creation.
Definition inode.h:56
superblock_t * superblock
Constant after creation.
Definition inode.h:67
const inode_ops_t * ops
Constant after creation.
Definition inode.h:68
uint64_t size
Definition inode.h:60
inode_flags_t flags
Definition inode.h:58
time_t changeTime
Unix time stamp for the last file metadata alteration.
Definition inode.h:64
uint64_t linkCount
Definition inode.h:59
const file_ops_t * fileOps
Constant after creation.
Definition inode.h:69
map_entry_t mapEntry
Protected by the inodeCache lock.
Definition inode.h:71
Map entry structure.
Definition map.h:57
Mutex structure.
Definition mutex.h:39
Reference counting structure.
Definition ref.h:30
Superblock structure.
Definition superblock.h:44
long long unsigned time_t
Definition time_t.h:4