summaryrefslogtreecommitdiffstats
path: root/libmount/src
diff options
context:
space:
mode:
authorStanislav Brabec2016-07-14 15:29:09 +0200
committerKarel Zak2016-08-03 11:53:28 +0200
commit74a4705a993ce475d95c1c20d0cc4eb740b0c933 (patch)
tree3d8f1ccfcd24f17448830c6f1977566917e31092 /libmount/src
parentmount: Handle MNT_ERR_LOOPOVERLAP (diff)
downloadkernel-qcow2-util-linux-74a4705a993ce475d95c1c20d0cc4eb740b0c933.tar.gz
kernel-qcow2-util-linux-74a4705a993ce475d95c1c20d0cc4eb740b0c933.tar.xz
kernel-qcow2-util-linux-74a4705a993ce475d95c1c20d0cc4eb740b0c933.zip
Add sizelimit to internal API
Fully safe checks of loop device need to check sizelimit. To prevent need of two nearly equal functions, introduce sizelimit parameter to several internal functions: loopdev_is_used() loopdev_find_by_backing_file() loopcxt_is_used() loopcxt_find_by_backing_file() If sizelimit is zero, fall back to the old behavior (ignoring of sizelimit). Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Diffstat (limited to 'libmount/src')
-rw-r--r--libmount/src/context_loopdev.c6
-rw-r--r--libmount/src/context_umount.c2
-rw-r--r--libmount/src/tab.c2
3 files changed, 5 insertions, 5 deletions
diff --git a/libmount/src/context_loopdev.c b/libmount/src/context_loopdev.c
index 753063219..8a5706af0 100644
--- a/libmount/src/context_loopdev.c
+++ b/libmount/src/context_loopdev.c
@@ -119,13 +119,13 @@ is_mounted_same_loopfile(struct libmnt_context *cxt,
rc = 0;
if (strncmp(src, "/dev/loop", 9) == 0) {
- rc = loopdev_is_used((char *) src, bf, offset, LOOPDEV_FL_OFFSET);
+ rc = loopdev_is_used((char *) src, bf, offset, 0, LOOPDEV_FL_OFFSET);
} else if (opts && (cxt->user_mountflags & MNT_MS_LOOP) &&
mnt_optstr_get_option(opts, "loop", &val, &len) == 0 && val) {
val = strndup(val, len);
- rc = loopdev_is_used((char *) val, bf, offset, LOOPDEV_FL_OFFSET);
+ rc = loopdev_is_used((char *) val, bf, offset, 0, LOOPDEV_FL_OFFSET);
free(val);
}
}
@@ -219,7 +219,7 @@ int mnt_context_setup_loopdev(struct libmnt_context *cxt)
if (rc)
goto done_no_deinit;
if (backing_file && !(loopcxt_find_by_backing_file(&lc,
- backing_file, offset, LOOPDEV_FL_OFFSET))) {
+ backing_file, offset, sizelimit, LOOPDEV_FL_OFFSET))) {
DBG(LOOP, ul_debugobj(cxt, "using existing loop device %s",
loopcxt_get_device(&lc)));
/* Once a loop is initialized RO, there is no way to safely
diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c
index d003c5def..28787dab1 100644
--- a/libmount/src/context_umount.c
+++ b/libmount/src/context_umount.c
@@ -328,7 +328,7 @@ static int is_associated_fs(const char *devname, struct libmnt_fs *fs)
return 0;
}
- return loopdev_is_used(devname, src, offset, flags);
+ return loopdev_is_used(devname, src, offset, 0, flags);
}
static int prepare_helper_from_options(struct libmnt_context *cxt,
diff --git a/libmount/src/tab.c b/libmount/src/tab.c
index 155c65ee3..341e5e343 100644
--- a/libmount/src/tab.c
+++ b/libmount/src/tab.c
@@ -1555,7 +1555,7 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
DBG(FS, ul_debugobj(fs, "checking for loop: src=%s", mnt_fs_get_srcpath(fs)));
#if __linux__
- if (!loopdev_is_used(mnt_fs_get_srcpath(fs), src, offset, flags))
+ if (!loopdev_is_used(mnt_fs_get_srcpath(fs), src, offset, 0, flags))
continue;
DBG(FS, ul_debugobj(fs, "used loop"));