mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 23:18:21 +00:00
syscalls: stat: make return values sane and fix check
This commit is contained in:
@@ -9,9 +9,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
syscallret syscall_stat(const char* path, stat* st){
|
syscallret syscall_stat(const char* path, stat* st){
|
||||||
|
|
||||||
syscallret retv;
|
syscallret retv;
|
||||||
retv.ret = -1;
|
retv.ret = -1;
|
||||||
|
|
||||||
if(st > USER_SPACE_END || path > USER_SPACE_END){
|
if(st > USER_SPACE_END || path > USER_SPACE_END){
|
||||||
retv.errno = EFAULT;
|
retv.errno = EFAULT;
|
||||||
return retv;
|
return retv;
|
||||||
@@ -19,7 +19,7 @@ syscallret syscall_stat(const char* path, stat* st){
|
|||||||
|
|
||||||
char* kpath = alloc(strlen(path)); // XXX use proper user strlen func
|
char* kpath = alloc(strlen(path)); // XXX use proper user strlen func
|
||||||
|
|
||||||
if(!path){
|
if(!kpath){
|
||||||
retv.errno = ENOMEM;
|
retv.errno = ENOMEM;
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,7 @@ syscallret syscall_stat(const char* path, stat* st){
|
|||||||
|
|
||||||
int ret = vfs_open(&file, *kpath == '/' ? proc->root : proc->cwd, kpath);
|
int ret = vfs_open(&file, *kpath == '/' ? proc->root : proc->cwd, kpath);
|
||||||
|
|
||||||
|
|
||||||
if(ret){
|
if(ret){
|
||||||
retv.errno = ret;
|
retv.errno = ret;
|
||||||
goto _ret;
|
goto _ret;
|
||||||
@@ -43,6 +44,8 @@ syscallret syscall_stat(const char* path, stat* st){
|
|||||||
|
|
||||||
memcpy(st, &stbuff, sizeof(stat)); // XXX use user memcpy
|
memcpy(st, &stbuff, sizeof(stat)); // XXX use user memcpy
|
||||||
|
|
||||||
|
retv.ret = 0;
|
||||||
|
retv.errno = 0;
|
||||||
_ret:
|
_ret:
|
||||||
free(kpath);
|
free(kpath);
|
||||||
return retv;
|
return retv;
|
||||||
|
|||||||
Reference in New Issue
Block a user