diff options
author | kaashoek <kaashoek> | 2006-08-12 04:33:50 +0000 |
---|---|---|
committer | kaashoek <kaashoek> | 2006-08-12 04:33:50 +0000 |
commit | 1f544842ceb5af73b1f2b13222d72dd4ad7cd08a (patch) | |
tree | 49ad1096c0ad43c591c493166ff752a3e7cfd7cd /syscall.c | |
parent | 0633b9715e106ac97fafcf3a68c06da1f0cf873a (diff) | |
download | xv6-labs-1f544842ceb5af73b1f2b13222d72dd4ad7cd08a.tar.gz xv6-labs-1f544842ceb5af73b1f2b13222d72dd4ad7cd08a.tar.bz2 xv6-labs-1f544842ceb5af73b1f2b13222d72dd4ad7cd08a.zip |
fstat
primitive ls
Diffstat (limited to 'syscall.c')
-rw-r--r-- | syscall.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -1,4 +1,5 @@ #include "types.h" +#include "stat.h" #include "param.h" #include "mmu.h" #include "proc.h" @@ -334,6 +335,28 @@ sys_unlink(void) return r; } + +int +sys_fstat(void) +{ + struct proc *cp = curproc[cpu()]; + uint fd, addr; + int r; + + if(fetcharg(0, &fd) < 0) + return -1; + if(fetcharg(1, &addr) < 0) + return -1; + if(fd < 0 || fd >= NOFILE) + return -1; + if(cp->fds[fd] == 0) + return -1; + if(addr + sizeof(struct stat) > cp->sz) + return -1; + r = fd_stat (cp->fds[fd], (struct stat *)(cp->mem + addr)); + return r; +} + int sys_exec(void) { @@ -570,6 +593,9 @@ syscall(void) case SYS_unlink: ret = sys_unlink(); break; + case SYS_fstat: + ret = sys_fstat(); + break; default: cprintf("unknown sys call %d\n", num); // XXX fault |