CS350 COS
COS
Loading...
Searching...
No Matches
vfs.h
Go to the documentation of this file.
1
2#ifndef __SYS_VFS_H__
3#define __SYS_VFS_H__
4
5#include <sys/kmem.h>
6#include <sys/stat.h>
7
8typedef struct VFSOp VFSOp;
9typedef struct VNode VNode;
10
11typedef struct VFS {
16 // FS Fields
17 void *fsptr;
21 void *bitmap[16];
23
24typedef struct VNode {
29 // FS Fields
30 void *fsptr;
33} VNode;
34
37
38typedef struct VFSOp {
39 // VFS Operations
40 int (*unmount)(VFS *fs);
41 int (*getroot)(VFS *fs, VNode **dn);
42 // VNode Operations
43 int (*lookup)(VNode *dn, VNode **fn, const char *name);
44 int (*open)(VNode *fn);
45 int (*close)(VNode *fn);
46 int (*stat)(VNode *fn, struct stat *sb);
47 int (*read)(VNode *fn, void *buf, uint64_t off, uint64_t len);
48 int (*write)(VNode *fn, void *buf, uint64_t off, uint64_t len);
49 int (*readdir)(VNode *fn, void *buf, uint64_t len, uint64_t *off);
50} VFSOp;
51
52int VFS_MountRoot(Disk *root);
53VNode *VFS_Lookup(const char *path);
54// XXX: Release/Retain
55int VFS_Stat(const char *path, struct stat *sb);
56int VFS_Open(VNode *fn);
57int VFS_Close(VNode *fn);
58int VFS_Read(VNode *fn, void *buf, uint64_t off, uint64_t len);
59int VFS_Write(VNode *fn, void *buf, uint64_t off, uint64_t len);
60int VFS_ReadDir(VNode *fn, void *buf, uint64_t len, uint64_t *off);
61
62#endif /* __SYS_VFS_H__ */
63
static char buf[4096]
Definition: ethdump.c:10
#define DECLARE_SLAB(_type)
Definition: kmem.h:65
uint64_t len
Definition: multiboot.h:2
Definition: stat.h:5
Definition: disk.h:11
Definition: vfs.h:38
int(* close)(VNode *fn)
Definition: vfs.h:45
int(* open)(VNode *fn)
Definition: vfs.h:44
int(* getroot)(VFS *fs, VNode **dn)
Definition: vfs.h:41
int(* unmount)(VFS *fs)
Definition: vfs.h:40
int(* write)(VNode *fn, void *buf, uint64_t off, uint64_t len)
Definition: vfs.h:48
int(* readdir)(VNode *fn, void *buf, uint64_t len, uint64_t *off)
Definition: vfs.h:49
int(* lookup)(VNode *dn, VNode **fn, const char *name)
Definition: vfs.h:43
int(* read)(VNode *fn, void *buf, uint64_t off, uint64_t len)
Definition: vfs.h:47
unsigned long uint64_t
Definition: types.h:13
Spinlock lock
Definition: vfs.h:27
uint64_t fsval
Definition: vfs.h:31
void * bitmap[16]
Definition: vfs.h:21
int VFS_Stat(const char *path, struct stat *sb)
Definition: vfs.c:124
VFSOp * op
Definition: vfs.h:25
uint64_t refCount
Definition: vfs.h:28
uint64_t blksize
Definition: vfs.h:19
int VFS_Read(VNode *fn, void *buf, uint64_t off, uint64_t len)
Definition: vfs.c:180
Disk * disk
Definition: vfs.h:13
VNode * VFS_Lookup(const char *path)
Definition: vfs.c:63
Disk * disk
Definition: vfs.h:26
VFS * vfs
Definition: vfs.h:32
Spinlock lock
Definition: vfs.h:14
void * fsptr
Definition: vfs.h:30
uint64_t fsval
Definition: vfs.h:18
int VFS_Open(VNode *fn)
Definition: vfs.c:147
VFSOp * op
Definition: vfs.h:12
int VFS_MountRoot(Disk *root)
Definition: vfs.c:36
int VFS_ReadDir(VNode *fn, void *buf, uint64_t len, uint64_t *off)
Definition: vfs.c:216
VNode * root
Definition: vfs.h:20
void * fsptr
Definition: vfs.h:17
int VFS_Write(VNode *fn, void *buf, uint64_t off, uint64_t len)
Definition: vfs.c:198
uint64_t refCount
Definition: vfs.h:15
int VFS_Close(VNode *fn)
Definition: vfs.c:162
Definition: vfs.h:11
Definition: vfs.h:24