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>
This commit is contained in:
parent
76fab513b8
commit
f8a4a0d4f2
|
@ -136,6 +136,9 @@ or
|
|||
.BR \-u , " \-\-update"
|
||||
Update the specified partitions.
|
||||
.TP
|
||||
.BR \-S , " \-\-sector\-size " \fIsize
|
||||
Overwrite default sector size.
|
||||
.TP
|
||||
.BR \-v , " \-\-verbose"
|
||||
Verbose mode.
|
||||
.TP
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue