Skip to contentSkip to conversation

libmount: special treatment for auto in fstype pattern

PATCH In review Andreas Henriksson 2 participants 2 messages Jun 22, 2014 – Jun 23, 2014 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libmount: special treatment for auto in fstype pattern

Quoting from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=506695 :

according to mount(8), mount tries to guess a filesystem type when given fstype `auto' and it tries multiple filesystems if a list of fstypes is given.

A single fstype `auto' works as expected:
mount -t auto /dev/sde /media/stick
mounts /dev/sde as vfat, which is correct.
However, merging `auto' with other types doesn't work as expected:
mount -t ext2,auto /dev/sde /media/stick
does not mount /dev/sde but returns:
mount: unknown filesystem type 'auto'

Trying multiple fstypes before allowing mount to guess makes sense in different scenarios, for example to prefer specific fstypes (ext2 instead of ext3) or to try fstypes that mount doesn't guess (minix). I'm not sure if the Debian installer still sets CDROM fstab entries to `udf,iso9660,auto' but I remember it did once. This wouldn't work then either.

---
 libmount/src/context_mount.c | 2 ++
 1 file changed, 2 insertions(+)
libmount/src/context_mount.c +2 -0
index dcfdabf..d07fa02 100644
@@ -782,6 +782,8 @@ static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern)
 			char *end = strchr(p, ',');
 			if (end)
 				*end = '\0';
+			if (strcmp(p, "auto") == 0)
+				p = NULL;
 			rc = do_mount(cxt, p);
 			p = end ? end + 1 : NULL;
 
Signature · 1 line
2.0.0
maintainer
#1 lore raw
Quoted 4 lines · Andreas Henriksson

However, merging `auto' with other types doesn't work as expected:
mount -t ext2,auto /dev/sde /media/stick
does not mount /dev/sde but returns:
mount: unknown filesystem type 'auto'

Interesting use case.

Quoted 3 lines

Trying multiple fstypes before allowing mount to guess makes sense in different scenarios, for example to prefer specific fstypes (ext2 instead of ext3) or to try fstypes that mount doesn't guess (minix).

I hope libblkid is able to detect minix ;-)

libmount/src/context_mount.c static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern) · line 787

Quoted 11 lines
libmount/src/context_mount.c +2 -0
index dcfdabf..d07fa02 100644
@@ -782,6 +782,8 @@ static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern)
 			char *end = strchr(p, ',');
 			if (end)
 				*end = '\0';
+			if (strcmp(p, "auto") == 0)
+				p = NULL;
 			rc = do_mount(cxt, p);

This is insufficient solution, the code has to call an FS detection code. I have applied a little different solution.

Thanks!

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com