]> 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>
Mon, 1 Oct 2012 09:56:23 +0000 (11:56 +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 da246e3bbce5ce694cbf67d7e87edb6e46c67f3c..7ba8a52078bef0477cac94b873bf8f5983708e12 100644 (file)
@@ -62,8 +62,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;