- minor optimization in syscall.c
This commit is contained in:
parent
9c7b565344
commit
d03afaf36f
1 changed files with 8 additions and 23 deletions
|
@ -26,13 +26,6 @@
|
|||
#include <metalsvm/spinlock.h>
|
||||
#include <metalsvm/time.h>
|
||||
|
||||
|
||||
static int sys_write(int fd, const char *buf, size_t len)
|
||||
{
|
||||
return write_fs(&(per_core(current_task)->fildes_table[fd]),
|
||||
(uint8_t*)buf, len);
|
||||
}
|
||||
|
||||
static int sys_open(const char* name, int flags, int mode)
|
||||
{
|
||||
int fd, check;
|
||||
|
@ -41,24 +34,20 @@ static int sys_open(const char* name, int flags, int mode)
|
|||
for (fd = 3; fd < NR_OPEN; fd++) {
|
||||
if (per_core(current_task)->fildes_table[fd].node == NULL) {
|
||||
file = &(per_core(current_task)->fildes_table[fd]);
|
||||
file->offset = 0;
|
||||
file->mode = mode;
|
||||
file->flags = flags;
|
||||
check = open_fs(file, (char*) name);
|
||||
if (check == -EINVAL) {
|
||||
if (check < 0) {
|
||||
/* file doesn't exist! */
|
||||
file->node = NULL;
|
||||
file->offset = 0;
|
||||
file->mode = 0;
|
||||
file->flags = 0;
|
||||
kprintf("Operation not permitted");
|
||||
return -EINVAL;
|
||||
return check;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fd >= NR_OPEN) {
|
||||
kprintf("Unable to create filedescriptor");
|
||||
return -EINVAL;
|
||||
return -EMFILE;
|
||||
}
|
||||
|
||||
return fd;
|
||||
|
@ -75,12 +64,6 @@ static int sys_close(int fd)
|
|||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static int sys_read(int fd, const char *buf, size_t len)
|
||||
{
|
||||
return read_fs(&(per_core(current_task)->fildes_table[fd]),
|
||||
(uint8_t*)buf, len);
|
||||
}
|
||||
|
||||
static int sys_lseek(int fd, off_t pos, int origin)
|
||||
{
|
||||
|
@ -160,7 +143,8 @@ int syscall_handler(uint32_t sys_nr, ...)
|
|||
int fd = va_arg(vl, int);
|
||||
const char* buf = va_arg(vl, const char*);
|
||||
size_t len = va_arg(vl, size_t);
|
||||
ret = sys_write(fd, buf, len);
|
||||
ret = write_fs(&(per_core(current_task)->fildes_table[fd]),
|
||||
(uint8_t*)buf, len);
|
||||
break;
|
||||
}
|
||||
case __NR_open: {
|
||||
|
@ -179,7 +163,8 @@ int syscall_handler(uint32_t sys_nr, ...)
|
|||
int fd = va_arg(vl, int);
|
||||
const char* buf = va_arg(vl, const char*);
|
||||
size_t len = va_arg(vl, size_t);
|
||||
ret = sys_read(fd, buf, len);
|
||||
ret = read_fs(&(per_core(current_task)->fildes_table[fd]),
|
||||
(uint8_t*)buf, len);
|
||||
break;
|
||||
}
|
||||
case __NR_lseek: {
|
||||
|
|
Loading…
Add table
Reference in a new issue