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