Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Jan 2016 15:23:54 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r293500 - in stable/10/sys: amd64/linux32 compat/linux i386/linux
Message-ID:  <201601091523.u09FNsoH018153@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Sat Jan  9 15:23:54 2016
New Revision: 293500
URL: https://svnweb.freebsd.org/changeset/base/293500

Log:
  MFC r283391:
  
  To reduce code duplication introduce linux_copyout_rusage() method.
  Use it in linux_wait4() system call and move linux_wait4() to the MI path.
  While here add a prototype for the static bsd_to_linux_rusage().

Modified:
  stable/10/sys/amd64/linux32/linux.h
  stable/10/sys/amd64/linux32/linux32_genassym.c
  stable/10/sys/amd64/linux32/linux32_machdep.c
  stable/10/sys/compat/linux/linux_misc.c
  stable/10/sys/i386/linux/linux.h
  stable/10/sys/i386/linux/linux_machdep.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/amd64/linux32/linux.h
==============================================================================
--- stable/10/sys/amd64/linux32/linux.h	Sat Jan  9 15:22:50 2016	(r293499)
+++ stable/10/sys/amd64/linux32/linux.h	Sat Jan  9 15:23:54 2016	(r293500)
@@ -780,6 +780,7 @@ struct l_iovec32 {
 
 int linux32_copyiniov(struct l_iovec32 *iovp32, l_ulong iovcnt,
 			    struct iovec **iovp, int error);
+int linux_copyout_rusage(struct rusage *ru, void *uaddr);
 
 /* robust futexes */
 struct linux_robust_list {

Modified: stable/10/sys/amd64/linux32/linux32_genassym.c
==============================================================================
--- stable/10/sys/amd64/linux32/linux32_genassym.c	Sat Jan  9 15:22:50 2016	(r293499)
+++ stable/10/sys/amd64/linux32/linux32_genassym.c	Sat Jan  9 15:23:54 2016	(r293500)
@@ -3,6 +3,7 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/assym.h>
+#include <sys/resource.h>
 #include <sys/systm.h>
 
 #include <amd64/linux32/linux.h>

Modified: stable/10/sys/amd64/linux32/linux32_machdep.c
==============================================================================
--- stable/10/sys/amd64/linux32/linux32_machdep.c	Sat Jan  9 15:22:50 2016	(r293499)
+++ stable/10/sys/amd64/linux32/linux32_machdep.c	Sat Jan  9 15:23:54 2016	(r293500)
@@ -72,6 +72,8 @@ __FBSDID("$FreeBSD$");
 #include <compat/linux/linux_util.h>
 #include <compat/linux/linux_emul.h>
 
+static void	bsd_to_linux_rusage(struct rusage *ru, struct l_rusage *lru);
+
 struct l_old_select_argv {
 	l_int		nfds;
 	l_uintptr_t	readfds;
@@ -133,6 +135,16 @@ bsd_to_linux_rusage(struct rusage *ru, s
 }
 
 int
+linux_copyout_rusage(struct rusage *ru, void *uaddr)
+{
+	struct l_rusage lru;
+
+	bsd_to_linux_rusage(ru, &lru);
+
+	return (copyout(&lru, uaddr, sizeof(struct l_rusage)));
+}
+
+int
 linux_execve(struct thread *td, struct linux_execve_args *args)
 {
 	struct image_args eargs;
@@ -907,17 +919,14 @@ linux_settimeofday(struct thread *td, st
 int
 linux_getrusage(struct thread *td, struct linux_getrusage_args *uap)
 {
-	struct l_rusage s32;
 	struct rusage s;
 	int error;
 
 	error = kern_getrusage(td, uap->who, &s);
 	if (error != 0)
 		return (error);
-	if (uap->rusage != NULL) {
-		bsd_to_linux_rusage(&s, &s32);
-		error = copyout(&s32, uap->rusage, sizeof(s32));
-	}
+	if (uap->rusage != NULL)
+		error = linux_copyout_rusage(&s, uap->rusage);
 	return (error);
 }
 
@@ -1023,37 +1032,3 @@ linux_set_thread_area(struct thread *td,
 
 	return (0);
 }
-
-int
-linux_wait4(struct thread *td, struct linux_wait4_args *args)
-{
-	int error, options;
-	struct rusage ru, *rup;
-	struct l_rusage lru;
-
-#ifdef DEBUG
-	if (ldebug(wait4))
-		printf(ARGS(wait4, "%d, %p, %d, %p"),
-		    args->pid, (void *)args->status, args->options,
-		    (void *)args->rusage);
-#endif
-
-	options = (args->options & (WNOHANG | WUNTRACED));
-	/* WLINUXCLONE should be equal to __WCLONE, but we make sure */
-	if (args->options & __WCLONE)
-		options |= WLINUXCLONE;
-
-	if (args->rusage != NULL)
-		rup = &ru;
-	else
-		rup = NULL;
-	error = linux_common_wait(td, args->pid, args->status, options, rup);
-	if (error)
-		return (error);
-	if (args->rusage != NULL) {
-		bsd_to_linux_rusage(rup, &lru);
-		error = copyout(&lru, args->rusage, sizeof(lru));
-	}
-
-	return (error);
-}

Modified: stable/10/sys/compat/linux/linux_misc.c
==============================================================================
--- stable/10/sys/compat/linux/linux_misc.c	Sat Jan  9 15:22:50 2016	(r293499)
+++ stable/10/sys/compat/linux/linux_misc.c	Sat Jan  9 15:23:54 2016	(r293500)
@@ -885,6 +885,35 @@ linux_waitpid(struct thread *td, struct 
 	return (linux_common_wait(td, args->pid, args->status, options, NULL));
 }
 
+int
+linux_wait4(struct thread *td, struct linux_wait4_args *args)
+{
+	int error, options;
+	struct rusage ru, *rup;
+
+#ifdef DEBUG
+	if (ldebug(wait4))
+		printf(ARGS(wait4, "%d, %p, %d, %p"),
+		    args->pid, (void *)args->status, args->options,
+		    (void *)args->rusage);
+#endif
+
+	options = (args->options & (WNOHANG | WUNTRACED));
+	/* WLINUXCLONE should be equal to __WCLONE, but we make sure */
+	if (args->options & __WCLONE)
+		options |= WLINUXCLONE;
+
+	if (args->rusage != NULL)
+		rup = &ru;
+	else
+		rup = NULL;
+	error = linux_common_wait(td, args->pid, args->status, options, rup);
+	if (error != 0)
+		return (error);
+	if (args->rusage != NULL)
+		error = linux_copyout_rusage(&ru, args->rusage);
+	return (error);
+}
 
 int
 linux_mknod(struct thread *td, struct linux_mknod_args *args)

Modified: stable/10/sys/i386/linux/linux.h
==============================================================================
--- stable/10/sys/i386/linux/linux.h	Sat Jan  9 15:22:50 2016	(r293499)
+++ stable/10/sys/i386/linux/linux.h	Sat Jan  9 15:23:54 2016	(r293500)
@@ -741,6 +741,8 @@ struct l_desc_struct {
 #define	LINUX_GET_USEABLE(desc)		\
 	(((desc)->b >> LINUX_ENTRY_B_USEABLE) & 1)
 
+#define	linux_copyout_rusage(r, u)	copyout(r, u, sizeof(*r))
+
 /* robust futexes */
 struct linux_robust_list {
 	struct linux_robust_list	*next;

Modified: stable/10/sys/i386/linux/linux_machdep.c
==============================================================================
--- stable/10/sys/i386/linux/linux_machdep.c	Sat Jan  9 15:22:50 2016	(r293499)
+++ stable/10/sys/i386/linux/linux_machdep.c	Sat Jan  9 15:23:54 2016	(r293500)
@@ -1047,34 +1047,3 @@ linux_mq_getsetattr(struct thread *td, s
 	return (ENOSYS);
 #endif
 }
-
-int
-linux_wait4(struct thread *td, struct linux_wait4_args *args)
-{
-	int error, options;
-	struct rusage ru, *rup;
-
-#ifdef DEBUG
-	if (ldebug(wait4))
-		printf(ARGS(wait4, "%d, %p, %d, %p"),
-		    args->pid, (void *)args->status, args->options,
-		    (void *)args->rusage);
-#endif
-
-	options = (args->options & (WNOHANG | WUNTRACED));
-	/* WLINUXCLONE should be equal to __WCLONE, but we make sure */
-	if (args->options & __WCLONE)
-		options |= WLINUXCLONE;
-
-	if (args->rusage != NULL)
-		rup = &ru;
-	else
-		rup = NULL;
-	error = linux_common_wait(td, args->pid, args->status, options, rup);
-	if (error)
-		return (error);
-	if (args->rusage != NULL)
-		error = copyout(&ru, args->rusage, sizeof(ru));
-
-	return (error);
-}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601091523.u09FNsoH018153>