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
| int tmpfs_setup_mount(struct filesystem* fs, struct mount* mount) {
mount->fs = fs;
mount->root = tmpfs_create_dentry(NULL, "/", DIRECTORY);
return 0;
}
struct dentry* tmpfs_create_dentry(struct dentry* parent, const char* name, int type) {
struct dentry* dentry = (struct dentry*)kmalloc(sizeof(struct dentry));
strcpy(dentry->name, name);
dentry->parent = parent;
list_head_init(&dentry->list);
list_head_init(&dentry->childs);
if (parent != NULL) {
list_add(&dentry->list, &parent->childs);
}
dentry->vnode = tmpfs_create_vnode(dentry);
dentry->mountpoint = NULL;
dentry->type = type;
return dentry;
}
struct vnode* tmpfs_create_vnode(struct dentry* dentry) {
struct vnode* vnode = (struct vnode*)kmalloc(sizeof(struct vnode));
vnode->dentry = dentry;
vnode->f_ops = tmpfs_f_ops;
vnode->v_ops = tmpfs_v_ops;
return vnode;
}
|