linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] let binfmt_misc optionally preserve argv[1]
@ 2003-12-31  0:06 Bjorn Helgaas
  0 siblings, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2003-12-31  0:06 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: linux-kernel

Originally by David Mosberger; here's his description:

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.

http://groups.google.com/groups?q=mosberger+binfmt_misc&hl=en&lr=&ie=UTF-8&oe=UT
F-8&selm=200209092241.g89MfPS5001013%40napali.hpl.hp.com&rnum=1

This has been in 2.6 for 16 months:
    http://linux.bkbits.net:8080/linux-2.5/diffs/fs/binfmt_misc.c@1.16?nav=index.html|src/.|src/fs|hist/fs/binfmt_misc.c

diff -urN linux-2.4/fs/binfmt_misc.c linux-ia64-2.4/fs/binfmt_misc.c
--- linux-2.4/fs/binfmt_misc.c	2003-12-29 17:05:24.000000000 -0700
+++ linux-ia64-2.4/fs/binfmt_misc.c	2003-12-29 17:06:12.000000000 -0700
@@ -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++;
@@ -287,6 +290,11 @@
 	if (!e->interpreter[0])
 		goto Einval;
 
+	if (*p == 'P') {
+		p++;
+		e->flags |= MISC_FMT_PRESERVE_ARGV0;
+	}
+
 	if (*p == '\n')
 		p++;
 	if (p != buf + count)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] let binfmt_misc optionally preserve argv[1]
@ 2002-12-16 19:17 Bjorn Helgaas
  0 siblings, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2002-12-16 19:17 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: linux-kernel

[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.

http://groups.google.com/groups?q=mosberger+binfmt_misc&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=200209092241.g89MfPS5001013%40napali.hpl.hp.com&rnum=1

diff -Nru a/fs/binfmt_misc.c b/fs/binfmt_misc.c
--- a/fs/binfmt_misc.c	Mon Dec 16 12:06:58 2002
+++ b/fs/binfmt_misc.c	Mon Dec 16 12:06:58 2002
@@ -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++;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [patch] let binfmt_misc optionally preserve argv[1]
@ 2002-11-06 18:19 David Mosberger
  0 siblings, 0 replies; 3+ messages in thread
From: David Mosberger @ 2002-11-06 18:19 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, davidm

Hi Linus,

Below is a patch which 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.

Thanks,

	--david

http://groups.google.com/groups?q=mosberger+binfmt_misc&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=200209092241.g89MfPS5001013%40napali.hpl.hp.com&rnum=1

diff -Nru a/fs/binfmt_misc.c b/fs/binfmt_misc.c
--- a/fs/binfmt_misc.c	Tue Sep 24 22:09:20 2002
+++ b/fs/binfmt_misc.c	Tue Sep 24 22:09:20 2002
@@ -36,6 +36,7 @@
 static int enabled = 1;
 
 enum {Enabled, Magic};
+#define MISC_FMT_PRESERVE_ARGV0 (1<<31)
 
 typedef struct {
 	struct list_head list;
@@ -124,7 +125,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++;
@@ -289,6 +292,11 @@
 	*p++ = '\0';
 	if (!e->interpreter[0])
 		goto Einval;
+
+	if (*p == 'P') {
+		p++;
+		e->flags |= MISC_FMT_PRESERVE_ARGV0;
+	}
 
 	if (*p == '\n')
 		p++;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-12-31  0:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-31  0:06 [PATCH] let binfmt_misc optionally preserve argv[1] Bjorn Helgaas
  -- strict thread matches above, loose matches on Subject: below --
2002-12-16 19:17 Bjorn Helgaas
2002-11-06 18:19 [patch] " David Mosberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).