summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2016-07-08 17:06:35 +0100
committerBryn M. Reeves <bmr@redhat.com>2016-07-08 17:11:51 +0100
commite2d8ac9dd92c6c837ea55eb3c2d87ffc2f554009 (patch)
treec4384cbe014c8732604ac03f168fe6c4033b884f
parent9ac84614f46d439d9954a3bd70ddd0d47df436a7 (diff)
downloadlvm2-dev-bmr-dmstats-grphist.tar.gz
dmstats: use canonical path when reporting errorsdev-bmr-dmstats-grphist
When a 'dmstats create --filemap' operation fails (e.g. during open(2), close(2), or dm_stats_create_regions_from_fd()), use the canonical version of the path. This avoids cryptic/confusing error messages when symbolic links exist in the path argument given: # findmnt /var/lib/libvirt/images -otarget,source TARGET SOURCE /var/lib/libvirt/images /dev/mapper/vg_hex-lv_images # readlink /var/lib/libvirt/images/my.img /boot/my.img # dmstats create --filemap /var/lib/libvirt/images/my.img Cannot map file: not a device-mapper device. Could not create regions from file /var/lib/libvirt/images/my.img Command failed Using the canonical path the error is immediately obvious: # dmstats create --filemap /var/lib/libvirt/images/my.img Cannot map file: not a device-mapper device. Could not create regions from file /boot/my.img Command failed
-rw-r--r--tools/dmsetup.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index eb7c83a24..34e33d30c 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -5034,7 +5034,7 @@ static int _stats_create_file(CMD_ARGS)
fd = open(abspath, O_RDONLY);
if (fd < 0) {
- log_error("Could not open %s for reading", path);
+ log_error("Could not open %s for reading", abspath);
goto bad;
}
@@ -5060,12 +5060,12 @@ static int _stats_create_file(CMD_ARGS)
bounds, alias);
if (close(fd))
- log_error("Error closing %s", path);
+ log_error("Error closing %s", abspath);
fd = -1;
if (!regions) {
- log_error("Could not create regions from file %s", path);
+ log_error("Could not create regions from file %s", abspath);
goto bad;
}