chiark / gitweb /
vol_id: add --skip-raid and --probe-all option
authorKay Sievers <kay.sievers@suse.de>
Thu, 13 Jul 2006 14:59:01 +0000 (16:59 +0200)
committerKay Sievers <kay.sievers@suse.de>
Thu, 13 Jul 2006 14:59:01 +0000 (16:59 +0200)
extras/volume_id/lib/Makefile
extras/volume_id/lib/exported_symbols
extras/volume_id/lib/volume_id.c
extras/volume_id/vol_id.8
extras/volume_id/vol_id.c

index 90cd63e..66b3b92 100644 (file)
@@ -13,7 +13,7 @@ INSTALL_DATA  = ${INSTALL} -m 644
 INSTALL_LIB = ${INSTALL} -m 755
 
 SHLIB_CUR = 0
-SHLIB_REV = 66
+SHLIB_REV = 67
 SHLIB_AGE = 0
 SHLIB = libvolume_id.so.$(SHLIB_CUR).$(SHLIB_REV).$(SHLIB_AGE)
 
index 3f10ec0..57a1feb 100644 (file)
@@ -7,6 +7,8 @@
        volume_id_probe_raid;
        volume_id_close;
 
+       volume_id_probe_linux_swap;
+       volume_id_probe_luks;
        volume_id_probe_cramfs;
        volume_id_probe_ext;
        volume_id_probe_vfat;
@@ -41,6 +43,8 @@
        volume_id_probe_promise_fasttrack_raid;
        volume_id_probe_silicon_medley_raid;
        volume_id_probe_via_raid;
+       volume_id_probe_adaptec_raid;
+       volume_id_probe_jmicron_raid;
 local:
        *;
 };
index bcdbe2f..f74319f 100644 (file)
@@ -102,21 +102,21 @@ int volume_id_probe_filesystem(struct volume_id *id, uint64_t off, uint64_t size
        info("probing at offset 0x%llx, size 0x%llx",
            (unsigned long long) off, (unsigned long long) size);
 
-       if (volume_id_probe_luks(id, off) == 0)
-               goto found;
-
        if (volume_id_probe_vfat(id, off) == 0)
                goto found;
 
-       if (volume_id_probe_xfs(id, off) == 0)
-               goto found;
-
        /* fill buffer with maximum */
        volume_id_get_buffer(id, 0, SB_BUFFER_SIZE);
 
        if (volume_id_probe_linux_swap(id, off) == 0)
                goto found;
 
+       if (volume_id_probe_luks(id, off) == 0)
+               goto found;
+
+       if (volume_id_probe_xfs(id, off) == 0)
+               goto found;
+
        if (volume_id_probe_ext(id, off) == 0)
                goto found;
 
index 9f5a9c5..15fccbe 100644 (file)
@@ -31,6 +31,12 @@ print the label of a volume
 .TP
 \fB\-u\fR
 print the uuid of a volume
+.TP
+\fB\-\-skip-raid\fR
+skip probing for raid signatures
+.TP
+\fB\-\-probe-all\fR
+probe for all known signatures to detect possible conflicts
 .SH "ENVIRONMENT"
 .TP
 \fBUDEV_LOG\fR
index dcf56d8..d516eb5 100644 (file)
@@ -109,11 +109,14 @@ static void set_str(char *to, const char *from, size_t count)
 
 int main(int argc, char *argv[])
 {
-       const char help[] = "usage: vol_id [--export|-t|-l|-u] <device>\n"
-                           "       --export\n"
-                           "       -t filesystem type\n"
-                           "       -l filesystem label\n"
-                           "       -u filesystem uuid\n"
+       const char help[] = "Usage: vol_id [options] <device>\n"
+                           " --export        export key/value pairs\n"
+                           "  -t             filesystem type\n"
+                           "  -l             filesystem label\n"
+                           "  -u             filesystem uuid\n"
+                           " --skip-raid     don't probe for raid\n"
+                           " --probe-all     find possibly conflicting signatures\n"
+                           " --help\n"
                            "\n";
        enum print_type {
                PRINT_EXPORT,
@@ -125,9 +128,12 @@ int main(int argc, char *argv[])
        static char name[VOLUME_ID_LABEL_SIZE];
        int i;
        uint64_t size;
+       int skip_raid = 0;
+       int probe_all = 0;
        const char *node = NULL;
        uid_t nobody_uid;
        gid_t nobody_gid;
+       int retval;
        int rc = 0;
 
        logging_init("vol_id");
@@ -146,6 +152,13 @@ int main(int argc, char *argv[])
                        print = PRINT_LABEL;
                } else if (strcmp(arg, "-u") == 0) {
                        print = PRINT_UUID;
+               } else if (strcmp(arg, "--skip-raid") == 0) {
+                       skip_raid = 1;
+               } else if (strcmp(arg, "--probe-all") == 0) {
+                       probe_all = 1;
+               } else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) {
+                       printf(help);
+                       goto exit;
                } else
                        node = arg;
        }
@@ -179,15 +192,89 @@ int main(int argc, char *argv[])
                }
        }
 
-       if (volume_id_probe_all(vid, 0, size) == 0)
-               goto print;
+       if (probe_all) {
+               if (volume_id_probe_linux_raid(vid, 0, size) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_intel_software_raid(vid, 0, size) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_lsi_mega_raid(vid, 0, size) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_via_raid(vid, 0, size) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_silicon_medley_raid(vid, 0, size) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_nvidia_raid(vid, 0, size) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_promise_fasttrack_raid(vid, 0, size) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_highpoint_45x_raid(vid, 0, size) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_adaptec_raid(vid, 0, size) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_jmicron_raid(vid, 0, size) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_vfat(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_linux_swap(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_luks(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_xfs(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_ext(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_reiserfs(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_jfs(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_udf(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_iso9660(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_hfs_hfsplus(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_ufs(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_ntfs(vid, 0)  == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_cramfs(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_romfs(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_hpfs(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_sysv(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_minix(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_ocfs1(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_ocfs2(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_vxfs(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_squashfs(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_netware(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_gfs(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+               if (volume_id_probe_gfs2(vid, 0) == 0)
+                       printf("%s\n", vid->type);
+
+               goto exit;
+       }
 
-       if (print != PRINT_EXPORT)
+       if (skip_raid)
+               retval = volume_id_probe_filesystem(vid, 0, size);
+       else
+               retval = volume_id_probe_all(vid, 0, size);
+       if (retval != 0) {
                fprintf(stderr, "%s: unknown volume type\n", node);
-       rc = 4;
-       goto exit;
+               rc = 4;
+               goto exit;
+       }
 
-print:
        set_str(name, vid->label, sizeof(vid->label));
        replace_untrusted_chars(name);