Compare commits

..

No commits in common. "b615166373a4316ec73bffe8195e1e6cafae49e4" and "0c04246300b08f83b88ed97bdac362b7ba03b29e" have entirely different histories.

9 changed files with 12 additions and 56 deletions

View File

@ -25,7 +25,6 @@
#define SYS_fstat 20 #define SYS_fstat 20
#define SYS_pstat 21 #define SYS_pstat 21
#define SYS_getdents 22 #define SYS_getdents 22
#define SYS_stat 23
struct stat; struct stat;
struct pstat; struct pstat;
@ -59,4 +58,3 @@ void sys_access(Context* context, const char* path, int amode);
void sys_fstat(Context* context, int fd, struct stat* buf); void sys_fstat(Context* context, int fd, struct stat* buf);
void sys_pstat(Context* context, long pid, struct pstat* buf); void sys_pstat(Context* context, long pid, struct pstat* buf);
void sys_getdents(Context* context, int fd, struct luna_dirent* buf, size_t count); void sys_getdents(Context* context, int fd, struct luna_dirent* buf, size_t count);
void sys_stat(Context* context, const char* path, struct stat* buf);

View File

@ -1,7 +1,6 @@
#include "fs/VFS.h" #include "fs/VFS.h"
#include "interrupts/Context.h" #include "interrupts/Context.h"
#include "std/errno.h" #include "std/errno.h"
#include "std/stdlib.h"
#include "sys/UserMemory.h" #include "sys/UserMemory.h"
#include "thread/Scheduler.h" #include "thread/Scheduler.h"
@ -16,21 +15,6 @@ struct stat // FIXME: This struct is quite stubbed out.
off_t st_size; off_t st_size;
}; };
void do_stat(Context* context, VFS::Node* node, struct stat* buf)
{
struct stat* kstat = obtain_user_ref(buf);
if (!kstat)
{
context->rax = -EFAULT; // FIXME: The manual doesn't say fstat can return EFAULT, but it seems logical here...
return;
}
kstat->st_ino = node->inode;
kstat->st_mode = (mode_t)node->type;
kstat->st_size = node->length;
release_user_ref(kstat);
context->rax = 0;
}
void sys_fstat(Context* context, int fd, struct stat* buf) void sys_fstat(Context* context, int fd, struct stat* buf)
{ {
Task* current_task = Scheduler::current_task(); Task* current_task = Scheduler::current_task();
@ -45,24 +29,16 @@ void sys_fstat(Context* context, int fd, struct stat* buf)
context->rax = -EBADF; context->rax = -EBADF;
return; return;
} }
struct stat* kstat = obtain_user_ref(buf);
if (!kstat)
{
context->rax = -EFAULT; // FIXME: The manual doesn't say fstat can return EFAULT, but it seems logical here...
return;
}
VFS::Node* node = file.node(); VFS::Node* node = file.node();
return do_stat(context, node, buf); kstat->st_ino = node->inode;
} kstat->st_mode = (mode_t)node->type;
kstat->st_size = node->length;
void sys_stat(Context* context, const char* path, struct stat* buf) release_user_ref(kstat);
{ context->rax = 0;
char* kpath = strdup_from_user(path);
if (!kpath)
{
context->rax = -EFAULT;
return;
}
VFS::Node* node = VFS::resolve_path(kpath);
kfree(kpath);
if (!node)
{
context->rax = -ENOENT;
return;
}
return do_stat(context, node, buf);
} }

View File

@ -162,8 +162,6 @@ extern "C"
int remove(const char* pathname); // Not implemented. int remove(const char* pathname); // Not implemented.
FILE* tmpfile(void); // Not implemented.
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -25,9 +25,6 @@ extern "C"
/* Returns information about the file pointed to by fd in buf. */ /* Returns information about the file pointed to by fd in buf. */
int fstat(int fd, struct stat* buf); int fstat(int fd, struct stat* buf);
/* Returns information about the file pointed at path in buf. */
int stat(const char* pathname, struct stat* buf);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -24,6 +24,5 @@
#define SYS_fstat 20 #define SYS_fstat 20
#define SYS_pstat 21 #define SYS_pstat 21
#define SYS_getdents 22 #define SYS_getdents 22
#define SYS_stat 23
#endif #endif

View File

@ -58,10 +58,4 @@ extern "C"
{ {
NOT_IMPLEMENTED("sscanf"); NOT_IMPLEMENTED("sscanf");
} }
FILE* tmpfile()
{
errno = ENOTSUP;
return NULL;
}
} }

View File

@ -13,9 +13,4 @@ extern "C"
{ {
return (int)syscall(SYS_fstat, fd, buf); return (int)syscall(SYS_fstat, fd, buf);
} }
int stat(const char* path, struct stat* buf)
{
return (int)syscall(SYS_stat, path, buf);
}
} }

View File

@ -24,7 +24,6 @@ extern "C" long syscall(long number, ...)
case SYS_munmap: case SYS_munmap:
case SYS_access: case SYS_access:
case SYS_fstat: case SYS_fstat:
case SYS_stat:
case SYS_pstat: case SYS_pstat:
case SYS_open: { case SYS_open: {
arg arg0 = va_arg(ap, arg); arg arg0 = va_arg(ap, arg);