mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fs: Check if automount actually mounts something
@ 2022-07-14 19:35 Sascha Hauer
  2022-07-14 21:12 ` Uwe Kleine-König
  0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2022-07-14 19:35 UTC (permalink / raw)
  To: Barebox List; +Cc: Uwe Kleine-König

An automount command that returns successfully but doesn't mount
anything makes barebox hang as can be reproduced with:

automount -d /mnt/foo true
ls /mnt/foo

Check if the current dentry is a mountpoint after running the automount
command, otherwise return with an error from automount_mount().

Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/fs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/fs.c b/fs/fs.c
index 460fc2f7f1..bd6f144742 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -3191,6 +3191,10 @@ static int automount_mount(struct dentry *dentry)
 			printf("running automount command '%s' failed\n",
 					am->cmd);
 			ret = -ENODEV;
+		} else if (!(dentry->d_flags & DCACHE_MOUNTED)) {
+			printf("automount command '%s' didn't mount anything\n",
+					am->cmd);
+			ret = -ENODEV;
 		}
 
 		break;
-- 
2.30.2




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

* Re: [PATCH] fs: Check if automount actually mounts something
  2022-07-14 19:35 [PATCH] fs: Check if automount actually mounts something Sascha Hauer
@ 2022-07-14 21:12 ` Uwe Kleine-König
  2022-08-09 10:06   ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2022-07-14 21:12 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Barebox List

[-- Attachment #1: Type: text/plain, Size: 926 bytes --]

On Thu, Jul 14, 2022 at 09:35:09PM +0200, Sascha Hauer wrote:
> An automount command that returns successfully but doesn't mount
> anything makes barebox hang as can be reproduced with:
> 
> automount -d /mnt/foo true
> ls /mnt/foo
> 
> Check if the current dentry is a mountpoint after running the automount
> command, otherwise return with an error from automount_mount().

While I think the intention of this patch is fine, I have little doubts
if that breaks some workflows, e.g. something like:

	automount -d /mnt/tralala 'for p in 0 1 2; do mkdir ${automount_path}/${p} && mount /dev/disk0.${p} ${automount_path}/${p} || break; done'

I admit it's a bit constructed, but maybe that's only because I'm not
creative enough?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] fs: Check if automount actually mounts something
  2022-07-14 21:12 ` Uwe Kleine-König
@ 2022-08-09 10:06   ` Sascha Hauer
  2022-08-09 13:05     ` Uwe Kleine-König
  0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2022-08-09 10:06 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Barebox List

On Thu, Jul 14, 2022 at 11:12:38PM +0200, Uwe Kleine-König wrote:
> On Thu, Jul 14, 2022 at 09:35:09PM +0200, Sascha Hauer wrote:
> > An automount command that returns successfully but doesn't mount
> > anything makes barebox hang as can be reproduced with:
> > 
> > automount -d /mnt/foo true
> > ls /mnt/foo
> > 
> > Check if the current dentry is a mountpoint after running the automount
> > command, otherwise return with an error from automount_mount().
> 
> While I think the intention of this patch is fine, I have little doubts
> if that breaks some workflows, e.g. something like:
> 
> 	automount -d /mnt/tralala 'for p in 0 1 2; do mkdir ${automount_path}/${p} && mount /dev/disk0.${p} ${automount_path}/${p} || break; done'

You would create 3 automountpoints for that.

> 
> I admit it's a bit constructed, but maybe that's only because I'm not
> creative enough?

Yes, it is constructed ;)

I can't think of a better example, but I'm not sure we should support
such cases.

Sascha


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



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

* Re: [PATCH] fs: Check if automount actually mounts something
  2022-08-09 10:06   ` Sascha Hauer
