This is a patch which I submitted to Launchpad
(https://bugs.launchpad.net/ubuntu/+source/multipath-tools/+bug/1469143). I
was told to submit it to this list instead.
Currently kpartx doesn't work correctly with relative path names,
hardlinks, symlinks or paths longer than 63 characters. This is because
it tries to identify mounts by a non-unique name it gives to the mount.
The loopinfo struct contains the device and inode information of the
backing image, it is better to identify mounts by those.
From: Risto Kankkunen <risto.kankkunen@xxxxxxxxxxxx>
Date: Mon, 29 Jun 2015 18:39:48 +0300
Subject: Use image file device/inode to find the correct loop device in kpartx
Previously kpartx used the "lo_name" field of struct loop_info to store
and match the image file name. That field is not intended to store path
names (it's not big enough). Therefore kpartx was unable to delete
mappings to file paths longer than 63 characters. It also didn't
properly handle relative file paths: two different files with identical
relative path names could not be mapped. Instead kpartx would modify
the existing mapping when seeing a new file with the same relative path.
The "loopinfo" structure contains the image file device and inode
numbers. Use those to uniquely identify the correct loop device.
--- a/kpartx/lopart.c
+++ b/kpartx/lopart.c
@@ -103,6 +103,14 @@
int i, j, fd;
struct stat statbuf;
struct loop_info loopinfo;
+ dev_t file_dev;
+ ino_t file_ino;
+
+ if (stat (filename, &statbuf) != 0) {
+ return NULL;
+ }
+ file_dev = statbuf.st_dev;
+ file_ino = statbuf.st_ino;
for (j = 0; j < SIZE(loop_formats); j++) {
@@ -123,7 +131,7 @@
continue;
}
- if (0 == strcmp(filename, loopinfo.lo_name)) {
+ if (loopinfo.lo_device == file_dev && loopinfo.lo_inode == file_ino) {
close (fd);
return xstrdup(dev); /*found */
}
--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel