Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat Simplify dup3 emulation to call dodup() directly ...
details: https://anonhg.NetBSD.org/src/rev/91a19cb4b4f9
branches: trunk
changeset: 329288:91a19cb4b4f9
user: njoly <njoly%NetBSD.org@localhost>
date: Sun May 18 09:30:00 2014 +0000
description:
Simplify dup3 emulation to call dodup() directly instead of
sys_dup2()+fd_set_exclose(). While here, add some error conditions.
diffstat:
sys/compat/linux/common/linux_file.c | 18 ++++++++++--------
sys/compat/linux32/common/linux32_unistd.c | 16 +++++-----------
2 files changed, 15 insertions(+), 19 deletions(-)
diffs (82 lines):
diff -r 596fd613721d -r 91a19cb4b4f9 sys/compat/linux/common/linux_file.c
--- a/sys/compat/linux/common/linux_file.c Sun May 18 00:33:20 2014 +0000
+++ b/sys/compat/linux/common/linux_file.c Sun May 18 09:30:00 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_file.c,v 1.110 2014/05/06 13:21:50 njoly Exp $ */
+/* $NetBSD: linux_file.c,v 1.111 2014/05/18 09:30:00 njoly Exp $ */
/*-
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.110 2014/05/06 13:21:50 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.111 2014/05/18 09:30:00 njoly Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -784,14 +784,16 @@
syscallarg(int) to;
syscallarg(int) flags;
} */
- int error;
- if ((error = sys_dup2(l, (const struct sys_dup2_args *)uap, retval)))
- return error;
+ int flags;
- if (SCARG(uap, flags) & LINUX_O_CLOEXEC)
- fd_set_exclose(l, SCARG(uap, to), true);
+ flags = linux_to_bsd_ioflags(SCARG(uap, flags));
+ if ((flags & ~O_CLOEXEC) != 0)
+ return EINVAL;
- return 0;
+ if (SCARG(uap, from) == SCARG(uap, to))
+ return EINVAL;
+
+ return dodup(l, SCARG(uap, from), SCARG(uap, to), flags, retval);
}
diff -r 596fd613721d -r 91a19cb4b4f9 sys/compat/linux32/common/linux32_unistd.c
--- a/sys/compat/linux32/common/linux32_unistd.c Sun May 18 00:33:20 2014 +0000
+++ b/sys/compat/linux32/common/linux32_unistd.c Sun May 18 09:30:00 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_unistd.c,v 1.37 2014/05/04 10:08:53 njoly Exp $ */
+/* $NetBSD: linux32_unistd.c,v 1.38 2014/05/18 09:30:00 njoly Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.37 2014/05/04 10:08:53 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.38 2014/05/18 09:30:00 njoly Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -293,19 +293,13 @@
syscallarg(int) to;
syscallarg(int) flags;
} */
- struct sys_dup2_args ua;
- int error;
+ struct linux_sys_dup3_args ua;
NETBSD32TO64_UAP(from);
NETBSD32TO64_UAP(to);
-
- if ((error = sys_dup2(l, &ua, retval)))
- return error;
+ NETBSD32TO64_UAP(flags);
- if (SCARG(uap, flags) & LINUX_O_CLOEXEC)
- fd_set_exclose(l, SCARG(uap, to), true);
-
- return 0;
+ return linux_sys_dup3(l, &ua, retval);
}
Home |
Main Index |
Thread Index |
Old Index