get_media_devices: don't discard virtual devices
authorMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 29 May 2011 13:58:51 +0000 (10:58 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 29 May 2011 14:12:47 +0000 (11:12 -0300)
Instead of discarding virtual devices, just consider each of
them as a new hardware.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
utils/libmedia_dev/get_media_devices.c

index c27d7f5..4a1d01f 100644 (file)
@@ -100,10 +100,12 @@ static int get_class(char *class,
        char            dname[512];
        char            fname[512];
        char            link[1024];
+       char            virt_dev[60];
        int             err = -2;
        struct          media_device_entry *md_ptr = NULL;
        int             size;
        char            *p, *class_node, *device;
+       static int      virtual = 0;
 
        sprintf(dname, "/sys/class/%s", class);
        dir = opendir(dname);
@@ -150,9 +152,11 @@ static int get_class(char *class,
                                } while (1);
                        }
 
-                       /* Don't handle virtual devices */
-                       if (!strcmp(device, "virtual"))
-                               continue;
+                       /* Don't group virtual devices */
+                       if (!strcmp(device, "virtual")) {
+                               sprintf(virt_dev, "virtual%d", virtual++);
+                               device = virt_dev;
+                       }
 
                        /* Add one more element to the devices struct */
                        *md = realloc(*md, (*md_size + 1) * sizeof(*md_ptr));