summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2010-07-27 17:31:03 +0000
committeralc <alc@FreeBSD.org>2010-07-27 17:31:03 +0000
commit256c63de2893fe3b3b9d97763bc4871052984f8f (patch)
treea92c11fd0f16b4fd2595573c50330d0e933b83dc /sys/compat
parent3571b845b3692def492231ca1420482177b1d056 (diff)
downloadFreeBSD-src-256c63de2893fe3b3b9d97763bc4871052984f8f.zip
FreeBSD-src-256c63de2893fe3b3b9d97763bc4871052984f8f.tar.gz
Introduce exec_alloc_args(). The objective being to encapsulate the
details of the string buffer allocation in one place. Eliminate the portion of the string buffer that was dedicated to storing the interpreter name. The pointer to the interpreter name can simply be made to point to the appropriate argument string. Reviewed by: kib
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 1144f80..3dfed77 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -86,7 +86,6 @@ __FBSDID("$FreeBSD$");
#endif
#include <vm/vm.h>
-#include <vm/vm_kern.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
@@ -279,19 +278,18 @@ freebsd32_exec_copyin_args(struct image_args *args, char *fname,
return (EFAULT);
/*
- * Allocate temporary demand zeroed space for argument and
- * environment strings
+ * Allocate demand-paged memory for the file name, argument, and
+ * environment strings.
*/
- args->buf = (char *) kmem_alloc_wait(exec_map,
- PATH_MAX + ARG_MAX + MAXSHELLCMDLEN);
- if (args->buf == NULL)
- return (ENOMEM);
+ error = exec_alloc_args(args);
+ if (error != 0)
+ return (error);
/*
* Copy the file name.
*/
if (fname != NULL) {
- args->fname = args->buf + MAXSHELLCMDLEN;
+ args->fname = args->buf;
error = (segflg == UIO_SYSSPACE) ?
copystr(fname, args->fname, PATH_MAX, &length) :
copyinstr(fname, args->fname, PATH_MAX, &length);
@@ -300,7 +298,7 @@ freebsd32_exec_copyin_args(struct image_args *args, char *fname,
} else
length = 0;
- args->begin_argv = args->buf + MAXSHELLCMDLEN + length;
+ args->begin_argv = args->buf + length;
args->endp = args->begin_argv;
args->stringspace = ARG_MAX;
OpenPOWER on IntegriCloud