vfs: expect fd argument to a few calls

This commit is contained in:
Matheus
2022-10-24 15:40:38 -03:00
parent 72504f3598
commit 763ea89e83
5 changed files with 19 additions and 14 deletions
+10 -3
View File
@@ -9,6 +9,7 @@
#include <kernel/pipe.h>
#include <arch/timekeeper.h>
#include <arch/cls.h>
#include <kernel/fd.h>
#define VFS_MAX_LOOP 5
@@ -148,12 +149,18 @@ int vfs_ioctl(vnode_t* node, unsigned long request, void* arg, int* result){
}
int vfs_read(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, void* fd){
fd_t tmpfd;
if(!fd)
fd = &tmpfd;
int type = GETTYPE(node->st.st_mode);
if(type == TYPE_SOCKET)
return socket_recv(node->objdata, buff, count, 0, error);
return socket_recv(node->objdata, buff, count, 0, error, fd);
if(type == TYPE_FIFO){
return pipe_read(node->objdata, buff, count, error);
@@ -399,7 +406,7 @@ int vfs_link(dirnode_t* ref, vnode_t* link, char* path){
result = parent->vnode.fs->calls->link(parent, link, name);
spinlock_release(&lock);
return result;
+1 -1
View File
@@ -13,5 +13,5 @@ typedef unsigned socklen_t;
int unsocket_new(struct _socket_t** returnptr, int type, int protocol);
int unsocket_bind(struct _socket_t* sock, sockaddr_un* addr, socklen_t addrlen);
int unsocket_send(struct _socket_t* socket, void* buff, socklen_t len, int flags, int* error);
int unsocket_send(struct _socket_t* socket, void* buff, size_t len, int flags, int* error, fd_t* fd);
#endif
+1 -1
View File
@@ -82,7 +82,7 @@ int vfs_close(vnode_t* node);
int vfs_mkdir(dirnode_t* ref, char* path, mode_t mode);
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_read(int* error, vnode_t* node, void* buff, size_t count, size_t offset, void* fd);
int vfs_isatty(vnode_t* node);
int vfs_getdirent(dirnode_t* node, dent_t* buff, size_t count, uintmax_t offset, size_t* readcount);
int vfs_ioctl(vnode_t* node, unsigned long request, void* arg, int* result);
+5 -5
View File
@@ -58,7 +58,7 @@ static int load(vnode_t* node, elf_ph64 ph){
int err = 0;
size_t readc = vfs_read(&err, node, (void*)ph.memaddr, ph.fsize, ph.offset);
size_t readc = vfs_read(&err, node, (void*)ph.memaddr, ph.fsize, ph.offset, NULL);
if(err)
return err;
@@ -165,7 +165,7 @@ int elf_load(thread_t* thread, vnode_t* node, char** argv, char** env, void** st
elf_ph64 phbuff;
int err = 0;
int readc = vfs_read(&err, node, &header, sizeof(elf_header64), 0);
int readc = vfs_read(&err, node, &header, sizeof(elf_header64), 0, NULL);
if(err)
return err;
@@ -189,7 +189,7 @@ int elf_load(thread_t* thread, vnode_t* node, char** argv, char** env, void** st
for(size_t pos = header.ph_pos, ph = 0; ph < header.ph_count; ++ph, pos += header.ph_size){
readc = vfs_read(&err, node, &phbuff, header.ph_size, pos);
readc = vfs_read(&err, node, &phbuff, header.ph_size, pos, NULL);
if(err)
return err;
@@ -226,7 +226,7 @@ int elf_load(thread_t* thread, vnode_t* node, char** argv, char** env, void** st
if(err)
return err;
readc = vfs_read(&err, interfile, &header, sizeof(elf_header64), 0);
readc = vfs_read(&err, interfile, &header, sizeof(elf_header64), 0, NULL);
if(err)
goto _interpfail;
@@ -238,7 +238,7 @@ int elf_load(thread_t* thread, vnode_t* node, char** argv, char** env, void** st
for(size_t pos = header.ph_pos, ph = 0; ph < header.ph_count; ++ph, pos += header.ph_size){
readc = vfs_read(&err, interfile, &phbuff, header.ph_size, pos);
readc = vfs_read(&err, interfile, &phbuff, header.ph_size, pos, NULL);
if(err)
goto _interpfail;
+2 -4
View File
@@ -35,10 +35,8 @@ syscallret syscall_read(int ifd, void* buff, size_t count){
retv.errno = ENOMEM;
return retv;
}
size_t readc = vfs_read(&err, fd->node, kbuff, count, fd->offset);
size_t readc = vfs_read(&err, fd->node, kbuff, count, fd->offset, fd);
if(err){
fd_release(fd);