Commit eec8c097 authored by David Mosberger's avatar David Mosberger Committed by Linus Torvalds

[PATCH] let binfmt_misc optionally preserve argv[1]

This makes it possible for binfmt_misc to optionally preserve the
contents of argv[1].  This is needed for building accurate simulators
which are invoked via binfmt_misc.  I had brought up this patch a while
ago (see URL below) and there was no negative feedback (OK, there was no
feedback at all...  ;-).

The patch is trivial and the new behavior is triggered only if the
letter "P" (for "preserve") is appended to the binfmt_misc registration
string, so it shold be completely safe.
parent faa9e015
...@@ -36,6 +36,7 @@ static LIST_HEAD(entries); ...@@ -36,6 +36,7 @@ static LIST_HEAD(entries);
static int enabled = 1; static int enabled = 1;
enum {Enabled, Magic}; enum {Enabled, Magic};
#define MISC_FMT_PRESERVE_ARGV0 (1<<31)
typedef struct { typedef struct {
struct list_head list; struct list_head list;
...@@ -124,7 +125,9 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs) ...@@ -124,7 +125,9 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
bprm->file = NULL; bprm->file = NULL;
/* Build args for interpreter */ /* Build args for interpreter */
remove_arg_zero(bprm); if (!(fmt->flags & MISC_FMT_PRESERVE_ARGV0)) {
remove_arg_zero(bprm);
}
retval = copy_strings_kernel(1, &bprm->filename, bprm); retval = copy_strings_kernel(1, &bprm->filename, bprm);
if (retval < 0) goto _ret; if (retval < 0) goto _ret;
bprm->argc++; bprm->argc++;
...@@ -290,6 +293,11 @@ static Node *create_entry(const char *buffer, size_t count) ...@@ -290,6 +293,11 @@ static Node *create_entry(const char *buffer, size_t count)
if (!e->interpreter[0]) if (!e->interpreter[0])
goto Einval; goto Einval;
if (*p == 'P') {
p++;
e->flags |= MISC_FMT_PRESERVE_ARGV0;
}
if (*p == '\n') if (*p == '\n')
p++; p++;
if (p != buf + count) if (p != buf + count)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment