* [PATCH] kpartx: use inode to identify loopback mounts
@ 2015-07-06 11:56 Risto Kankkunen
2015-10-06 7:14 ` Christophe Varoqui
0 siblings, 1 reply; 2+ messages in thread
From: Risto Kankkunen @ 2015-07-06 11:56 UTC (permalink / raw)
To: dm-devel; +Cc: Risto Kankkunen
[-- Attachment #1: Type: text/plain, Size: 510 bytes --]
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.
[-- Attachment #2: 0014-kpartx-long-path.patch --]
[-- Type: text/plain, Size: 1366 bytes --]
From: Risto Kankkunen <risto.kankkunen@f-secure.com>
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 */
}
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] kpartx: use inode to identify loopback mounts
2015-07-06 11:56 [PATCH] kpartx: use inode to identify loopback mounts Risto Kankkunen
@ 2015-10-06 7:14 ` Christophe Varoqui
0 siblings, 0 replies; 2+ messages in thread
From: Christophe Varoqui @ 2015-10-06 7:14 UTC (permalink / raw)
To: device-mapper development; +Cc: Risto Kankkunen
[-- Attachment #1.1: Type: text/plain, Size: 743 bytes --]
Applied, finally.
Thanks.
On Mon, Jul 6, 2015 at 1:56 PM, Risto Kankkunen <
risto.kankkunen@f-secure.com> wrote:
> 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.
>
> --
> dm-devel mailing list
> dm-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel
>
[-- Attachment #1.2: Type: text/html, Size: 1321 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-06 7:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-06 11:56 [PATCH] kpartx: use inode to identify loopback mounts Risto Kankkunen
2015-10-06 7:14 ` Christophe Varoqui
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.