fd: new abstraction

This commit is contained in:
Matheus
2022-09-18 16:21:19 -03:00
parent 73a8584a72
commit 41d6e7230e
11 changed files with 216 additions and 151 deletions
+16 -1
View File
@@ -29,14 +29,29 @@
#define O_RSYNC 04010000
#define O_TMPFILE 020000000
#include <stdint.h>
#include <stddef.h>
typedef struct {
uintmax_t refcount;
vnode_t* node;
off_t offset;
int flags;
int lock;
mode_t mode;
} fd_t;
typedef struct {
int lock;
size_t fdcount;
uintmax_t firstfreefd;
fd_t** fd;
} fdtable_t;
int fd_alloc(fdtable_t* fdtable, fd_t** fd, int* ifd);
int fd_free(fdtable_t* fdtable, int ifd);
int fd_access(fdtable_t* fdtable, fd_t** fd, int ifd);
int fd_release(fd_t* fd);
int fd_tableinit(fdtable_t* fdtable);
#endif
+1 -4
View File
@@ -46,10 +46,7 @@ typedef struct _proc_t{
pid_t pid;
gid_t gid;
uid_t uid;
fd_t* fds;
int fdlock;
size_t fdcount;
off_t firstfreefd;
fdtable_t fdtable;
thread_t** threads;
size_t threadcount;
dirnode_t* root;