[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [UNIKRAFT PATCH 3/8] lib/vfscore: Register `open` to syscall_shim
Registers `open` system call to syscall_shim library. The signature of the `open` library call is different from signature of the `open` syscall, forcing us to use the macro UK_LLSYSCALL_R_DEFINE. Signed-off-by: Constantin Raducanu <raducanu.costi@xxxxxxxxx> --- lib/vfscore/Makefile.uk | 3 ++- lib/vfscore/exportsyms.uk | 2 ++ lib/vfscore/main.c | 42 ++++++++++++++++++++++----------------- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk index c8451e7..1fe5eb6 100644 --- a/lib/vfscore/Makefile.uk +++ b/lib/vfscore/Makefile.uk @@ -56,4 +56,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += umask-1 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += lstat-2 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += flock-2 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += unlink-1 -UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += stat-2 \ No newline at end of file +UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += stat-2 +UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += open-3 \ No newline at end of file diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk index 3e9642b..7e2f7ea 100644 --- a/lib/vfscore/exportsyms.uk +++ b/lib/vfscore/exportsyms.uk @@ -13,6 +13,8 @@ vfscore_vop_einval vfscore_vop_eperm vfscore_vop_erofs open +uk_syscall_e_open +uk_syscall_r_open creat write uk_syscall_e_write diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c index db190b9..1bbbbd4 100644 --- a/lib/vfscore/main.c +++ b/lib/vfscore/main.c @@ -84,16 +84,8 @@ UK_TRACEPOINT(trace_vfs_open_err, "%d", int); struct task *main_task; /* we only have a single process */ -int open(const char *pathname, int flags, ...) +UK_LLSYSCALL_R_DEFINE(int, open, const char*, pathname, int, flags, mode_t, mode) { - mode_t mode = 0; - if (flags & O_CREAT) { - va_list ap; - va_start(ap, flags); - mode = apply_umask(va_arg(ap, mode_t)); - va_end(ap); - } - trace_vfs_open(pathname, flags, mode); struct task *t = main_task; @@ -117,11 +109,11 @@ int open(const char *pathname, int flags, ...) error = task_conv(t, pathname, acc, path); if (error) - goto out_errno; + goto out_error; error = sys_open(path, flags, mode, &fp); if (error) - goto out_errno; + goto out_error; error = fdalloc(fp, &fd); if (error) @@ -132,10 +124,22 @@ int open(const char *pathname, int flags, ...) out_fput: fdrop(fp); - out_errno: - errno = error; + out_error: trace_vfs_open_err(error); - return -1; + return -error; +} + +int open(const char *pathname, int flags, ...) +{ + mode_t mode = 0; + if (flags & O_CREAT) { + va_list ap; + va_start(ap, flags); + mode = apply_umask(va_arg(ap, mode_t)); + va_end(ap); + } + + return uk_syscall_e_open((long int)pathname, flags, mode); } LFS64(open); @@ -151,7 +155,7 @@ int openat(int dirfd, const char *pathname, int flags, ...) } if (pathname[0] == '/' || dirfd == AT_FDCWD) { - return open(pathname, flags, mode); + return uk_syscall_e_open((long int)pathname, flags, mode); } struct vfscore_file *fp; @@ -172,7 +176,7 @@ int openat(int dirfd, const char *pathname, int flags, ...) strlcat(p, "/", PATH_MAX); strlcat(p, pathname, PATH_MAX); - error = open(p, flags, mode); + error = uk_syscall_e_open((long int)p, flags, mode); vn_unlock(vp); fdrop(fp); @@ -183,7 +187,8 @@ LFS64(openat); int creat(const char *pathname, mode_t mode) { - return open(pathname, O_CREAT|O_WRONLY|O_TRUNC, mode); + return uk_syscall_e_open((long int) pathname, + O_CREAT|O_WRONLY|O_TRUNC, mode); } LFS64(creat); @@ -646,6 +651,7 @@ DIR *opendir(const char *path) { DIR *dir; struct stat st; + mode_t mode = 0; dir = malloc(sizeof(*dir)); if (!dir) { @@ -653,7 +659,7 @@ DIR *opendir(const char *path) goto out_err; } - dir->fd = open(path, O_RDONLY); + dir->fd = uk_syscall_e_open((long int)path, O_RDONLY, mode); if (dir->fd < 0) goto out_free_dir; -- 2.17.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |