minor optimizations in syscall.c

This commit is contained in:
Marian Ohligs 2011-09-28 17:20:22 +02:00
parent 675c47f1b3
commit acc3796cc1

View file

@ -49,6 +49,8 @@ static int get_fildes(void)
for (fd = 0; fd < NR_OPEN; fd++) {
if (curr_task->fildes_table[fd].node == NULL) {
/* Init Filedescriptor */
memset(curr_task->fildes_table + fd, 0x00, sizeof(fildes_t));
return fd;
}
}
@ -68,7 +70,6 @@ static int sys_open(const char* name, int flags, int mode)
return fd;
file = &(per_core(current_task)->fildes_table[fd]);
file->offset = 0;
file->mode = mode;
file->flags = flags;
@ -106,7 +107,7 @@ static int sys_stat(const char* name, struct stat* st) {
return -EINVAL;
st->st_dev = 0; /* ID of device containing file */
st->st_ino = 0; /* inode number */
st->st_ino = 0; /* inode number */
st->st_mode = node->mask; /* protection */
st->st_nlink = 0; /* number of hard links */
st->st_uid = node->uid; /* user ID of owner */
@ -138,8 +139,6 @@ static int sys_socket(int domain, int type, int protocol)
file = &(per_core(current_task)->fildes_table[fd]);
file->offset = lwip_socket(domain, type, protocol);
file->mode = 0;
file->flags = 0;
file->node = findnode_fs("/dev/socket");
return fd;
@ -160,8 +159,6 @@ static int sys_accept(int s, struct sockaddr* addr, socklen_t* addrlen)
file = &(per_core(current_task)->fildes_table[fd]);
file->offset = lwip_accept(s, addr, addrlen);
file->mode = 0;
file->flags = 0;
file->node = findnode_fs("/dev/socket");
return fd;
@ -172,17 +169,13 @@ static int sys_accept(int s, struct sockaddr* addr, socklen_t* addrlen)
static int sys_close(int fd)
{
fildes_t* file;
task_t* curr_task = per_core(current_task);
if (BUILTIN_EXPECT(fd >= NR_OPEN, 0))
return -EINVAL;
file = &(per_core(current_task)->fildes_table[fd]);
close_fs(file);
file->node = NULL;
file->offset = 0;
file->mode = 0;
file->flags = 0;
close_fs(&(curr_task->fildes_table[fd]));
memset(curr_task->fildes_table + fd, 0x00, sizeof(fildes_t));
return 0;
}