@ 2022-08-09 13:05     ` Uwe Kleine-König
  2022-08-10  6:44       ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2022-08-09 13:05 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Barebox List

[-- Attachment #1: Type: text/plain, Size: 1693 bytes --]

Hello,

On Tue, Aug 09, 2022 at 12:06:38PM +0200, Sascha Hauer wrote:
> On Thu, Jul 14, 2022 at 11:12:38PM +0200, Uwe Kleine-König wrote:
> > On Thu, Jul 14, 2022 at 09:35:09PM +0200, Sascha Hauer wrote:
> > > An automount command that returns successfully but doesn't mount
> > > anything makes barebox hang as can be reproduced with:
> > > 
> > > automount -d /mnt/foo true
> > > ls /mnt/foo
> > > 
> > > Check if the current dentry is a mountpoint after running the automount
> > > command, otherwise return with an error from automount_mount().
> > 
> > While I think the intention of this patch is fine, I have little doubts
> > if that breaks some workflows, e.g. something like:
> > 
> > 	automount -d /mnt/tralala 'for p in 0 1 2; do mkdir ${automount_path}/${p} && mount /dev/disk0.${p} ${automount_path}/${p} || break; done'
> 
> You would create 3 automountpoints for that.

Yeah, if you go one step further and create a directory for each
partition of the thumb drive, this is a dynamic thing though and solving
that with an automount might make sense, so something like:

	automount -d /mnt/tralala "for p in /dev/disk0.*; do mp=$(\${automount_path}/\$(basename $p)); automount -d \$mp 'mount \$p \$mp'"

(don't know if that would work, but you get the idea I guess).

> > I admit it's a bit constructed, but maybe that's only because I'm not
> > creative enough?
> 
> Yes, it is constructed ;)

OK, we can still adapt that later if and when such a need arises :-)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] fs: Check if automount actually mounts something
  2022-08-09 13:05     ` Uwe Kleine-König
@ 2022-08-10  6:44       ` Sascha Hauer
  0 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2022-08-10  6:44 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Barebox List

On Tue, Aug 09, 2022 at 03:05:19PM +0200, Uwe Kleine-König wrote:
> Hello,
> 
> On Tue, Aug 09, 2022 at 12:06:38PM +0200, Sascha Hauer wrote:
> > On Thu, Jul 14, 2022 at 11:12:38PM +0200, Uwe Kleine-König wrote:
> > > On Thu, Jul 14, 2022 at 09:35:09PM +0200, Sascha Hauer wrote:
> > > > An automount command that returns successfully but doesn't mount
> > > > anything makes barebox hang as can be reproduced with:
> > > > 
> > > > automount -d /mnt/foo true
> > > > ls /mnt/foo
> > > > 
> > > > Check if the current dentry is a mountpoint after running the automount
> > > > command, otherwise return with an error from automount_mount().
> > > 
> > > While I think the intention of this patch is fine, I have little doubts
> > > if that breaks some workflows, e.g. something like:
> > > 
> > > 	automount -d /mnt/tralala 'for p in 0 1 2; do mkdir ${automount_path}/${p} && mount /dev/disk0.${p} ${automount_path}/${p} || break; done'
> > 
> > You would create 3 automountpoints for that.
> 
> Yeah, if you go one step further and create a directory for each
> partition of the thumb drive, this is a dynamic thing though and solving
> that with an automount might make sense, so something like:
> 
> 	automount -d /mnt/tralala "for p in /dev/disk0.*; do mp=$(\${automount_path}/\$(basename $p)); automount -d \$mp 'mount \$p \$mp'"
> 
> (don't know if that would work, but you get the idea I guess).

It won't work. The outer automount is for mounting /mnt/tralala/. You
can't access anything inside /mnt/tralala/ before that has been
completed.

Similarly the following doesn't work:

# automount -d /mnt/tralala 'echo -o ${automount_path}/foo bar'
# ls /mnt/tralala/
open: Invalid argument
running automount command 'echo -o ${automount_path}/foo bar' failed
ls: /mnt/tralala/: No such device

Sascha

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



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

end of thread, other threads:[~2022-08-10  6:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-14 19:35 [PATCH] fs: Check if automount actually mounts something Sascha Hauer
2022-07-14 21:12 ` Uwe Kleine-König
2022-08-09 10:06   ` Sascha Hauer
2022-08-09 13:05     ` Uwe Kleine-König
2022-08-10  6:44       ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox