From 556c9641f01eb9c6d1c5b4ae3c6cdd4f9395d34d Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 8 Apr 2010 16:38:23 +0200 Subject: [PATCH] mount: use auto-loopdev for all known filesystems The commit e580266914734898999f652025f9c7141023df66 introduced "automatically detect and loop-mount regular files". This should be used only for filesystems that require block devices. All known filesystems in libblkid depend block devices, so we can use blkid_known_fstype() as a filter for this feature. Signed-off-by: Karel Zak --- mount/mount.8 | 5 +++-- mount/mount.c | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mount/mount.8 b/mount/mount.8 index 9675cc62..06ea3acd 100644 --- a/mount/mount.8 +++ b/mount/mount.8 @@ -2560,13 +2560,14 @@ will try to find some unused loop device and use that, for example The mount command .B automatically creates a loop device from a regular file if a filesystem type is -not specified, for example: +not specified or the filesystem is known for libblkid, for example: .RS .sp .B "mount /tmp/disk.img /mnt" .sp +.B "mount -t ext3 /tmp/disk.img /mnt" +.sp .RE - This type of mount knows about four options, namely .BR loop ", " offset ", " sizelimit " and " encryption , that are really options to diff --git a/mount/mount.c b/mount/mount.c index 7a5ea06d..8cab2e8a 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -1120,16 +1120,15 @@ loop_check(const char **spec, const char **type, int *flags, *loopfile = *spec; /* Automatically create a loop device from a regular file if a filesystem - * is not specified. + * is not specified or the filesystem is known for libblkid (these + * filesystems work with block devices only). * * Note that there is not a restriction (on kernel side) that prevents regular * file as a mount(2) source argument. A filesystem that is able to mount * regular files could be implemented. - * - * If the filesystem type is specified than "-o loop" is required to create a - * loop device. */ - if (!*loop && (!*type || strcmp(*type, "auto") == 0)) { + if (!*loop && (!*type || strcmp(*type, "auto") == 0 || + fsprobe_known_fstype(*type))) { struct stat st; if (stat(*loopfile, &st) == 0) *loop = S_ISREG(st.st_mode); -- 2.39.5