aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Schmidt <colins@eecs.berkeley.edu>2016-01-18 23:16:24 -0800
committerColin Schmidt <colins@eecs.berkeley.edu>2016-01-18 23:17:07 -0800
commit676c953b798e33022a8a63a55f2c65af43442cb4 (patch)
treed91a472d4ee45ae91881891c093a6c7503a9b6cd
parent85ae17aa149b9ea114bdd70cc30ea7e73813fb48 (diff)
downloadriscv-pk-676c953b798e33022a8a63a55f2c65af43442cb4.zip
riscv-pk-676c953b798e33022a8a63a55f2c65af43442cb4.tar.gz
riscv-pk-676c953b798e33022a8a63a55f2c65af43442cb4.tar.bz2
add renameat syscall
-rw-r--r--pk/syscall.c13
-rw-r--r--pk/syscall.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/pk/syscall.c b/pk/syscall.c
index 2d96282..87b77ee 100644
--- a/pk/syscall.c
+++ b/pk/syscall.c
@@ -137,6 +137,18 @@ int sys_close(int fd)
return ret;
}
+int sys_renameat(int old_fd, const char *old_path, int new_fd, const char *new_path) {
+ int old_kfd = at_kfd(old_fd);
+ int new_kfd = at_kfd(new_fd);
+ if(old_kfd != -1 && new_kfd != -1) {
+ size_t old_size = strlen(old_path)+1;
+ size_t new_size = strlen(new_path)+1;
+ return frontend_syscall(SYS_renameat, old_kfd, (uintptr_t)old_path, old_size,
+ new_kfd, (uintptr_t)new_path, new_size, 0);
+ }
+ return -EBADF;
+}
+
int sys_fstat(int fd, void* st)
{
int r = -EBADF;
@@ -442,6 +454,7 @@ long do_syscall(long a0, long a1, long a2, long a3, long a4, long a5, unsigned l
[SYS_linkat] = sys_linkat,
[SYS_unlinkat] = sys_unlinkat,
[SYS_mkdirat] = sys_mkdirat,
+ [SYS_renameat] = sys_renameat,
[SYS_getcwd] = sys_getcwd,
[SYS_brk] = sys_brk,
[SYS_uname] = sys_uname,
diff --git a/pk/syscall.h b/pk/syscall.h
index bed30e9..c1f3d8a 100644
--- a/pk/syscall.h
+++ b/pk/syscall.h
@@ -16,6 +16,7 @@
#define SYS_linkat 37
#define SYS_unlinkat 35
#define SYS_mkdirat 34
+#define SYS_renameat 38
#define SYS_chdir 49
#define SYS_getcwd 17
#define SYS_fstat 80