mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Stefan Riedmueller <s.riedmueller@phytec.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] fs: Fix default mount when device already mounted
Date: Wed, 17 Mar 2021 10:31:39 +0100	[thread overview]
Message-ID: <20210317093139.GY23724@pengutronix.de> (raw)
In-Reply-To: <20210316123546.25769-1-s.riedmueller@phytec.de>

Hi Stefan,

On Tue, Mar 16, 2021 at 01:35:46PM +0100, Stefan Riedmueller wrote:
> Let cdev_mount_default return an error in case the device is already
> mounted to a different location than the default mount point.
> 
> Otherwise the automount routine can get stuck in an infinite loop
> spamming:
> 
> mounted /dev/mmc0.0 on /mnt/mmc
> mounted /dev/mmc0.0 on /mnt/mmc
> mounted /dev/mmc0.0 on /mnt/mmc
> 
> Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
> ---
>  fs/fs.c | 28 +++++++++++++++++++---------
>  1 file changed, 19 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/fs.c b/fs/fs.c
> index 3db24b7b6822..4f2345d22544 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -951,9 +951,10 @@ const char *cdev_get_mount_path(struct cdev *cdev)
>  /*
>   * cdev_mount_default - mount a cdev to the default path
>   *
> - * If a cdev is already mounted return the path it's mounted on, otherwise
> - * mount it to /mnt/<cdevname> and return the path. Returns an error pointer
> - * on failure.
> + * If a cdev is already mounted to the default mount path return the path
> + * it's mounted on. If it is mounted to any other path return EBUSY.
> + * Otherwise mount it to /mnt/<cdevname> and return the path. Returns an
> + * error pointer on failure.

blspec depends on the return-current-path-when-mounted part you are
removing here. I added the following patch before applying this one.

Sascha

------------------------------8<-------------------------------

>From 7dc73d3618a15f0d858d5409574f38f9f83905ef Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Wed, 17 Mar 2021 10:25:47 +0100
Subject: [PATCH] blspec: Check if already mounted before mounting

cdev_mount_default() either mounts a cdev and returns the path it's
mounted to or directly returns the path when it already is mounted.
This will change in the next patch: When the cdev is already mounted
cdev_mount_default() will return -EBUSY instead. To let blspec
work when a cdev is already mounted check for the actual mount path
before trying to mount it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/blspec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/blspec.c b/common/blspec.c
index c05d8a8297..ad80d7a8cd 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -729,7 +729,9 @@ static int blspec_scan_cdev(struct bootentries *bootentries, struct cdev *cdev)
 			found += ret;
 	}
 
-	rootpath = cdev_mount_default(cdev, NULL);
+	rootpath = cdev_get_mount_path(cdev);
+	if (!rootpath)
+		rootpath = cdev_mount_default(cdev, NULL);
 	if (!IS_ERR(rootpath)) {
 		ret = blspec_scan_directory(bootentries, rootpath);
 		if (ret > 0)
-- 
2.29.2


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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


      reply	other threads:[~2021-03-17  9:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-16 12:35 Stefan Riedmueller
2021-03-17  9:31 ` Sascha Hauer [this message]

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=20210317093139.GY23724@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.riedmueller@phytec.de \
    /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