chiark / gitweb /
volume_id: split raid and filesystem detection
authorKay Sievers <kay.sievers@suse.de>
Tue, 21 Feb 2006 17:48:28 +0000 (18:48 +0100)
committerKay Sievers <kay.sievers@suse.de>
Tue, 21 Feb 2006 17:48:28 +0000 (18:48 +0100)
extras/volume_id/libvolume_id/volume_id.c
extras/volume_id/libvolume_id/volume_id.h

index 09d1e317257f66b9bc7291b2ae3f8201feaa3b5a..1daf1cbd74c4e0685fc4c6eb8e3402ae5fee0556 100644 (file)
@@ -31,7 +31,7 @@
 #include "util.h"
 
 
 #include "util.h"
 
 
-int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size)
+int volume_id_probe_raid(struct volume_id *id, uint64_t off, uint64_t size)
 {
        if (id == NULL)
                return -EINVAL;
 {
        if (id == NULL)
                return -EINVAL;
@@ -72,6 +72,17 @@ int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size)
        if (volume_id_probe_highpoint_37x_raid(id, off) == 0)
                goto exit;
 
        if (volume_id_probe_highpoint_37x_raid(id, off) == 0)
                goto exit;
 
+exit:
+       /* If recognized, we free the allocated buffers */
+       volume_id_free_buffer(id);
+       return 0;
+}
+
+int volume_id_probe_filesystem(struct volume_id *id, uint64_t off, uint64_t size)
+{
+       if (id == NULL)
+               return -EINVAL;
+
        if (volume_id_probe_luks(id, off) == 0)
                goto exit;
 
        if (volume_id_probe_luks(id, off) == 0)
                goto exit;
 
@@ -139,13 +150,25 @@ int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size)
        return -1;
 
 exit:
        return -1;
 
 exit:
-       /* If the filestystem in recognized, we free the allocated buffers,
-          otherwise they will stay in place for the possible next probe call */
+       /* If recognized, we free the allocated buffers */
        volume_id_free_buffer(id);
        volume_id_free_buffer(id);
-
        return 0;
 }
 
        return 0;
 }
 
+int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size)
+{
+       if (id == NULL)
+               return -EINVAL;
+
+       if (volume_id_probe_raid(id, off, size) == 0)
+               return 0;
+
+       if (volume_id_probe_filesystem(id, off, size) == 0)
+               return 0;
+
+       return -1;
+}
+
 /* open volume by already open file descriptor */
 struct volume_id *volume_id_open_fd(int fd)
 {
 /* open volume by already open file descriptor */
 struct volume_id *volume_id_open_fd(int fd)
 {
index 0f265a584da2668ba3283485f63701a26d0e9329..2caf75f532eeaf80326226f83dd2828862d3118e 100644 (file)
@@ -14,7 +14,7 @@
 #include <stdint.h>
 #include <stddef.h>
 
 #include <stdint.h>
 #include <stddef.h>
 
-#define VOLUME_ID_VERSION              56
+#define VOLUME_ID_VERSION              57
 
 #ifndef PACKED
 #define PACKED                         __attribute__((packed))
 
 #ifndef PACKED
 #define PACKED                         __attribute__((packed))
@@ -73,6 +73,8 @@ struct volume_id {
 extern struct volume_id *volume_id_open_fd(int fd);
 extern struct volume_id *volume_id_open_node(const char *path);
 extern int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size);
 extern struct volume_id *volume_id_open_fd(int fd);
 extern struct volume_id *volume_id_open_node(const char *path);
 extern int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size);
+extern int volume_id_probe_filesystem(struct volume_id *id, uint64_t off, uint64_t size);
+extern int volume_id_probe_raid(struct volume_id *id, uint64_t off, uint64_t size);
 extern void volume_id_close(struct volume_id *id);
 
 /* filesystems */
 extern void volume_id_close(struct volume_id *id);
 
 /* filesystems */