OSDN Git Service

devices: allow sending on device-add notifications for major/minor-less devices
authorOctavian Purdila <octavian.purdila@intel.com>
Thu, 27 Sep 2012 16:28:43 +0000 (19:28 +0300)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Sun, 16 Jun 2013 06:52:01 +0000 (14:52 +0800)
This is usefull for getting device plug/unplug notifications for
things like USB ethernet adapters which do not have major/minor
numbers.

Change-Id: I8f032ef983aeb36dd013fafc4a5df5238decbb17
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
init/devices.c

index b5c41a8..5e58538 100644 (file)
@@ -503,7 +503,8 @@ static void handle_device(const char *action, const char *devpath,
     int i;
 
     if(!strcmp(action, "add")) {
-        make_device(devpath, path, block, major, minor);
+        if (major >= 0 && minor >= 0)
+            make_device(devpath, path, block, major, minor);
         __system_property_set("ctl.dev_added",devpath);
         if (links) {
             for (i = 0; links[i]; i++)
@@ -517,7 +518,8 @@ static void handle_device(const char *action, const char *devpath,
                 remove_link(devpath, links[i]);
         }
         __system_property_set("ctl.dev_removed",devpath);
-        unlink(devpath);
+        if (major >= 0 && minor >= 0)
+            unlink(devpath);
     }
 
     if (links) {
@@ -541,10 +543,6 @@ static const char *parse_device_name(struct uevent *uevent, unsigned int len)
 {
     const char *name;
 
-    /* if it's not a /dev device, nothing else to do */
-    if((uevent->major < 0) || (uevent->minor < 0))
-        return NULL;
-
     /* do we have a name? */
     name = strrchr(uevent->path, '/');
     if(!name)