VFS: dot entries

This commit is contained in:
Matheus
2022-08-28 16:28:11 -03:00
parent 54d9c3d809
commit 56bee8be77
4 changed files with 11 additions and 11 deletions
+1 -2
View File
@@ -10,13 +10,12 @@ static fs_t* fs;
static int devfs_mount(dirnode_t* mountpoint, vnode_t* device, int mountflags, void* fsinfo){
dirnode_t* node = vfs_newdirnode(mountpoint->vnode.name, fs, 0);
dirnode_t* node = vfs_newdirnode(mountpoint->vnode.name, fs, NULL, mountpoint->vnode.parent);
if(!node)
return ENOMEM;
mountpoint->mount = node;
node->vnode.parent = mountpoint->vnode.parent;
return 0;
}
+2 -4
View File
@@ -12,7 +12,7 @@ static int tmpfs_mount(dirnode_t* mountpoint, vnode_t* device, int mountflags, v
if(!desc)
return ENOMEM;
dirnode_t* root = vfs_newdirnode(mountpoint->vnode.name, desc, NULL);
dirnode_t* root = vfs_newdirnode(mountpoint->vnode.name, desc, NULL, mountpoint->vnode.parent);
if(!root){
free(desc);
@@ -21,7 +21,6 @@ static int tmpfs_mount(dirnode_t* mountpoint, vnode_t* device, int mountflags, v
desc->calls = tmpfs_getfuncs();
mountpoint->mount = root;
root->vnode.parent = mountpoint->vnode.parent;
return 0;
}
@@ -74,7 +73,7 @@ static int tmpfs_close(vnode_t* node){return 0;} // nothing to do really
static int tmpfs_mkdir(dirnode_t* parent, char* name, mode_t mode){
dirnode_t* node = vfs_newdirnode(name, parent->vnode.fs, NULL);
dirnode_t* node = vfs_newdirnode(name, parent->vnode.fs, NULL, parent);
if(!node)
return ENOMEM;
@@ -84,7 +83,6 @@ static int tmpfs_mkdir(dirnode_t* parent, char* name, mode_t mode){
return ENOMEM;
}
node->vnode.parent = parent;
stat* st = &node->vnode.st;
st->st_mode = MAKETYPE(TYPE_DIR) | GETMODE(mode);
st->st_blksize = PAGE_SIZE;
+7 -4
View File
@@ -276,7 +276,7 @@ vnode_t* vfs_newnode(char* name, fs_t* fs, void* fsdata){
}
dirnode_t* vfs_newdirnode(char* name, fs_t* fs, void* fsdata){
dirnode_t* vfs_newdirnode(char* name, fs_t* fs, void* fsdata, dirnode_t* parent){
dirnode_t* node = alloc(sizeof(dirnode_t));
if(!node) return NULL;
@@ -289,12 +289,15 @@ dirnode_t* vfs_newdirnode(char* name, fs_t* fs, void* fsdata){
return NULL;
}
if(!hashtable_init(&node->children, 10)){ // add more here later
if(!hashtable_init(&node->children, 25)){ // add more here later
free(vnode->name);
free(node);
return NULL;
}
hashtable_insert(&node->children, ".", node);
hashtable_insert(&node->children, "..", parent);
vnode->st.st_mode = MAKETYPE(TYPE_DIR);
vnode->fs = fs;
vnode->fsdata = fsdata;
@@ -401,7 +404,7 @@ void vfs_releasenode(vnode_t* node){
void vfs_init(){
printf("Creating a fake root for the VFS\n");
vfsroot = vfs_newdirnode("/", NULL, NULL);
vfsroot = vfs_newdirnode("/", NULL, NULL, NULL);
hashtable_init(&fsfuncs, 10);
+1 -1
View File
@@ -74,7 +74,7 @@ dirnode_t* vfs_root();
void vfs_acquirenode(vnode_t* node);
void vfs_releasenode(vnode_t* node);
vnode_t* vfs_newnode(char* name, fs_t* fs, void* fsdata);
dirnode_t* vfs_newdirnode(char* name, fs_t* fs, void* fsdata);
dirnode_t* vfs_newdirnode(char* name, fs_t* fs, void* fsdata, dirnode_t* parent);
void vfs_destroynode(vnode_t* node);
int vfs_resolvepath(vnode_t** result, dirnode_t** parent, dirnode_t* ref, char* path, char* name);