summaryrefslogtreecommitdiffstats
path: root/libmount/src/context_loopdev.c
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/context_loopdev.c
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/context_loopdev.c')
-rw-r--r--libmount/src/context_loopdev.c6
1 files changed, 3 insertions, 3 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