diff options
Diffstat (limited to 'udev-remove.c')
-rw-r--r-- | udev-remove.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/udev-remove.c b/udev-remove.c index 41636b684e..98c45d6c33 100644 --- a/udev-remove.c +++ b/udev-remove.c @@ -135,22 +135,38 @@ int udev_remove_device(char *path, char *subsystem) char *temp; int retval; - memset(&dev, 0, sizeof(dev)); + memset(&dev, 0x00, sizeof(dev)); - retval = udevdb_get_dev(path, &dev); - if (retval) { - dbg("'%s' not found in database, falling back on default name", path); - temp = strrchr(path, '/'); - if (temp == NULL) - return -ENODEV; - strfieldcpy(dev.name, &temp[1]); - } + dev.type = get_device_type(path, subsystem); + + switch (dev.type) { + case 'b': + case 'c': + retval = udevdb_get_dev(path, &dev); + if (retval) { + dbg("'%s' not found in database, falling back on default name", path); + temp = strrchr(path, '/'); + if (temp == NULL) + return -ENODEV; + strfieldcpy(dev.name, &temp[1]); + } - dbg("name is '%s'", dev.name); - udevdb_delete_dev(path); + dbg("name='%s'", dev.name); + udevdb_delete_dev(path); - dev_d_send(&dev, subsystem); + dev_d_send(&dev, subsystem); + + retval = delete_node(&dev); + break; + + case 'n': + retval = 0; + break; + + default: + dbg("unknown device type '%c'", dev.type); + retval = -EINVAL; + } - retval = delete_node(&dev); return retval; } |