-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvfs.c
96 lines (82 loc) · 1.62 KB
/
vfs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
*
*
* VFS subsystem.
*
* Adapter for filesystems and file API.
*
*/
#include <type.h>
struct vnode_buf {
;
};
struct vnode {
int refcnt;
struct vnode_buf;
char path[];
};
struct stat {
int perm; // Unix style 4-octet permission
int type; // Indicates file type.
int dev;
int size;
};
struct dirent {
int a;
char name[];
};
struct dir {
struct dirent *subs;
};
struct mount;
struct backend {
enum {
BACKEND_MEM,
BACKEND_DEV,
BACKEND_FILE,
BACKEND_BIND,
BACKEND_MOUNT,
} type;
union {
void *ptr; //In-Memory storage
int dev; //Device backend
char *name; // File backed mount or mount
struct mount *mount; //Mount reference
} backend;
};
struct mount {
//Mountpoint in absolute path.
char *path;
//Config
int flag;
struct backend backend;
void *config; //FS-specific config
//Operations callbacks
int (*open)(void *config,char *path);
int (*close)(int handle);
struct dir (*read_dir)(void *config,char *path);
};
struct fs {
//Pointers to function to mount.NULL refers to un-implemented funcs.
struct mount *(*mount_from_mem)(int from,struct mount *m);
struct mount *(*mount_dev)(int dev,struct mount *m);
struct mount *(*mount_file)(char *path,struct mount *m);
struct mount *(*mount_bind)(char *path,struct mount *m);
struct mount *(*mount_ref)(struct mount *from,struct mount *m);
//Generic umount. If this function is NULL,de-register mount info,no more operations needed.
int *(*umount)(struct mount *m);
struct fs *next;
char name[];
};
void parse_path(char *path)
{
;
}
int open(const char *pathname,int mode,struct file *file)
{
;
}
void close(struct file *file)
{
;
}