block: allow remove hotplug event to arrive at blockd
[project/fstools.git] / probe.c
diff --git a/probe.c b/probe.c
index 9983a723d5e6ea73375f1803b35d51a34c603661..ab1bc617515a209e0d398a9591922951325bba22 100644 (file)
--- a/probe.c
+++ b/probe.c
@@ -21,45 +21,52 @@ static struct probe_info *
 probe_path_tiny(const char *path)
 {
        struct probe_info *info = NULL;
-       struct blkid_struct_probe pr = { };
-       char *type, *dev, *uuid, *label, *name, *version;
+       struct blkid_struct_probe *pr;
+       char *type, *dev, *uuid, *label, *version;
 
-       if (probe_block((char *)path, &pr) == 0 && pr.id && !pr.err) {
+       pr = blkidtiny_new_probe();
+       if (!pr)
+               return NULL;
+
+       if (probe_block((char *)path, pr) == 0 && pr->id && !pr->err) {
                info = calloc_a(sizeof(*info),
-                               &type,    strlen(pr.id->name) + 1,
-                               &dev,     strlen(pr.dev)      + 1,
-                               &uuid,    strlen(pr.uuid)     + 1,
-                               &label,   strlen(pr.label)    + 1,
-                               &name,    strlen(pr.name)     + 1,
-                               &version, strlen(pr.version)  + 1);
+                               &type,    strlen(pr->id->name) + 1,
+                               &dev,     strlen(path)         + 1,
+                               &uuid,    strlen(pr->uuid)     + 1,
+                               &label,   strlen(pr->label)    + 1,
+                               &version, strlen(pr->version)  + 1);
 
                if (info) {
-                       info->type = strcpy(type, pr.id->name);
-                       
-                       if (pr.dev[0])
-                               info->dev = strcpy(dev, pr.dev);
-
-                       if (pr.uuid[0])
-                               info->uuid = strcpy(uuid, pr.uuid);
+                       info->type = strcpy(type, pr->id->name);
+                       info->dev = strcpy(dev, path);
 
-                       if (pr.label[0])
-                               info->label = strcpy(label, pr.label);
+                       if (pr->uuid[0])
+                               info->uuid = strcpy(uuid, pr->uuid);
 
-                       if (pr.name[0])
-                               info->name = strcpy(name, pr.name);
+                       if (pr->label[0])
+                               info->label = strcpy(label, pr->label);
 
-                       if (pr.version[0])
-                               info->version = strcpy(version, pr.version);
+                       if (pr->version[0])
+                               info->version = strcpy(version, pr->version);
                }
        }
 
+       blkidtiny_free_probe(pr);
+
        return info;
 }
 
-struct probe_info * 
+struct probe_info *
 probe_path(const char *path)
 {
-       return probe_path_tiny(path);
+       struct probe_info *info;
+
+       info = probe_path_tiny(path);
+
+       if (!info)
+               info = probe_path_libblkid(path);
+
+       return info;
 }
 
 int