summaryrefslogtreecommitdiff
path: root/udev_remove.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2005-02-18 03:30:03 +0100
committerGreg KH <gregkh@suse.de>2005-04-26 23:36:13 -0700
commit1cec1c241600fc11121f9504bc9e95836c03bd9c (patch)
tree7ce2ccaa9ea5c15c3289726c2c2698ae8762f031 /udev_remove.c
parent3f930093f9ac79dca6bcc2dcbc8714c143709478 (diff)
[PATCH] remove the device node only if the major/minor number matches
Diffstat (limited to 'udev_remove.c')
-rw-r--r--udev_remove.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/udev_remove.c b/udev_remove.c
index 172ec12690..baafdea51a 100644
--- a/udev_remove.c
+++ b/udev_remove.c
@@ -71,6 +71,7 @@ static int delete_node(struct udevice *udev)
{
char filename[NAME_SIZE];
char partitionname[NAME_SIZE];
+ struct stat stats;
int retval;
int i;
char *pos;
@@ -80,6 +81,15 @@ static int delete_node(struct udevice *udev)
snprintf(filename, NAME_SIZE, "%s/%s", udev_root, udev->name);
filename[NAME_SIZE-1] = '\0';
+ dbg("checking major/minor of device node '%s'", filename);
+ if (stat(filename, &stats) != 0)
+ return -1;
+
+ if (udev->major && stats.st_rdev != makedev(udev->major, udev->minor)) {
+ info("device node '%s' points to a different device, skip removal", filename);
+ return -1;
+ }
+
info("removing device node '%s'", filename);
retval = unlink_secure(filename);
if (retval)