diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2010-01-13 13:18:14 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2010-01-13 13:18:14 +0100 |
commit | 889dd1061c2e09044a6c0450c06180b47288fe4f (patch) | |
tree | 77cb2d3f9e1d075cfb53bb06d90aa940a8cb04d7 | |
parent | 6f1892dc7abb26ca988521c89d563dd38a0349c0 (diff) |
do not remove device nodes of active kernel devices
We do no longer delete the primary device node while handling "remove"
events if the same kernel device is already re-created in the meantime.
This prevents the asynchronously running udev from removing and re-creating
primary device nodes for active devices.
-rw-r--r-- | udev/udev-node.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/udev/udev-node.c b/udev/udev-node.c index c80a74c218..c3df72b0d5 100644 --- a/udev/udev-node.c +++ b/udev/udev-node.c @@ -422,10 +422,11 @@ int udev_node_remove(struct udev_device *dev) const char *devnode; char partitionname[UTIL_PATH_SIZE]; struct stat stats; + struct udev_device *dev_check; int err = 0; int num; - /* remove,update symlinks, remove symlinks from name index */ + /* remove/update symlinks, remove symlinks from name index */ udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(dev)) link_update(dev, udev_list_entry_get_name(list_entry), 0); @@ -441,10 +442,15 @@ int udev_node_remove(struct udev_device *dev) return -1; } - info(udev, "removing device node '%s'\n", devnode); - err = util_unlink_secure(udev, devnode); - if (err) - return err; + dev_check = udev_device_new_from_syspath(udev, udev_device_get_syspath(dev)); + if (dev_check != NULL && stats.st_rdev == udev_device_get_devnum(dev_check)) { + /* do not remove device node if the same sys-device is re-created in the meantime */ + info(udev, "keeping device node '%s'\n", devnode); + } else { + info(udev, "removing device node '%s'\n", devnode); + err = util_unlink_secure(udev, devnode); + } + udev_device_unref(dev_check); num = udev_device_get_num_fake_partitions(dev); if (num > 0) { |