mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Mosberger <davidm@napali.hpl.hp.com>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org, davidm@napali.hpl.hp.com
Subject: [patch] let binfmt_misc optionally preserve argv[1]
Date: Wed, 6 Nov 2002 10:19:17 -0800	[thread overview]
Message-ID: <15817.23845.227983.58235@napali.hpl.hp.com> (raw)

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++;

             reply	other threads:[~2002-11-06 18:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-06 18:19 David Mosberger [this message]
2002-12-16 19:17 [PATCH] " Bjorn Helgaas
2003-12-31  0:06 Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15817.23845.227983.58235@napali.hpl.hp.com \
    --to=davidm@napali.hpl.hp.com \
    --cc=davidm@hpl.hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®