summaryrefslogtreecommitdiff
path: root/syscall.c
diff options
context:
space:
mode:
authorkaashoek <kaashoek>2006-08-12 04:33:50 +0000
committerkaashoek <kaashoek>2006-08-12 04:33:50 +0000
commit1f544842ceb5af73b1f2b13222d72dd4ad7cd08a (patch)
tree49ad1096c0ad43c591c493166ff752a3e7cfd7cd /syscall.c
parent0633b9715e106ac97fafcf3a68c06da1f0cf873a (diff)
downloadxv6-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.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/syscall.c b/syscall.c
index dfd86c4..0f90bd6 100644
--- a/syscall.c
+++ b/syscall.c
@@ -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