aboutsummaryrefslogtreecommitdiff
path: root/pk
diff options
context:
space:
mode:
authorhuaixv <44743118+huaixv@users.noreply.github.com>2021-03-26 13:17:35 +0800
committerAndrew Waterman <andrew@sifive.com>2021-03-25 22:20:58 -0700
commitb7f64fe5584094a6fe65d94d5e2382ff9289cbda (patch)
tree0c88526e9d294f56e514ee31e692a0ad6b94e413 /pk
parent62bb5daea5ef014616b00a63c106afdd07e68ffd (diff)
downloadpk-b7f64fe5584094a6fe65d94d5e2382ff9289cbda.zip
pk-b7f64fe5584094a6fe65d94d5e2382ff9289cbda.tar.gz
pk-b7f64fe5584094a6fe65d94d5e2382ff9289cbda.tar.bz2
Add `statx` syscall (#234)
Diffstat (limited to 'pk')
-rw-r--r--pk/frontend.h2
-rw-r--r--pk/syscall.c20
-rw-r--r--pk/syscall.h1
3 files changed, 23 insertions, 0 deletions
diff --git a/pk/frontend.h b/pk/frontend.h
index 1a6be61..ad51109 100644
--- a/pk/frontend.h
+++ b/pk/frontend.h
@@ -32,4 +32,6 @@ struct frontend_stat {
uint32_t __unused5;
};
+#define FRONTEND_STATX_SIZE 256
+
#endif
diff --git a/pk/syscall.c b/pk/syscall.c
index a5e12f2..e6916a2 100644
--- a/pk/syscall.c
+++ b/pk/syscall.c
@@ -239,6 +239,25 @@ long sys_stat(const char* name, void* st)
return sys_fstatat(AT_FDCWD, name, st, 0);
}
+long sys_statx(int dirfd, const char* name, int flags, unsigned int mask, void * st)
+{
+ int kfd = at_kfd(dirfd);
+ if (kfd != -1) {
+ char buf[FRONTEND_STATX_SIZE];
+
+ char kname[MAX_BUF];
+ if (!strcpy_from_user(kname, name, MAX_BUF))
+ return -ENAMETOOLONG;
+
+ size_t name_size = strlen(kname)+1;
+
+ long ret = frontend_syscall(SYS_statx, kfd, kva2pa(kname), name_size, flags, mask, kva2pa(&buf), 0);
+ memcpy_to_user(st, &buf, sizeof(buf));
+ return ret;
+ }
+ return -EBADF;
+}
+
long sys_faccessat(int dirfd, const char *name, int mode)
{
int kfd = at_kfd(dirfd);
@@ -451,6 +470,7 @@ long do_syscall(long a0, long a1, long a2, long a3, long a4, long a5, unsigned l
[SYS_openat] = sys_openat,
[SYS_close] = sys_close,
[SYS_fstat] = sys_fstat,
+ [SYS_statx] = sys_statx,
[SYS_lseek] = sys_lseek,
[SYS_fstatat] = sys_fstatat,
[SYS_linkat] = sys_linkat,
diff --git a/pk/syscall.h b/pk/syscall.h
index 60355ae..9fcc551 100644
--- a/pk/syscall.h
+++ b/pk/syscall.h
@@ -54,6 +54,7 @@
#define SYS_set_tid_address 96
#define SYS_set_robust_list 99
#define SYS_madvise 233
+#define SYS_statx 291
#define OLD_SYSCALL_THRESHOLD 1024
#define SYS_open 1024