]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: append loop option when automatically create loopdev
authorKarel Zak <kzak@redhat.com>
Tue, 18 Sep 2012 09:40:44 +0000 (11:40 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 18 Sep 2012 09:40:44 +0000 (11:40 +0200)
The loop option is optional, mount(8) is able to detect that the
source path is regular file (image) with known filesystem -- then a
loop device is automatically created. In this case we have to store
"loop" option to mtab on systems without autoclear loopdev flag.

Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context_loopdev.c

index 532057870fc6f20839dcb8be3d4cfa0a7e64a3d0..fc8da9fe78a42a32f7b6d405a77f870578a0ebfc 100644 (file)
@@ -60,8 +60,12 @@ int mnt_context_is_loopdev(struct libmnt_context *cxt)
                struct stat st;
 
                if (stat(src, &st) == 0 && S_ISREG(st.st_mode) &&
-                   st.st_size > 1024)
+                   st.st_size > 1024) {
+                       DBG(CXT, mnt_debug_h(cxt, "automatically enabling loop= option"));
+                       cxt->user_mountflags |= MNT_MS_LOOP;
+                       mnt_optstr_append_option(&cxt->fs->user_optstr, "loop", NULL);
                        return 1;
+               }
        }
 
        return 0;