summaryrefslogtreecommitdiffstats
path: root/libmount/src/context_loopdev.c
diff options
context:
space:
mode:
authorKarel Zak2012-09-18 11:40:44 +0200
committerKarel Zak2012-09-18 11:40:44 +0200
commite8cd1819675bdda61d7edee6d951bf9f2b5d9091 (patch)
tree5f9e084172f1bf6d405efcd95d1a9f9fd1e5709e /libmount/src/context_loopdev.c
parentlibmount: detach loopdev on umount if loop option in mtab (diff)
downloadkernel-qcow2-util-linux-e8cd1819675bdda61d7edee6d951bf9f2b5d9091.tar.gz
kernel-qcow2-util-linux-e8cd1819675bdda61d7edee6d951bf9f2b5d9091.tar.xz
kernel-qcow2-util-linux-e8cd1819675bdda61d7edee6d951bf9f2b5d9091.zip
libmount: append loop option when automatically create loopdev
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>
Diffstat (limited to 'libmount/src/context_loopdev.c')
-rw-r--r--libmount/src/context_loopdev.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libmount/src/context_loopdev.c b/libmount/src/context_loopdev.c
index 532057870..fc8da9fe7 100644
--- a/libmount/src/context_loopdev.c
+++ b/libmount/src/context_loopdev.c
@@ -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;