mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
vfs: expect fd argument to a few calls
This commit is contained in:
+9
-2
@@ -9,6 +9,7 @@
|
|||||||
#include <kernel/pipe.h>
|
#include <kernel/pipe.h>
|
||||||
#include <arch/timekeeper.h>
|
#include <arch/timekeeper.h>
|
||||||
#include <arch/cls.h>
|
#include <arch/cls.h>
|
||||||
|
#include <kernel/fd.h>
|
||||||
|
|
||||||
#define VFS_MAX_LOOP 5
|
#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);
|
int type = GETTYPE(node->st.st_mode);
|
||||||
|
|
||||||
if(type == TYPE_SOCKET)
|
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){
|
if(type == TYPE_FIFO){
|
||||||
return pipe_read(node->objdata, buff, count, error);
|
return pipe_read(node->objdata, buff, count, error);
|
||||||
|
|||||||
@@ -13,5 +13,5 @@ typedef unsigned socklen_t;
|
|||||||
|
|
||||||
int unsocket_new(struct _socket_t** returnptr, int type, int protocol);
|
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_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
|
#endif
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ int vfs_close(vnode_t* node);
|
|||||||
int vfs_mkdir(dirnode_t* ref, char* path, mode_t mode);
|
int vfs_mkdir(dirnode_t* ref, char* path, mode_t mode);
|
||||||
int vfs_create(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_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_isatty(vnode_t* node);
|
||||||
int vfs_getdirent(dirnode_t* node, dent_t* buff, size_t count, uintmax_t offset, size_t* readcount);
|
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);
|
int vfs_ioctl(vnode_t* node, unsigned long request, void* arg, int* result);
|
||||||
|
|||||||
+5
-5
@@ -58,7 +58,7 @@ static int load(vnode_t* node, elf_ph64 ph){
|
|||||||
|
|
||||||
int err = 0;
|
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)
|
if(err)
|
||||||
return 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;
|
elf_ph64 phbuff;
|
||||||
|
|
||||||
int err = 0;
|
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)
|
if(err)
|
||||||
return 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){
|
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)
|
if(err)
|
||||||
return err;
|
return err;
|
||||||
@@ -226,7 +226,7 @@ int elf_load(thread_t* thread, vnode_t* node, char** argv, char** env, void** st
|
|||||||
if(err)
|
if(err)
|
||||||
return 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)
|
if(err)
|
||||||
goto _interpfail;
|
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){
|
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)
|
if(err)
|
||||||
goto _interpfail;
|
goto _interpfail;
|
||||||
|
|||||||
@@ -36,9 +36,7 @@ syscallret syscall_read(int ifd, void* buff, size_t count){
|
|||||||
return retv;
|
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){
|
if(err){
|
||||||
fd_release(fd);
|
fd_release(fd);
|
||||||
|
|||||||
Reference in New Issue
Block a user