summaryrefslogtreecommitdiff
path: root/libdm/libdm-common.c
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2014-03-17 11:51:30 +0100
committerPeter Rajnoha <prajnoha@redhat.com>2014-03-17 11:51:30 +0100
commit12eb284eecc631096e31384537289a3376617580 (patch)
tree67dd1d89b406e7a93db5843646adf0742f1082ad /libdm/libdm-common.c
parentb16235de96a18c9e9e619bebe506d41f80fff834 (diff)
downloadlvm2-12eb284eecc631096e31384537289a3376617580.tar.gz
tests: fix name-mangling test
We need to use "--verifyudev" for dmsetup mangle command used in the name-mangling test since without the --verifyudev, we'd end up with the failed rename. Also, add direct check for the dev nodes - node with old name must be gone and node with new name must be present. Before, we checked just the output of the command. One bug popped up here when renaming with udev and libdevmapper fallback checking the udev when target mangle mode is "none" (fixme added in the libdevmapper's node rename code).
Diffstat (limited to 'libdm/libdm-common.c')
-rw-r--r--libdm/libdm-common.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index 2ec66e7e3..72fa508c0 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -1073,6 +1073,24 @@ static int _rename_dev_node(const char *old_name, const char *new_name,
oldpath, newpath);
/* udev may already have renamed the node. Ignore ENOENT. */
+ /* FIXME: when renaming to target mangling mode "none" with udev
+ * while there are some blacklisted characters in the node name,
+ * udev will remove the old_node, but fails to properly rename
+ * to new_node. The libdevmapper code tries to call
+ * rename(old_node,new_node), but that won't do anything
+ * since the old node is already removed by udev.
+ * For example renaming 'a\x20b' to 'a b':
+ * - udev removes 'a\x20b'
+ * - udev creates 'a' and 'b' (since it considers the ' ' as a delimiter
+ * - libdevmapper checks udev has done the rename properly
+ * - libdevmapper calls stat(new_node) and it does not see it
+ * - libdevmapper calls rename(old_node,new_node)
+ * - the rename is a NOP since the old_node does not exist anymore
+ *
+ * However, this situation is very rare - why would anyone need
+ * to rename to an unsupported mode??? So a fix for this would be
+ * just for completeness.
+ */
if (rename(oldpath, newpath) < 0 && errno != ENOENT) {
log_error("Unable to rename device node from '%s' to '%s'",
old_name, new_name);