X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=extras%2Fvolume_id%2Fvol_id.c;h=b3f810fc9d3d6082af10e4ad8e1a132fcc44c617;hb=1893cf588f3d428a35a46030deca4ea54be71320;hp=38950ee85f408b6ae349a1a2924fba9a49eee431;hpb=1fdce2f39dd5be0a722d34866e8823c4760738f2;p=elogind.git diff --git a/extras/volume_id/vol_id.c b/extras/volume_id/vol_id.c index 38950ee85..b3f810fc9 100644 --- a/extras/volume_id/vol_id.c +++ b/extras/volume_id/vol_id.c @@ -34,7 +34,7 @@ #include #include -#include "../../udev.h" +#include "../../udev/udev.h" #include "lib/libvolume_id.h" #define BLKGETSIZE64 _IOR(0x12,114,size_t) @@ -134,6 +134,7 @@ int main(int argc, char *argv[]) { "export", 0, NULL, 'x' }, { "skip-raid", 0, NULL, 's' }, { "probe-all", 0, NULL, 'a' }, + { "offset", 2, NULL, 'o' }, { "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 offset = 0; 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; - option = getopt_long(argc, argv, "lLutxsah", options, NULL); + option = getopt_long(argc, argv, "lLutxsaoh", options, NULL); if (option == -1) break; @@ -193,6 +195,10 @@ int main(int argc, char *argv[]) case 'a': probe_all = 1; break; + case 'o': + if (optarg[0] != '\0') + offset = strtoull(optarg, NULL, 0); + break; case 'h': printf("Usage: vol_id [options] \n" " --export export key/value pairs\n" @@ -202,6 +208,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" + " --offset skip given number of bytes of input\n" " --help\n\n"); goto exit; default: @@ -212,7 +219,7 @@ int main(int argc, char *argv[]) node = argv[optind]; if (!node) { - err("no device"); + err("no device\n"); fprintf(stderr, "no device\n"); rc = 1; goto exit; @@ -233,7 +240,7 @@ int main(int argc, char *argv[]) if (ioctl(fd, BLKGETSIZE64, &size) != 0) size = 0; - dbg("BLKGETSIZE64=%llu", (unsigned long long)size); + dbg("BLKGETSIZE64=%llu\n", (unsigned long long)size); /* try to drop all privileges before reading disk content */ if (getuid() == 0) { @@ -244,19 +251,19 @@ int main(int argc, char *argv[]) if (setgroups(0, NULL) != 0 || setgid(pw->pw_gid) != 0 || setuid(pw->pw_uid) != 0) - info("unable to drop privileges: %s\n", strerror(errno)); + info("unable to drop privileges: %s\n\n", strerror(errno)); } } 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) - retval = volume_id_probe_filesystem(vid, 0, size); + retval = volume_id_probe_filesystem(vid, offset, size); 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;