chiark / gitweb /
vol_id: add --offset option
authorKay Sievers <kay.sievers@vrfy.org>
Wed, 9 Apr 2008 10:35:03 +0000 (12:35 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Wed, 9 Apr 2008 10:35:03 +0000 (12:35 +0200)
extras/volume_id/lib/Makefile
extras/volume_id/lib/volume_id.c
extras/volume_id/vol_id.c

index c0905f4a06fc7844b22f6cb62c6884554ed958d0..0e1565f98a3237a649ad67f289c524eb226bd356 100644 (file)
@@ -13,7 +13,7 @@ INSTALL_DATA  = ${INSTALL} -m 644
 INSTALL_LIB = ${INSTALL} -m 755
 
 SHLIB_CUR = 0
 INSTALL_LIB = ${INSTALL} -m 755
 
 SHLIB_CUR = 0
-SHLIB_REV = 82
+SHLIB_REV = 83
 SHLIB_AGE = 0
 SHLIB = libvolume_id.so.$(SHLIB_CUR).$(SHLIB_REV).$(SHLIB_AGE)
 
 SHLIB_AGE = 0
 SHLIB = libvolume_id.so.$(SHLIB_CUR).$(SHLIB_REV).$(SHLIB_AGE)
 
index e8f6de35fdc607ca058c206c8ae1a6aa4c123b40..7c68fb1ef9fdb42cb77c2e3164982949a4ad2a36 100644 (file)
@@ -331,9 +331,9 @@ err:
 }
 
 /* run only once into a timeout for unreadable devices */
 }
 
 /* run only once into a timeout for unreadable devices */
-static int device_is_readable(struct volume_id *id)
+static int device_is_readable(struct volume_id *id, uint64_t off)
 {
 {
-       if (volume_id_get_buffer(id, 0x00, 0x200) != NULL)
+       if (volume_id_get_buffer(id, off, 0x200) != NULL)
                return 1;
        return 0;
 }
                return 1;
        return 0;
 }
@@ -355,7 +355,7 @@ 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;
 
-       if (!device_is_readable(id))
+       if (!device_is_readable(id, off))
                return -1;
 
        info("probing at offset 0x%llx, size 0x%llx",
                return -1;
 
        info("probing at offset 0x%llx, size 0x%llx",
@@ -389,7 +389,7 @@ int volume_id_probe_filesystem(struct volume_id *id, uint64_t off, uint64_t size
        if (id == NULL)
                return -EINVAL;
 
        if (id == NULL)
                return -EINVAL;
 
-       if (!device_is_readable(id))
+       if (!device_is_readable(id, off))
                return -1;
 
        info("probing at offset 0x%llx, size 0x%llx",
                return -1;
 
        info("probing at offset 0x%llx, size 0x%llx",
@@ -421,7 +421,7 @@ int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size)
        if (id == NULL)
                return -EINVAL;
 
        if (id == NULL)
                return -EINVAL;
 
-       if (!device_is_readable(id))
+       if (!device_is_readable(id, off))
                return -1;
 
        /* probe for raid first, because fs probes may be successful on raid members */
                return -1;
 
        /* probe for raid first, because fs probes may be successful on raid members */
index 38950ee85f408b6ae349a1a2924fba9a49eee431..04e85abb7f8bd02bd69a59ad09a0d112de0bfe5d 100644 (file)
@@ -134,6 +134,7 @@ int main(int argc, char *argv[])
                { "export", 0, NULL, 'x' },
                { "skip-raid", 0, NULL, 's' },
                { "probe-all", 0, NULL, 'a' },
                { "export", 0, NULL, 'x' },
                { "skip-raid", 0, NULL, 's' },
                { "probe-all", 0, NULL, 'a' },
+               { "offset", 1, NULL, 'o' },
                { "help", 0, NULL, 'h' },
                {}
        };
                { "help", 0, NULL, 'h' },
                {}
        };
@@ -153,6 +154,7 @@ int main(int argc, char *argv[])
        uint64_t size;
        int skip_raid = 0;
        int probe_all = 0;
        uint64_t size;
        int skip_raid = 0;
        int probe_all = 0;
+       uint64_t offset = 0;
        const char *node;
        int fd;
        const char *label, *uuid, *type, *type_version, *usage;
        const char *node;
        int fd;
        const char *label, *uuid, *type, *type_version, *usage;
@@ -167,7 +169,7 @@ int main(int argc, char *argv[])
        while (1) {
                int option;
 
        while (1) {
                int option;
 
-               option = getopt_long(argc, argv, "lLutxsah", options, NULL);
+               option = getopt_long(argc, argv, "lLutxsaoh", options, NULL);
                if (option == -1)
                        break;
 
                if (option == -1)
                        break;
 
@@ -193,6 +195,9 @@ int main(int argc, char *argv[])
                case 'a':
                        probe_all = 1;
                        break;
                case 'a':
                        probe_all = 1;
                        break;
+               case 'o':
+                       offset = strtoull(optarg, NULL, 0);
+                       break;
                case 'h':
                        printf("Usage: vol_id [options] <device>\n"
                            " --export        export key/value pairs\n"
                case 'h':
                        printf("Usage: vol_id [options] <device>\n"
                            " --export        export key/value pairs\n"
@@ -202,6 +207,7 @@ int main(int argc, char *argv[])
                            " --uuid          filesystem uuid\n"
                            " --skip-raid     don't probe for raid\n"
                            " --probe-all     find possibly conflicting signatures\n"
                            " --uuid          filesystem uuid\n"
                            " --skip-raid     don't probe for raid\n"
                            " --probe-all     find possibly conflicting signatures\n"
+                           " --offset        skip given number of bytes of input\n"
                            " --help\n\n");
                        goto exit;
                default:
                            " --help\n\n");
                        goto exit;
                default:
@@ -249,14 +255,14 @@ int main(int argc, char *argv[])
        }
 
        if (probe_all) {
        }
 
        if (probe_all) {
-               volume_id_all_probers(all_probers, vid, 0, size, NULL);
+               volume_id_all_probers(all_probers, vid, offset, size, NULL);
                goto exit;
        }
 
        if (skip_raid)
                goto exit;
        }
 
        if (skip_raid)
-               retval = volume_id_probe_filesystem(vid, 0, size);
+               retval = volume_id_probe_filesystem(vid, offset, size);
        else
        else
-               retval = volume_id_probe_all(vid, 0, size);
+               retval = volume_id_probe_all(vid, offset, size);
        if (retval != 0) {
                fprintf(stderr, "%s: unknown volume type\n", node);
                rc = 4;
        if (retval != 0) {
                fprintf(stderr, "%s: unknown volume type\n", node);
                rc = 4;