summaryrefslogtreecommitdiffstats
path: root/tools/dmsetup.c
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2009-11-13 12:43:21 +0000
committerPeter Rajnoha <prajnoha@redhat.com>2009-11-13 12:43:21 +0000
commit584d1fb7d1c6e55eac8d6ad04568e49af723a266 (patch)
treeca4d206097bd2939841c238e1f69efddf7bdbf0d /tools/dmsetup.c
parent9c20c7af59f5dca84446143f6233fe5533097144 (diff)
downloadlvm2-584d1fb7d1c6e55eac8d6ad04568e49af723a266.tar.gz
lvm2-584d1fb7d1c6e55eac8d6ad04568e49af723a266.tar.xz
lvm2-584d1fb7d1c6e55eac8d6ad04568e49af723a266.zip
Support udev flags even when udev_sync is disabled or not compiled in.
This provides better support for environments where udev rules are installed but udev_sync is not compiled in (however, using udev_sync is highly recommended). It also provides consistent and expected functionality even when '--noudevsync' option is used. There is still requirement for kernel >= 2.6.31 for the flags to work though (it uses DM cookies to pass the flags into the kernel and set them in udev event environment that we can read in udev rules).
Diffstat (limited to 'tools/dmsetup.c')
-rw-r--r--tools/dmsetup.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 186f8f0c..888edffb 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -843,9 +843,17 @@ static int _udevcomplete(int argc, char **argv, void *data __attribute((unused))
if (!(cookie = _get_cookie_value(argv[1])))
return 0;
- /* strip flags from the cookie and use cookie magic instead */
- cookie = (cookie & ~DM_UDEV_FLAGS_MASK) |
- (DM_COOKIE_MAGIC << DM_UDEV_FLAGS_SHIFT);
+ /*
+ * Strip flags from the cookie and use cookie magic instead.
+ * If the cookie has non-zero prefix and the base is zero then
+ * this one carries flags to control udev rules only and it is
+ * not meant to be for notification. Return with success in this
+ * situation.
+ */
+ if (!(cookie &= ~DM_UDEV_FLAGS_MASK))
+ return 1;
+
+ cookie |= DM_COOKIE_MAGIC << DM_UDEV_FLAGS_SHIFT;
return dm_udev_complete(cookie);
}