From: Kay Sievers Date: Wed, 13 Jan 2010 12:18:14 +0000 (+0100) Subject: do not remove device nodes of active kernel devices X-Git-Tag: 174~637 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=889dd1061c2e09044a6c0450c06180b47288fe4f;p=systemd 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. --- diff --git a/udev/udev-node.c b/udev/udev-node.c index c80a74c2..c3df72b0 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) {