let binfmt_misc optionally preserve argv[1]
Subsystems (2)
PATCH 1/1 let binfmt_misc optionally preserve argv[1]
[This patch applies to 2.4.20 and is due to David Mosberger]
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.
fs/binfmt_misc.c +9 -1
@@ -35,6 +35,7 @@static int enabled =1 ;enum {Enabled, Magic}; +#define MISC_FMT_PRESERVE_ARGV0 (1<<31) typedef struct { struct list_head list;
@@ -121,7 +122,9 @@ bprm->file =NULL ;/* 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);if (retval <0 ) goto _ret; bprm->argc++;
@@ -286,6 +289,11 @@ *p++ ='\0' ;if (!e->interpreter[0 ]) goto Einval; + +if (*p =='P' ) { + p++; + e->flags |=MISC_FMT_PRESERVE_ARGV0 ; + }if (*p =='\n' ) p++;