Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Mar 2011 21:51:32 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r219155 - in stable/8/sys: amd64/linux32 compat/freebsd32
Message-ID:  <201103012151.p21LpWTq063194@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Mar  1 21:51:32 2011
New Revision: 219155
URL: http://svn.freebsd.org/changeset/base/219155

Log:
  MFC r210431:
  Remove the linux_exec_copyin_args(), freebsd32_exec_copyin_args() may
  serve as well. COMPAT_FREEBSD32 is a prerequisite for COMPAT_LINUX32.
  
  MFC r210451:
  Use forward declartion for enum uio_seg in imgact.h. This allows to remove
  inclusion of sys/uio.h from the header.
  
  MFC r210498:
  Revert r210451, and the similar part of the r210431. The forward-declaration
  for the enum tag when enum definition is not complete is not allowed by
  C99, and is gcc extension.
  
  MFC r210501:
  Remove unneeded includes.
  
  Requested by:	dchagin

Modified:
  stable/8/sys/amd64/linux32/linux32_machdep.c
  stable/8/sys/amd64/linux32/syscalls.master
  stable/8/sys/compat/freebsd32/freebsd32_misc.c
  stable/8/sys/compat/freebsd32/freebsd32_util.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/amd64/linux32/linux32_machdep.c
==============================================================================
--- stable/8/sys/amd64/linux32/linux32_machdep.c	Tue Mar  1 21:48:22 2011	(r219154)
+++ stable/8/sys/amd64/linux32/linux32_machdep.c	Tue Mar  1 21:51:32 2011	(r219155)
@@ -60,10 +60,9 @@ __FBSDID("$FreeBSD$");
 
 #include <vm/vm.h>
 #include <vm/pmap.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_kern.h>
 #include <vm/vm_map.h>
 
+#include <compat/freebsd32/freebsd32_util.h>
 #include <amd64/linux32/linux.h>
 #include <amd64/linux32/linux32_proto.h>
 #include <compat/linux/linux_ipc.h>
@@ -107,105 +106,6 @@ bsd_to_linux_sigaltstack(int bsa)
 	return (lsa);
 }
 
-/*
- * Custom version of exec_copyin_args() so that we can translate
- * the pointers.
- */
-static int
-linux_exec_copyin_args(struct image_args *args, char *fname,
-    enum uio_seg segflg, char **argv, char **envv)
-{
-	char *argp, *envp;
-	u_int32_t *p32, arg;
-	size_t length;
-	int error;
-
-	bzero(args, sizeof(*args));
-	if (argv == NULL)
-		return (EFAULT);
-
-	/*
-	 * Allocate temporary demand zeroed space for argument and
-	 *	environment strings
-	 */
-	args->buf = (char *)kmem_alloc_wait(exec_map,
-	    PATH_MAX + ARG_MAX + MAXSHELLCMDLEN);
-	if (args->buf == NULL)
-		return (ENOMEM);
-	args->begin_argv = args->buf;
-	args->endp = args->begin_argv;
-	args->stringspace = ARG_MAX;
-
-	args->fname = args->buf + ARG_MAX;
-
-	/*
-	 * Copy the file name.
-	 */
-	error = (segflg == UIO_SYSSPACE) ?
-	    copystr(fname, args->fname, PATH_MAX, &length) :
-	    copyinstr(fname, args->fname, PATH_MAX, &length);
-	if (error != 0)
-		goto err_exit;
-
-	/*
-	 * extract arguments first
-	 */
-	p32 = (u_int32_t *)argv;
-	for (;;) {
-		error = copyin(p32++, &arg, sizeof(arg));
-		if (error)
-			goto err_exit;
-		if (arg == 0)
-			break;
-		argp = PTRIN(arg);
-		error = copyinstr(argp, args->endp, args->stringspace, &length);
-		if (error) {
-			if (error == ENAMETOOLONG)
-				error = E2BIG;
-
-			goto err_exit;
-		}
-		args->stringspace -= length;
-		args->endp += length;
-		args->argc++;
-	}
-
-	args->begin_envv = args->endp;
-
-	/*
-	 * extract environment strings
-	 */
-	if (envv) {
-		p32 = (u_int32_t *)envv;
-		for (;;) {
-			error = copyin(p32++, &arg, sizeof(arg));
-			if (error)
-				goto err_exit;
-			if (arg == 0)
-				break;
-			envp = PTRIN(arg);
-			error = copyinstr(envp, args->endp, args->stringspace,
-			    &length);
-			if (error) {
-				if (error == ENAMETOOLONG)
-					error = E2BIG;
-				goto err_exit;
-			}
-			args->stringspace -= length;
-			args->endp += length;
-			args->envc++;
-		}
-	}
-
-	return (0);
-
-err_exit:
-	kmem_free_wakeup(exec_map, (vm_offset_t)args->buf,
-	    PATH_MAX + ARG_MAX + MAXSHELLCMDLEN);
-	args->buf = NULL;
-	return (error);
-}
-
 int
 linux_execve(struct thread *td, struct linux_execve_args *args)
 {
@@ -220,8 +120,8 @@ linux_execve(struct thread *td, struct l
 		printf(ARGS(execve, "%s"), path);
 #endif
 
-	error = linux_exec_copyin_args(&eargs, path, UIO_SYSSPACE, args->argp,
-	    args->envp);
+	error = freebsd32_exec_copyin_args(&eargs, path, UIO_SYSSPACE,
+	    args->argp, args->envp);
 	free(path, M_TEMP);
 	if (error == 0)
 		error = kern_execve(td, &eargs, NULL);

Modified: stable/8/sys/amd64/linux32/syscalls.master
==============================================================================
--- stable/8/sys/amd64/linux32/syscalls.master	Tue Mar  1 21:48:22 2011	(r219154)
+++ stable/8/sys/amd64/linux32/syscalls.master	Tue Mar  1 21:51:32 2011	(r219155)
@@ -54,8 +54,8 @@
 				    l_int mode); }
 9	AUE_LINK	STD	{ int linux_link(char *path, char *to); }
 10	AUE_UNLINK	STD	{ int linux_unlink(char *path); }
