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

[UNIKRAFT PATCH 06/11] lib/vfscore: Register `rename` to syscall_shim



Registers `rename` system call to syscall_shim library.

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

diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index 56d3e4f..63fc806 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -47,4 +47,5 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup2-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += pwritev-4
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += utimes-2
 UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += mknod-3
-UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rmdir-1
\ No newline at end of file
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rmdir-1
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += rename-2
\ No newline at end of file
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index d615eb8..4a8a4f4 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -144,6 +144,8 @@ fstatfs
 eaccess
 euidaccess
 rename
+uk_syscall_e_rename
+uk_syscall_r_rename
 __xmknod
 __xstat
 __lxstat
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index b0af047..41c81f5 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -932,7 +932,7 @@ UK_TRACEPOINT(trace_vfs_rename, "\"%s\" \"%s\"", const 
char*, const char*);
 UK_TRACEPOINT(trace_vfs_rename_ret, "");
 UK_TRACEPOINT(trace_vfs_rename_err, "%d", int);
 
-int rename(const char *oldpath, const char *newpath)
+UK_SYSCALL_R_DEFINE(int, rename, const char*, oldpath, const char*, newpath)
 {
        trace_vfs_rename(oldpath, newpath);
        struct task *t = main_task;
@@ -942,35 +942,35 @@ int rename(const char *oldpath, const char *newpath)
 
        error = ENOENT;
        if (null_or_empty(oldpath) || null_or_empty(newpath))
-               goto out_errno;
+               goto out_error;
 
        get_last_component(oldpath, src);
        if (!strcmp(src, ".") || !strcmp(src, "..")) {
                error = EINVAL;
-               goto out_errno;
+               goto out_error;
        }
 
        get_last_component(newpath, dest);
        if (!strcmp(dest, ".") || !strcmp(dest, "..")) {
                error = EINVAL;
-               goto out_errno;
+               goto out_error;
        }
 
        if ((error = task_conv(t, oldpath, VREAD, src)) != 0)
-               goto out_errno;
+               goto out_error;
 
        if ((error = task_conv(t, newpath, VWRITE, dest)) != 0)
-               goto out_errno;
+               goto out_error;
 
        error = sys_rename(src, dest);
        if (error)
-               goto out_errno;
+               goto out_error;
        trace_vfs_rename_ret();
        return 0;
-       out_errno:
+
+       out_error:
        trace_vfs_rename_err(error);
-       errno = error;
-       return -1;
+       return -error;
 }
 
 UK_TRACEPOINT(trace_vfs_chdir, "\"%s\"", const char*);
-- 
2.17.1




 


Rackspace

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