diff options
author | Karel Zak | 2017-01-13 13:30:22 +0100 |
---|---|---|
committer | Karel Zak | 2017-01-13 13:30:22 +0100 |
commit | f8a4a0d4f2fd569252029bd004e24ee433b43fe8 (patch) | |
tree | 98a085be69dba476b280fa32e7671a8942c92e01 /disk-utils/partx.c | |
parent | libblkid: add blkid_probe_set_sectorsize() (diff) | |
download | kernel-qcow2-util-linux-f8a4a0d4f2fd569252029bd004e24ee433b43fe8.tar.gz kernel-qcow2-util-linux-f8a4a0d4f2fd569252029bd004e24ee433b43fe8.tar.xz kernel-qcow2-util-linux-f8a4a0d4f2fd569252029bd004e24ee433b43fe8.zip |
partx: add --sector-size option
/dev/sdc is 4K disk:
# fdisk -l /dev/sdc
Disk /dev/sdc: 100 MiB, 104857600 bytes, 25600 sectors
...
Device Boot Start End Sectors Size Id Type
/dev/sdc1 1024 25599 24576 96M 83 Linux
let's use it as disk image:
# dd if=/dev/sdc of=~/sdc.img
# losetup -f ~/sdc.img
old version:
# partx --show /dev/loop0
NR START END SECTORS SIZE NAME UUID
1 1024 25599 24576 12M 6a4ba75b-01
new version:
# partx --show /dev/loop0 --sector-size 4096
NR START END SECTORS SIZE NAME UUID
1 8192 204799 196608 96M 6a4ba75b-01
Addresses: https://github.com/karelzak/util-linux/issues/396
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils/partx.c')
-rw-r--r-- | disk-utils/partx.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/disk-utils/partx.c b/disk-utils/partx.c index d74a52a6e..7442100f3 100644 --- a/disk-utils/partx.c +++ b/disk-utils/partx.c @@ -766,6 +766,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out) fputs(_(" -o, --output <list> define which output columns to use\n"), out); fputs(_(" -P, --pairs use key=\"value\" output format\n"), out); fputs(_(" -r, --raw use raw output format\n"), out); + fputs(_(" -S, --sector-size <num> overwrite sector size\n"), out); fputs(_(" -t, --type <type> specify the partition type (dos, bsd, solaris, etc.)\n"), out); fputs(_(" -v, --verbose verbose mode\n"), out); @@ -792,6 +793,7 @@ int main(int argc, char **argv) char *wholedisk = NULL; /* allocated, ie: /dev/sda */ char *outarg = NULL; dev_t disk_devno = 0, part_devno = 0; + unsigned int sector_size = 0; static const struct option long_opts[] = { { "bytes", no_argument, NULL, 'b' }, @@ -806,6 +808,7 @@ int main(int argc, char **argv) { "nr", required_argument, NULL, 'n' }, { "output", required_argument, NULL, 'o' }, { "pairs", no_argument, NULL, 'P' }, + { "sector-size",required_argument, NULL, 'S' }, { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, { "verbose", no_argument, NULL, 'v' }, @@ -824,7 +827,7 @@ int main(int argc, char **argv) atexit(close_stdout); while ((c = getopt_long(argc, argv, - "abdglrsuvn:t:o:PhV", long_opts, NULL)) != -1) { + "abdglrsuvn:t:o:PS:hV", long_opts, NULL)) != -1) { err_exclusive_options(c, long_opts, excl, excl_st); @@ -862,6 +865,9 @@ int main(int argc, char **argv) case 's': what = ACT_SHOW; break; + case 'S': + sector_size = strtou32_or_err(optarg, _("invalid sector size argument")); + break; case 't': type = optarg; break; @@ -1001,8 +1007,12 @@ int main(int argc, char **argv) if (!pr || blkid_probe_set_device(pr, fd, 0, 0)) warnx(_("%s: failed to initialize blkid prober"), wholedisk); - else + else { + if (sector_size) + blkid_probe_set_sectorsize(pr, sector_size); + ls = get_partlist(pr, wholedisk, type); + } if (ls) { switch (what) { |