mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-31 22:48:21 +00:00
vfs: getdirent
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <string.h>
|
||||
#include <kernel/devman.h>
|
||||
#include <arch/spinlock.h>
|
||||
#include <dirent.h>
|
||||
|
||||
dirnode_t* vfsroot;
|
||||
hashtable fsfuncs;
|
||||
@@ -134,6 +135,27 @@ int vfs_close(vnode_t* node){
|
||||
return status;
|
||||
}
|
||||
|
||||
int vfs_getdirent(dirnode_t* node, dent_t* buff, size_t count, uintmax_t offset, size_t* readcount){
|
||||
|
||||
int err = 0;
|
||||
|
||||
spinlock_acquire(&lock);
|
||||
|
||||
|
||||
if(GETTYPE(node->vnode.st.st_mode) != TYPE_DIR){
|
||||
err = ENOTDIR;
|
||||
goto _ret;
|
||||
}
|
||||
|
||||
err = node->vnode.fs->calls->getdirent(node, buff, count, offset, readcount);
|
||||
|
||||
_ret:
|
||||
|
||||
spinlock_release(&lock);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int vfs_open(vnode_t** buff, dirnode_t* ref, char* path){
|
||||
|
||||
vnode_t* node;
|
||||
@@ -375,6 +397,10 @@ int vfs_resolvepath(vnode_t** result, dirnode_t** resultparent, dirnode_t* ref,
|
||||
|
||||
if(resultparent)
|
||||
*resultparent = iterator->vnode.parent;
|
||||
|
||||
if(GETTYPE(iterator->vnode.st.st_mode) == TYPE_DIR)
|
||||
iterator = mountpoint(iterator);
|
||||
|
||||
*result = (vnode_t*)iterator;
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user