huge bugfix patch for eeze 1.0 stuff: I fubared disk detection pretty hard initially...
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 17 May 2011 00:14:44 +0000 (00:14 +0000)
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 17 May 2011 00:14:44 +0000 (00:14 +0000)
SVN revision: 59458

legacy/eeze/src/bin/eeze_udev_test.c
legacy/eeze/src/lib/Eeze.h
legacy/eeze/src/lib/eeze_udev_find.c
legacy/eeze/src/lib/eeze_udev_private.c
legacy/eeze/src/lib/eeze_udev_watch.c

index fdf24a6594f4dbd1df5df980cf82568bda46db40..609325f121ee6e696b5b43de4773c0c8380f6a9d 100644 (file)
@@ -194,10 +194,10 @@ main()
    type = eeze_udev_find_unlisted_similar(type);
    EINA_LIST_FREE(type, name)  /* get a property using the device's syspath */
      {
-        if ((check = eeze_udev_syspath_get_property(name, "ID_MODEL")))
+        if ((check = eeze_udev_syspath_get_sysattr(name, "model")))
           {
-             check2 = eeze_udev_syspath_get_property(name, "ID_BUS");
-             printf("\tOoh, a %s attached on your %s bus!\n", check, check2);
+             check2 = eeze_udev_syspath_get_subsystem(name);
+             printf("\tOoh, a %s attached to the %s subsytem!\n", check, check2);
              eina_stringshare_del(check);
              eina_stringshare_del(check2);
           }
index d46712d8f0b7776c5c3ac3815d096ea60ee93d1f..80582011d6ce626c66c0cabbb18b7a7b21143afc 100644 (file)
@@ -292,6 +292,8 @@ EAPI Eina_List       *eeze_udev_find_similar_from_syspath(const char *syspath);
  * This function will update @p list to include all devices matching
  * devices with syspaths currently stored in @p list.  All strings are
  * stringshared.
+ *
+ * @note This is an expensive call, do not use it unless you must.
  */
 EAPI Eina_List       *eeze_udev_find_unlisted_similar(Eina_List *list);
 
index 51fcca92b9dfa447aed28b4ac54face54bcf311b..9af93641956d24ee266892fe7edec5be22491a96 100644 (file)
@@ -96,18 +96,28 @@ eeze_udev_find_unlisted_similar(Eina_List *list)
 
         if ((vendor = udev_device_get_property_value(device, "ID_VENDOR_ID")))
           udev_enumerate_add_match_property(en, "ID_VENDOR_ID", vendor);
-        else
-        if ((vendor = udev_device_get_property_value(device, "ID_VENDOR")))
+        else if ((vendor = udev_device_get_property_value(device, "ID_VENDOR")))
           udev_enumerate_add_match_property(en, "ID_VENDOR", vendor);
+        else if ((vendor = udev_device_get_sysattr_value(device, "vendor")))
+          udev_enumerate_add_match_sysattr(en, "vendor", vendor);
+        else if ((vendor = udev_device_get_sysattr_value(device, "manufacturer")))
+          udev_enumerate_add_match_sysattr(en, "manufacturer", vendor);
 
         if ((model = udev_device_get_property_value(device, "ID_MODEL_ID")))
           udev_enumerate_add_match_property(en, "ID_MODEL_ID", model);
-        else
-        if ((model = udev_device_get_property_value(device, "ID_MODEL")))
+        else if ((model = udev_device_get_property_value(device, "ID_MODEL")))
           udev_enumerate_add_match_property(en, "ID_MODEL", model);
+        else if ((model = udev_device_get_sysattr_value(device, "model")))
+          udev_enumerate_add_match_sysattr(en, "model", model);
+        else if ((model = udev_device_get_sysattr_value(device, "product")))
+          udev_enumerate_add_match_sysattr(en, "product", model);
 
         if ((revision = udev_device_get_property_value(device, "ID_REVISION")))
           udev_enumerate_add_match_property(en, "ID_REVISION", revision);
+        else if ((revision = udev_device_get_sysattr_value(device, "revision")))
+          udev_enumerate_add_match_sysattr(en, "revision", revision);
+
+        udev_enumerate_add_match_subsystem(en, udev_device_get_subsystem(device));
 
         udev_enumerate_scan_devices(en);
         udev_device_unref(device);
@@ -137,7 +147,7 @@ eeze_udev_find_by_type(Eeze_Udev_Type etype,
    _udev_enumerate *en;
    _udev_list_entry *devs, *cur;
    _udev_device *device, *parent;
-   const char *devname, *test;
+   const char *devname;
    Eina_List *ret = NULL;
 
    if ((!etype) && (!name))
@@ -181,8 +191,6 @@ eeze_udev_find_by_type(Eeze_Udev_Type etype,
       case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
         udev_enumerate_add_match_subsystem(en, "block");
         udev_enumerate_add_match_property(en, "ID_FS_USAGE", "filesystem");
-        /* parent node */
-        udev_enumerate_add_nomatch_sysattr(en, "capability", "50");
         break;
 
       case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
@@ -193,12 +201,11 @@ eeze_udev_find_by_type(Eeze_Udev_Type etype,
         break;
 
       case EEZE_UDEV_TYPE_DRIVE_REMOVABLE:
-        udev_enumerate_add_match_subsystem(en, "block");
+        udev_enumerate_add_match_sysattr(en, "removable", "1");
         udev_enumerate_add_match_property(en, "ID_TYPE", "disk");
         break;
 
       case EEZE_UDEV_TYPE_DRIVE_CDROM:
-        udev_enumerate_add_match_subsystem(en, "block");
         udev_enumerate_add_match_property(en, "ID_CDROM", "1");
         break;
 
@@ -258,21 +265,16 @@ eeze_udev_find_by_type(Eeze_Udev_Type etype,
                     goto out;
                }
           }
-        else if (etype == EEZE_UDEV_TYPE_DRIVE_INTERNAL)
-          {
-             if (udev_device_get_property_value(device, "ID_USB_DRIVER"))
-               goto out;
-          }
         else if (etype == EEZE_UDEV_TYPE_DRIVE_REMOVABLE)
           {
-             if (!(test = udev_device_get_property_value(device, "ID_BUS")) || (!strncmp(test, "ata", 3)))
-               goto out;
+             /* this yields the actual hw device, not to be confused with the filesystem */
+             devname = udev_device_get_syspath(udev_device_get_parent(device));
           }
         else if (etype == EEZE_UDEV_TYPE_DRIVE_MOUNTABLE)
           {
              int devcheck;
 
-             devcheck = open(udev_device_get_devnode(device), O_RDONLY | O_EXCL);
+             devcheck = open(udev_device_get_devnode(device), O_RDONLY);
              if (devcheck < 0) goto out;
              close(devcheck);
           }
index c94e4a35f4a498d4ccf9d75e3c4e0c04040145cc..b9989182affad34c691953b211f3003118d73efa 100644 (file)
@@ -111,9 +111,13 @@ _get_unlisted_parents(Eina_List    *list,
 
    if (!(vendor = udev_device_get_property_value(child, "ID_VENDOR_ID")))
      vendor = udev_device_get_property_value(child, "ID_VENDOR");
+   if (!vendor) vendor = udev_device_get_sysattr_value(child, "vendor");
+   if (!vendor) vendor = udev_device_get_sysattr_value(child, "manufacturer");
 
    if (!(model = udev_device_get_property_value(child, "ID_MODEL_ID")))
      model = udev_device_get_property_value(child, "ID_MODEL");
+   if (!model) model = udev_device_get_sysattr_value(child, "model");
+   if (!model) model = udev_device_get_sysattr_value(child, "product");
 
    parent = udev_device_get_parent(child);
 
@@ -123,9 +127,13 @@ _get_unlisted_parents(Eina_List    *list,
 
         if (!(vendor2 = udev_device_get_property_value(child, "ID_VENDOR_ID")))
           vendor2 = udev_device_get_property_value(child, "ID_VENDOR");
+        if (!vendor2) vendor2 = udev_device_get_sysattr_value(child, "vendor");
+        if (!vendor2) vendor2 = udev_device_get_sysattr_value(child, "manufacturer");
 
         if (!(model2 = udev_device_get_property_value(child, "ID_MODEL_ID")))
           model2 = udev_device_get_property_value(child, "ID_MODEL");
+        if (!model2) model2 = udev_device_get_sysattr_value(child, "model");
+        if (!model2) model2 = udev_device_get_sysattr_value(child, "product");
 
         if ((!model2 && model) || (model2 && !model) || (!vendor2 && vendor)
             || (vendor2 && !vendor))
index f9cc95ba2fa4109d3ee30c013bd86cfb1b70148d..19d341391855e4fcd9e32bd5aa727ac792d9f66c 100644 (file)
@@ -48,7 +48,7 @@ _get_syspath_from_watch(void             *data,
    Eeze_Udev_Watch_Cb func = store->func;
    void *sdata = store->data;
    Eeze_Udev_Watch *watch = store->watch;
-   int cap = 0, event = 0;
+   int event = 0;
 
    if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
      return EINA_TRUE;
@@ -171,18 +171,13 @@ _get_syspath_from_watch(void             *data,
             || (strcmp(test, "block")))
           goto error;
 #endif
-        test = udev_device_get_sysattr_value(device, "capability");
-
-        if (test)
-          cap = strtol(test, NULL, 10);
-
         if (!(test = (udev_device_get_property_value(device, "ID_FS_USAGE"))) ||
-            (strcmp("filesystem", test)) || (cap == 50))
+            (strcmp("filesystem", test)))
           goto error;
         {
            int devcheck;
 
-           devcheck = open(udev_device_get_devnode(device), O_RDONLY | O_EXCL);
+           devcheck = open(udev_device_get_devnode(device), O_RDONLY);
            if (devcheck < 0) goto error;
            close(devcheck);
         }
@@ -190,39 +185,20 @@ _get_syspath_from_watch(void             *data,
         break;
 
       case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
-#ifdef OLD_UDEV_RRRRRRRRRRRRRR
-        if ((!(test = udev_device_get_subsystem(device)))
-            || (strcmp(test, "block")))
-          goto error;
-#endif
-        if (!(test = udev_device_get_property_value(device, "ID_BUS"))
-            || (strcmp("ata", test))
-            || !(test = udev_device_get_sysattr_value(device, "removable"))
-            || (strtol(test, NULL, 10)))
-          goto error;
+        if (udev_device_get_property_value(device, "ID_FS_USAGE")) goto error;
+        test = udev_device_get_sysattr_value(device, "removable");
+        if (test[0] == '1') goto error;
 
         break;
 
       case EEZE_UDEV_TYPE_DRIVE_REMOVABLE:
-#ifdef OLD_UDEV_RRRRRRRRRRRRRR
-        if ((!(test = udev_device_get_subsystem(device)))
-            || (strcmp(test, "block")))
-          goto error;
-#endif
-        if ((!(test = udev_device_get_sysattr_value(device, "removable"))
-             || (!strtol(test, NULL, 10)))
-            && (!(test = udev_device_get_sysattr_value(device, "capability"))
-                || (strtol(test, NULL, 10) != 10)))
-          goto error;
+        if (udev_device_get_property_value(device, "ID_FS_USAGE")) goto error;
+        test = udev_device_get_sysattr_value(device, "removable");
+        if (test[0] == '0') goto error;
 
         break;
 
       case EEZE_UDEV_TYPE_DRIVE_CDROM:
-#ifdef OLD_UDEV_RRRRRRRRRRRRRR
-        if ((!(test = udev_device_get_subsystem(device)))
-            || (strcmp(test, "block")))
-          goto error;
-#endif
         if (!udev_device_get_property_value(device, "ID_CDROM"))
           goto error;
 
@@ -338,11 +314,11 @@ eeze_udev_watch_add(Eeze_Udev_Type     type,
         break;
 
       case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
-        udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
+        udev_monitor_filter_add_match_subsystem_devtype(mon, NULL, "disk");
         break;
 
       case EEZE_UDEV_TYPE_DRIVE_REMOVABLE:
-        udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
+        udev_monitor_filter_add_match_subsystem_devtype(mon, NULL, "disk");
         break;
 
       case EEZE_UDEV_TYPE_DRIVE_CDROM: