|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [UNIKRAFT PATCH 09/10] lib/vfscore: Register `dup3` to syscall_shim
Registers `dup3` 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 | 21 +++++++++++----------
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/lib/vfscore/Makefile.uk b/lib/vfscore/Makefile.uk
index a1570ed..0919de7 100644
--- a/lib/vfscore/Makefile.uk
+++ b/lib/vfscore/Makefile.uk
@@ -42,3 +42,4 @@ UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fchmod-2
UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += chdir-1
UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += fchdir-1
UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup-1
+UK_PROVIDED_SYSCALLS-$(CONFIG_LIBVFSCORE) += dup3-3
diff --git a/lib/vfscore/exportsyms.uk b/lib/vfscore/exportsyms.uk
index e16fa90..ead0d9f 100644
--- a/lib/vfscore/exportsyms.uk
+++ b/lib/vfscore/exportsyms.uk
@@ -48,6 +48,8 @@ uk_syscall_e_dup
uk_syscall_r_dup
dup2
dup3
+uk_syscall_e_dup3
+uk_syscall_r_dup3
sync
vfscore_mount_dump
umount
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 67344f9..dc8f9e2 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -1421,7 +1421,7 @@ UK_TRACEPOINT(trace_vfs_dup3_err, "%d", int);
/*
* Duplicate a file descriptor to a particular value.
*/
-int dup3(int oldfd, int newfd, int flags)
+UK_SYSCALL_R_DEFINE(int, dup3, int, oldfd, int, newfd, int, flags)
{
struct vfscore_file *fp, *fp_new;
int error;
@@ -1433,44 +1433,45 @@ int dup3(int oldfd, int newfd, int flags)
*/
if ((flags & ~O_CLOEXEC) != 0) {
error = EINVAL;
- goto out_errno;
+ goto out_error;
}
if (oldfd == newfd) {
error = EINVAL;
- goto out_errno;
+ goto out_error;
}
error = fget(oldfd, &fp);
if (error)
- goto out_errno;
+ goto out_error;
error = fget(newfd, &fp_new);
if (error == 0) {
/* if newfd is open, then close it */
error = close(newfd);
if (error)
- goto out_errno;
+ goto out_error;
}
error = vfscore_reserve_fd(newfd);
if (error)
- goto out_errno;
+ goto out_error;
error = vfscore_install_fd(newfd, fp);
if (error) {
fdrop(fp);
- goto out_errno;
+ goto out_error;
}
fdrop(fp);
trace_vfs_dup3_ret(newfd);
return newfd;
- out_errno:
+ out_error:
trace_vfs_dup3_err(error);
- errno = error;
- return -1;
+ if(error > 0)
+ return -error;
+ return error;
}
int dup2(int oldfd, int newfd)
--
2.17.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |