summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2010-07-23 21:30:33 +0000
committerkib <kib@FreeBSD.org>2010-07-23 21:30:33 +0000
commit229b3b9c19bbd5e43dcc3aa81060069b2d4bbfbd (patch)
tree22ad4409d444be573bff34cf29e34c16184ef0f5 /sys
parentaa17bd87c6841106f418283b6ef59509d82dd6e5 (diff)
downloadFreeBSD-src-229b3b9c19bbd5e43dcc3aa81060069b2d4bbfbd.zip
FreeBSD-src-229b3b9c19bbd5e43dcc3aa81060069b2d4bbfbd.tar.gz
Remove the linux_exec_copyin_args(), freebsd32_exec_copyin_args() may
server as well. COMPAT_FREEBSD32 is a prerequisite for COMPAT_LINUX32. Reviewed by: alc MFC after: 3 weeks
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/linux32/linux32_machdep.c102
-rw-r--r--sys/amd64/linux32/syscalls.master4
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c2
-rw-r--r--sys/compat/freebsd32/freebsd32_util.h4
4 files changed, 10 insertions, 102 deletions
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c
index b866929..541caf5 100644
--- a/sys/amd64/linux32/linux32_machdep.c
+++ b/sys/amd64/linux32/linux32_machdep.c
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#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,103 +108,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:
- exec_free_args(args);
- return (error);
-}
-
int
linux_execve(struct thread *td, struct linux_execve_args *args)
{
@@ -218,8 +122,8 @@ linux_execve(struct thread *td, struct linux_execve_args *args)
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);
diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master
index 9aff0fc..cff2ad7 100644
--- a/sys/amd64/linux32/syscalls.master
+++ b/sys/amd64/linux32/syscalls.master
@@ -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, \
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 534c82c..2d5c76d 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -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)
{
diff --git a/sys/compat/freebsd32/freebsd32_util.h b/sys/compat/freebsd32/freebsd32_util.h
index 3ac676d..385b690 100644
--- a/sys/compat/freebsd32/freebsd32_util.h
+++ b/sys/compat/freebsd32/freebsd32_util.h
@@ -101,5 +101,9 @@ int freebsd32_copyiniov(struct iovec32 *iovp, u_int iovcnt,
struct iovec **iov, int error);
void freebsd32_rusage_out(const struct rusage *s, struct rusage32 *s32);
+enum uio_seg;
+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_ */
OpenPOWER on IntegriCloud