mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/4] automount: Pass automount pass as environment variable
Date: Sun, 15 Apr 2012 16:51:54 +0200	[thread overview]
Message-ID: <1334501517-29478-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1334501517-29478-1-git-send-email-s.hauer@pengutronix.de>

This makes it possible to pass a command sequence to the automount
command instead of only a script (a command sequence would get confused
by the additional argument)

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/fs.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 24ef258..64997cc 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -31,6 +31,8 @@
 #include <init.h>
 #include <module.h>
 #include <libbb.h>
+#include <magicvar.h>
+#include <environment.h>
 
 void *read_file(const char *filename, size_t *size)
 {
@@ -289,7 +291,6 @@ static void automount_mount(const char *path, int instat)
 	int ret;
 
 	list_for_each_entry(am, &automount_list, list) {
-		char *cmd;
 		int len_path = strlen(path);
 		int len_am_path = strlen(am->path);
 
@@ -312,9 +313,10 @@ static void automount_mount(const char *path, int instat)
 		if (*(path + len_am_path) != 0 && *(path + len_am_path) != '/')
 			continue;
 
-		cmd = asprintf("%s %s", am->cmd, am->path);
-		ret = run_command(cmd, 0);
-		free(cmd);
+		setenv("automount_path", am->path);
+		export("automount_path");
+		ret = run_command(am->cmd, 0);
+		setenv("automount_path", NULL);
 
 		if (ret)
 			printf("running automount command '%s' failed\n",
@@ -325,6 +327,9 @@ static void automount_mount(const char *path, int instat)
 		return;
 	}
 }
+
+BAREBOX_MAGICVAR(automount_path, "mountpath passed to automount scripts");
+
 #else
 static void automount_mount(const char *path, int instat)
 {
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-04-15 14:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-15 14:51 [PATCH] automount work Sascha Hauer
2012-04-15 14:51 ` Sascha Hauer [this message]
2012-04-15 14:51 ` [PATCH 2/4] automount: fix argument parsing Sascha Hauer
2012-04-15 14:51 ` [PATCH 3/4] automount: optionally make directory Sascha Hauer
2012-04-15 14:51 ` [PATCH 4/4] automount: remove existing automountpoint Sascha Hauer

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=1334501517-29478-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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