Module Name: src
Committed By: njoly
Date: Sun May 18 09:30:00 UTC 2014
Modified Files:
src/sys/compat/linux/common: linux_file.c
src/sys/compat/linux32/common: linux32_unistd.c
Log Message:
Simplify dup3 emulation to call dodup() directly instead of
sys_dup2()+fd_set_exclose(). While here, add some error conditions.
To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/compat/linux/common/linux_file.c
cvs rdiff -u -r1.37 -r1.38 src/sys/compat/linux32/common/linux32_unistd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/compat/linux/common/linux_file.c
diff -u src/sys/compat/linux/common/linux_file.c:1.110 src/sys/compat/linux/common/linux_file.c:1.111
--- src/sys/compat/linux/common/linux_file.c:1.110 Tue May 6 13:21:50 2014
+++ src/sys/compat/linux/common/linux_file.c Sun May 18 09:30:00 2014
@@ -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 @@ linux_sys_dup3(struct lwp *l, const stru
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);
}
Index: src/sys/compat/linux32/common/linux32_unistd.c
diff -u src/sys/compat/linux32/common/linux32_unistd.c:1.37 src/sys/compat/linux32/common/linux32_unistd.c:1.38
--- src/sys/compat/linux32/common/linux32_unistd.c:1.37 Sun May 4 10:08:53 2014
+++ src/sys/compat/linux32/common/linux32_unistd.c Sun May 18 09:30:00 2014
@@ -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 @@ linux32_sys_dup3(struct lwp *l, const st
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);
+ NETBSD32TO64_UAP(flags);
- if ((error = sys_dup2(l, &ua, retval)))
- return error;
-
- if (SCARG(uap, flags) & LINUX_O_CLOEXEC)
- fd_set_exclose(l, SCARG(uap, to), true);
-
- return 0;
+ return linux_sys_dup3(l, &ua, retval);
}