add first steps to realize the system call stat
This commit is contained in:
parent
a00f187a07
commit
b1a968a82c
5 changed files with 24 additions and 1 deletions
|
@ -80,6 +80,7 @@ extern "C" {
|
|||
#define __NR_sendto 27
|
||||
#define __NR_recvfrom 28
|
||||
#define __NR_select 29
|
||||
#define __NR_stat 30
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -229,6 +229,13 @@ int syscall_handler(uint32_t sys_nr, ...)
|
|||
ret = sys_close(fd);
|
||||
break;
|
||||
}
|
||||
case __NR_stat: {
|
||||
const char* name = va_arg(vl, const char*);
|
||||
//struct stat* st = va_arg(vl, struct stat*);
|
||||
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
case __NR_read: {
|
||||
int fd = va_arg(vl, int);
|
||||
const char* buf = va_arg(vl, const char*);
|
||||
|
|
|
@ -69,6 +69,7 @@ extern "C" {
|
|||
#define __NR_sendto 27
|
||||
#define __NR_recvfrom 28
|
||||
#define __NR_select 29
|
||||
#define __NR_stat 30
|
||||
|
||||
#define _STR(token) #token
|
||||
#define _SYSCALLSTR(x) "int $" _STR(x) " "
|
||||
|
|
|
@ -46,12 +46,25 @@
|
|||
#undef errno
|
||||
extern int errno;
|
||||
#include "warning.h"
|
||||
#include "syscall.h"
|
||||
|
||||
int
|
||||
_DEFUN (stat, (file, st),
|
||||
const char *file _AND
|
||||
struct stat *st)
|
||||
{
|
||||
st->st_mode = S_IFCHR;
|
||||
int ret;
|
||||
|
||||
if (!file && ! st) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = SYSCALL2(__NR_stat, file, st);
|
||||
if (ret < 0) {
|
||||
errno = -ret;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ extern "C" {
|
|||
#define __NR_sendto 27
|
||||
#define __NR_recvfrom 28
|
||||
#define __NR_select 29
|
||||
#define __NR_stat 30
|
||||
|
||||
#define _STR(token) #token
|
||||
#define _SYSCALLSTR(x) "int $" _STR(x) " "
|
||||
|
|
Loading…
Add table
Reference in a new issue