From dbfb57058683ae054bf910815072851f52e69a20 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Tue, 1 Nov 2011 13:33:33 +0100 Subject: [PATCH] do not skip /dev/{disk,char}/M:m removal when the device node is already gone --- udev/udev-node.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/udev/udev-node.c b/udev/udev-node.c index f19dc4d9..44d3686d 100644 --- a/udev/udev-node.c +++ b/udev/udev-node.c @@ -416,20 +416,19 @@ int udev_node_remove(struct udev_device *dev) if (devnode == NULL) goto out; - if (stat(devnode, &stats) != 0) { - info(udev, "device node '%s' not found\n", devnode); - goto out; - } - - if (stats.st_rdev != udev_device_get_devnum(dev)) { - info(udev, "device node '%s' points to a different device, skip removal\n", devnode); - err = -1; - goto out; - } + if (stat(devnode, &stats) == 0) { + if (stats.st_rdev != udev_device_get_devnum(dev)) { + info(udev, "device node '%s' points to a different device, skip removal\n", devnode); + err = -1; + goto out; + } - if (stats.st_mode & 01000) { - info(udev, "device node '%s' has sticky bit set, skip removal\n", devnode); - goto out; + if (stats.st_mode & 01000) { + info(udev, "device node '%s' has sticky bit set, skip removal\n", devnode); + goto out; + } + } else { + info(udev, "device node '%s' not found\n", devnode); } dev_check = udev_device_new_from_syspath(udev, udev_device_get_syspath(dev)); -- 2.39.5