[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UNIKRAFT PATCH 06/10] lib/vfscore: Register `chdir` to syscall_shim



Registers `chdir` system call to syscall_shim library.

Signed-off-by: Constantin Raducanu <raducanu.costi@xxxxxxxxx>
---
 lib/vfscore/Makefile.uk   |  1 +
 lib/vfscore/exportsyms.uk |  2 ++
 lib/vfscore/main.c        | 16 ++++++++--------
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index e77818d..5ccc917 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -39,3 +39,4 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += faccessat-4
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fallocate-4
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += chmod-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fchmod-2
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += chdir-1
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index 03a02bb..64ca3f6 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -58,6 +58,8 @@ getcwd
 chown
 chroot
 chdir
+uk_syscall_e_chdir
+uk_syscall_r_chdir
 fstatat
 statfs
 lstat
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index d5ece51..8d074fe 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -1001,7 +1001,7 @@ __do_fchdir(struct vfscore_file *fp, struct task *t)
        return error;
 }
 
-int chdir(const char *pathname)
+UK_SYSCALL_R_DEFINE(int, chdir, const char*, pathname)
 {
        trace_vfs_chdir(pathname);
        struct task *t = main_task;
@@ -1011,29 +1011,29 @@ int chdir(const char *pathname)
 
        error = ENOENT;
        if (pathname == NULL)
-               goto out_errno;
+               goto out_error;
 
        if ((error = task_conv(t, pathname, VREAD, path)) != 0)
-               goto out_errno;
+               goto out_error;
 
        /* Check if directory exits */
        error = sys_open(path, O_DIRECTORY, 0, &fp);
        if (error) {
-               goto out_errno;
+               goto out_error;
        }
 
        error = __do_fchdir(fp, t);
        if (error) {
                fdrop(fp);
-               goto out_errno;
+               goto out_error;
        }
 
        trace_vfs_chdir_ret();
        return 0;
-       out_errno:
-       errno = error;
+
+       out_error:
        trace_vfs_chdir_err(errno);
-       return -1;
+       return -error;
 }
 
 UK_TRACEPOINT(trace_vfs_fchdir, "%d", int);
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.