From e8cd1819675bdda61d7edee6d951bf9f2b5d9091 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 18 Sep 2012 11:40:44 +0200 Subject: [PATCH] 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 --- libmount/src/context_loopdev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libmount/src/context_loopdev.c b/libmount/src/context_loopdev.c index 532057870f..fc8da9fe78 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; -- 2.47.2