chiark / gitweb /
udevinfo: do not replace chars when printing ATTR== matches
[elogind.git] / extras / volume_id / lib / volume_id.c
index 59303d5bffce2f2e8228f33980bf7a385151d3ee..e8f6de35fdc607ca058c206c8ae1a6aa4c123b40 100644 (file)
@@ -86,7 +86,7 @@ static void default_log(int priority, const char *file, int line, const char *fo
 volume_id_log_fn_t volume_id_log_fn = default_log;
 
 /**
- * volume_id_get_label:
+ * volume_id_get_prober_by_type:
  * @type: Type string.
  *
  * Lookup the probing function for a specific type.
@@ -330,6 +330,14 @@ err:
        return 0;
 }
 
+/* run only once into a timeout for unreadable devices */
+static int device_is_readable(struct volume_id *id)
+{
+       if (volume_id_get_buffer(id, 0x00, 0x200) != NULL)
+               return 1;
+       return 0;
+}
+
 /**
  * volume_id_probe_raid:
  * @id: Probing context.
@@ -347,6 +355,9 @@ int volume_id_probe_raid(struct volume_id *id, uint64_t off, uint64_t size)
        if (id == NULL)
                return -EINVAL;
 
+       if (!device_is_readable(id))
+               return -1;
+
        info("probing at offset 0x%llx, size 0x%llx",
            (unsigned long long) off, (unsigned long long) size);
 
@@ -378,6 +389,9 @@ int volume_id_probe_filesystem(struct volume_id *id, uint64_t off, uint64_t size
        if (id == NULL)
                return -EINVAL;
 
+       if (!device_is_readable(id))
+               return -1;
+
        info("probing at offset 0x%llx, size 0x%llx",
            (unsigned long long) off, (unsigned long long) size);
 
@@ -407,6 +421,9 @@ int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size)
        if (id == NULL)
                return -EINVAL;
 
+       if (!device_is_readable(id))
+               return -1;
+
        /* probe for raid first, because fs probes may be successful on raid members */
        if (volume_id_probe_raid(id, off, size) == 0)
                return 0;