-11	AUE_EXECVE	STD	{ int linux_execve(char *path, char **argp, \
-				    char **envp); }
+11	AUE_EXECVE	STD	{ int linux_execve(char *path, u_int32_t *argp, \
+				    u_int32_t *envp); }
 12	AUE_CHDIR	STD	{ int linux_chdir(char *path); }
 13	AUE_NULL	STD	{ int linux_time(l_time_t *tm); }
 14	AUE_MKNOD	STD	{ int linux_mknod(char *path, l_int mode, \

Modified: stable/8/sys/compat/freebsd32/freebsd32_misc.c
==============================================================================
--- stable/8/sys/compat/freebsd32/freebsd32_misc.c	Tue Mar  1 21:48:22 2011	(r219154)
+++ stable/8/sys/compat/freebsd32/freebsd32_misc.c	Tue Mar  1 21:51:32 2011	(r219155)
@@ -265,7 +265,7 @@ freebsd32_sigaltstack(struct thread *td,
  * Custom version of exec_copyin_args() so that we can translate
  * the pointers.
  */
-static int
+int
 freebsd32_exec_copyin_args(struct image_args *args, char *fname,
     enum uio_seg segflg, u_int32_t *argv, u_int32_t *envv)
 {

Modified: stable/8/sys/compat/freebsd32/freebsd32_util.h
==============================================================================
--- stable/8/sys/compat/freebsd32/freebsd32_util.h	Tue Mar  1 21:48:22 2011	(r219154)
+++ stable/8/sys/compat/freebsd32/freebsd32_util.h	Tue Mar  1 21:51:32 2011	(r219155)
@@ -34,6 +34,7 @@
 #include <sys/cdefs.h>
 #include <sys/exec.h>
 #include <sys/sysent.h>
+#include <sys/uio.h>
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
@@ -101,5 +102,8 @@ int	freebsd32_copyiniov(struct iovec32 *
 	    struct iovec **iov, int error);
 void	freebsd32_rusage_out(const struct rusage *s, struct rusage32 *s32);
 
+struct image_args;
+int freebsd32_exec_copyin_args(struct image_args *args, char *fname,
+	    enum uio_seg segflg, u_int32_t *argv, u_int32_t *envv);
 
 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_UTIL_H_ */



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