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] automount: check for recursive automount
Date: Thu,  3 Jul 2014 08:21:30 +0200	[thread overview]
Message-ID: <1404368490-24902-1-git-send-email-s.hauer@pengutronix.de> (raw)

automount_mount calls run_command which may trigger an automount
again. This results in an endless loop. A simple way to trigger
this is:

mkdir /x; automount /x false; cd /x; something

Use a static variable to detect if we are currently in automount_mount()
and bail out if we are.

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

diff --git a/fs/fs.c b/fs/fs.c
index b0ac918..dd410b7 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -409,6 +409,12 @@ static void automount_mount(const char *path, int instat)
 {
 	struct automount *am;
 	int ret;
+	static int in_automount;
+
+	if (in_automount)
+		return;
+
+	in_automount++;
 
 	list_for_each_entry(am, &automount_list, list) {
 		int len_path = strlen(path);
@@ -444,8 +450,10 @@ static void automount_mount(const char *path, int instat)
 		else
 			automount_remove(am->path);
 
-		return;
+		break;
 	}
+
+	in_automount--;
 }
 
 BAREBOX_MAGICVAR(automount_path, "mountpath passed to automount scripts");
-- 
2.0.0


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

             reply	other threads:[~2014-07-03  6:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-03  6:21 Sascha Hauer [this message]
2014-07-03  8:34 Rolf Evers-Fischer
2014-07-03  8:51 ` Uwe Kleine-König
2014-07-03  9:00 ` Alessandro Rubini
2014-07-03  9:33   ` Uwe Kleine-König
2014-07-03 11:05     ` Rolf Evers-Fischer

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=1404368490-24902-1-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