vfs: getdirent

This commit is contained in:
Matheus
2022-09-24 17:13:03 -03:00
parent ad8ec070be
commit 943e7abf80
5 changed files with 108 additions and 4 deletions
+24
View File
@@ -0,0 +1,24 @@
#ifndef _DIRENT_H_INCLUDE
#define _DIRENT_H_INCLUDE
#include <sys/types.h>
#define DT_UNKNOWN 0
#define DT_FIFO 1
#define DT_CHR 2
#define DT_DIR 4
#define DT_BLK 6
#define DT_REG 8
#define DT_LNK 10
#define DT_SOCK 12
#define DT_WHT 14
typedef struct {
ino_t d_ino;
off_t d_off;
unsigned short d_reclen;
unsigned char d_type;
char d_name[1024];
} dent_t;
#endif
+4
View File
@@ -4,6 +4,7 @@
#include <sys/stat.h>
#include <hashtable.h>
#include <errno.h>
#include <dirent.h>
struct _vnode_t;
struct _fscalls_t;
@@ -56,6 +57,8 @@ typedef struct _fscalls_t {
int (*write)(int* error, vnode_t* node, void* buff, size_t count, size_t offset);
// read from a file
int (*read)(int* error, vnode_t* node, void* buff, size_t count, size_t offset);
// get dir ents
int (*getdirent)(dirnode_t* node, dent_t* buff, size_t count, uintmax_t offset, size_t* readcount);
} fscalls_t;
@@ -68,6 +71,7 @@ int vfs_create(dirnode_t* ref, char* path, mode_t mode);
int vfs_write(int* error, vnode_t* node, void* buff, size_t count, size_t offset);
int vfs_read(int* error, vnode_t* node, void* buff, size_t count, size_t offset);
int vfs_isatty(vnode_t* node);
int vfs_getdirent(dirnode_t* node, dent_t* buff, size_t count, uintmax_t offset, size_t* readcount);
void vfs_init();
dirnode_t* vfs_root();