#include <sys/kmem.h>
#include <sys/stat.h>
Go to the source code of this file.
|
| DECLARE_SLAB (VFS) |
|
| DECLARE_SLAB (VNode) |
|
int | VFS_MountRoot (Disk *root) |
|
VNode * | VFS_Lookup (const char *path) |
|
int | VFS_Stat (const char *path, struct stat *sb) |
|
int | VFS_Open (VNode *fn) |
|
int | VFS_Close (VNode *fn) |
|
int | VFS_Read (VNode *fn, void *buf, uint64_t off, uint64_t len) |
|
int | VFS_Write (VNode *fn, void *buf, uint64_t off, uint64_t len) |
|
int | VFS_ReadDir (VNode *fn, void *buf, uint64_t len, uint64_t *off) |
|
◆ VFS
Definition at line 11 of file vfs.h.
◆ VNode
Definition at line 24 of file vfs.h.
◆ VFS
◆ VFSOp
Definition at line 8 of file vfs.h.
◆ VNode
Definition at line 9 of file vfs.h.
◆ DECLARE_SLAB() [1/2]
◆ DECLARE_SLAB() [2/2]
◆ VFS_Close()
int VFS_Close |
( |
VNode * |
fn | ) |
|
VFS_Close –
Close a vnode.
- Parameters
-
- Returns
- Return status
Definition at line 162 of file vfs.c.
◆ VFS_Lookup()
VNode * VFS_Lookup |
( |
const char * |
path | ) |
|
VFS_Lookup –
Lookup a VNode by a path. This function recursively searches the directory heirarchy until the given path is found otherwise returns NULL if not found.
Definition at line 63 of file vfs.c.
64{
65 int status;
66 const char *start = path + 1;
67 const char *end = path + 1;
71 char curName[256];
72
73 if (path[0] != '/')
75
77 if (status < 0)
78 Panic(
"Failed to get root VNode\n");
79
80 while (1) {
81 while (*end != '\0' && *end != '/')
82 end++;
83
86
87 return curNode;
88 }
90
92 }
93
96
97 oldNode = curNode;
99 status = oldNode->
op->
lookup(oldNode, &curNode, curName);
100 if (status < 0) {
101
103 }
104
105
106
107 if (*end == '\0') {
108 Log(vfs,
"%s %lx\n", path, curNode);
109 return curNode;
110 }
111
112 start = end + 1;
113 end = end + 1;
114 }
115}
#define Log(_module, _format,...)
void * memcpy(void *dst, const void *src, size_t len)
int(* getroot)(VFS *fs, VNode **dn)
int(* lookup)(VNode *dn, VNode **fn, const char *name)
void Panic(const char *str)
◆ VFS_MountRoot()
int VFS_MountRoot |
( |
Disk * |
rootDisk | ) |
|
VFS_MountRoot –
Mount the root file system from a specific disk.
Definition at line 36 of file vfs.c.
37{
38 int status;
39
41
44
47 return -1;
48
50 if (status < 0)
51 Panic(
"Failed to get root VNode\n");
52
53 return 0;
54}
void Slab_Init(Slab *slab, const char *name, uintptr_t objsz, uintptr_t align)
#define SPINLOCK_TYPE_NORMAL
void Spinlock_Init(Spinlock *lock, const char *name, uint64_t type)
VFS * O2FS_Mount(Disk *root)
◆ VFS_Open()
int VFS_Open |
( |
VNode * |
fn | ) |
|
VFS_Open –
Open a vnode for reading and writing.
- Parameters
-
- Returns
- Return status
Definition at line 147 of file vfs.c.
◆ VFS_Read()
VFS_Read –
Read from a vnode.
- Parameters
-
[in] | fn | VNode to read from. |
[in] | buf | Buffer to write the data to. |
[in] | off | File offset in bytes. |
[in] | len | Length to read in bytes. |
- Returns
- Return status
Definition at line 180 of file vfs.c.
181{
183}
int(* read)(VNode *fn, void *buf, uint64_t off, uint64_t len)
◆ VFS_ReadDir()
VFS_ReadDir –
Read a directory entry from a vnode.
- Parameters
-
[in] | fn | VNode to read from. |
[in] | buf | Buffer to write the data to. |
[in] | off | Directory offset in bytes. |
[in] | len | Length to read in bytes. |
- Returns
- Return status
Definition at line 216 of file vfs.c.
217{
219}
int(* readdir)(VNode *fn, void *buf, uint64_t len, uint64_t *off)
◆ VFS_Stat()
int VFS_Stat |
( |
const char * |
path, |
|
|
struct stat * |
sb |
|
) |
| |
VFS_Stat –
Return the struct stat that contains the file and directory information for a given VNode.
Definition at line 124 of file vfs.c.
125{
129
131
132
133
134 return 0;
135}
int(* stat)(VNode *fn, struct stat *sb)
VNode * VFS_Lookup(const char *path)
◆ VFS_Write()
VFS_Write –
Write from a vnode.
- Parameters
-
[in] | fn | VNode to write to. |
[in] | buf | Buffer to read the data from. |
[in] | off | File offset in bytes. |
[in] | len | Length to read in bytes. |
- Returns
- Return status
Definition at line 198 of file vfs.c.
199{
201}
int(* write)(VNode *fn, void *buf, uint64_t off, uint64_t len)