summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorManuel Bentele2019-08-14 18:19:24 +0200
committerManuel Bentele2019-08-14 18:19:24 +0200
commit5930cc1020706f90eafefac5d52535d0f49d2640 (patch)
treef1565940c9a59591347723c0e0f9d56186c2dc8a /lib
parentlib/losetup: added file format support (diff)
downloadkernel-qcow2-util-linux-5930cc1020706f90eafefac5d52535d0f49d2640.tar.gz
kernel-qcow2-util-linux-5930cc1020706f90eafefac5d52535d0f49d2640.tar.xz
kernel-qcow2-util-linux-5930cc1020706f90eafefac5d52535d0f49d2640.zip
lib/losetup: added backward compatibility for file format support
While using the new loop kernel module with file format support and an old losetup without file format support, problems occur. If losetup wants to have the loop_info structure filled by the loop kernel module, the kernel module writes across the boundaries of the old structure. A new flag called LO_FLAGS_FILE_FMT is introduced to specify the support of the loop_info extension for the file format support. If the flag is set before an - LOOP_GET_STATUS - LOOP_GET_STATUS64 - LOOP_SET_STATUS - LOOP_SET_STATUS64 ioctl call, the caller informs the kernel module about the usage of the extended loop_info structure. The module cna access the extension. Older versions of losetup do not set the flag by default and the loop module preserves the backward compatibility and do not write across the boundaries of the structure. Signed-off-by: Manuel Bentele <development@manuel-bentele.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/loopdev.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/loopdev.c b/lib/loopdev.c
index 676cc02f3..26ab402fa 100644
--- a/lib/loopdev.c
+++ b/lib/loopdev.c
@@ -665,6 +665,9 @@ struct loop_info64 *loopcxt_get_info(struct loopdev_cxt *lc)
if (fd < 0)
return NULL;
+ /* indicate that file format support is implemented in sys-utils */
+ lc->info.lo_flags |= LO_FLAGS_FILE_FMT;
+
if (ioctl(fd, LOOP_GET_STATUS64, &lc->info) == 0) {
lc->has_info = 1;
lc->info_failed = 0;
@@ -1439,6 +1442,10 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
}
do {
+ /* indicate that file format support is implemented in
+ * sys-utils */
+ lc->info.lo_flags |= LO_FLAGS_FILE_FMT;
+
err = ioctl(dev_fd, LOOP_SET_STATUS64, &lc->info);
again = err && errno == EAGAIN;
if (again)
@@ -1501,6 +1508,10 @@ int loopcxt_ioctl_status(struct loopdev_cxt *lc)
DBG(SETUP, ul_debugobj(lc, "device open: OK"));
do {
+ /* indicate that file format support is implemented in
+ * sys-utils */
+ lc->info.lo_flags |= LO_FLAGS_FILE_FMT;
+
err = ioctl(dev_fd, LOOP_SET_STATUS64, &lc->info);
again = err && errno == EAGAIN;
if (again)