diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-09-14 12:46:54 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-09-14 12:46:54 -0700 |
commit | 4a37572381acc146da66720f1f8073772f2c9119 (patch) | |
tree | eb46aded5af6936491162048160f947ccc91051b /pk/syscall.c | |
parent | 18efb61dc4fa2f20ce54cafcf12b12545751dd43 (diff) | |
download | pk-4a37572381acc146da66720f1f8073772f2c9119.zip pk-4a37572381acc146da66720f1f8073772f2c9119.tar.gz pk-4a37572381acc146da66720f1f8073772f2c9119.tar.bz2 |
Add ftruncate syscall
Diffstat (limited to 'pk/syscall.c')
-rw-r--r-- | pk/syscall.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pk/syscall.c b/pk/syscall.c index e80535b..2d96282 100644 --- a/pk/syscall.c +++ b/pk/syscall.c @@ -165,6 +165,20 @@ int sys_fcntl(int fd, int cmd, int arg) return r; } +int sys_ftruncate(int fd, off_t len) +{ + int r = -EBADF; + file_t* f = file_get(fd); + + if (f) + { + r = file_truncate(f, len); + file_decref(f); + } + + return r; +} + int sys_dup(int fd) { int r = -EBADF; @@ -446,6 +460,7 @@ long do_syscall(long a0, long a1, long a2, long a3, long a4, long a5, unsigned l [SYS_writev] = sys_writev, [SYS_faccessat] = sys_faccessat, [SYS_fcntl] = sys_fcntl, + [SYS_ftruncate] = sys_ftruncate, [SYS_getdents] = sys_getdents, [SYS_dup] = sys_dup, [SYS_readlinkat] = sys_stub_nosys, |