From 354f8cc8cf06de44656fb83705c57062d04d1565 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 19 Jan 2015 11:24:48 +0100 Subject: libfdiskL add API to print SIZE field in bytes The patch also add --bytes to fdisk and fdisk. Signed-off-by: Karel Zak --- disk-utils/sfdisk.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'disk-utils/sfdisk.c') diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index 499dd8f64..d609c55a6 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -1335,6 +1335,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out) fputs(USAGE_OPTIONS, out); fputs(_(" -A, --append append partitions to existing partition table\n"), out); + fputs(_(" --bytes print SIZE in bytes rather than in human readable format\n"), out); fputs(_(" -b, --backup backup partition table sectors (see -O)\n"), out); fputs(_(" -f, --force disable all consistency checking\n"), out); fputs(_(" -o, --output output columns\n"), out); @@ -1378,6 +1379,7 @@ int main(int argc, char *argv[]) OPT_PARTLABEL, OPT_PARTTYPE, OPT_PARTATTRS, + OPT_BYTES }; static const struct option longopts[] = { @@ -1385,6 +1387,7 @@ int main(int argc, char *argv[]) { "append", no_argument, NULL, 'A' }, { "backup", no_argument, NULL, 'b' }, { "backup-file", required_argument, NULL, 'O' }, + { "bytes", no_argument, NULL, OPT_BYTES }, { "dump", no_argument, NULL, 'd' }, { "help", no_argument, NULL, 'h' }, { "force", no_argument, NULL, 'f' }, @@ -1422,6 +1425,8 @@ int main(int argc, char *argv[]) textdomain(PACKAGE); atexit(close_stdout); + sfdisk_init(sf); + while ((c = getopt_long(argc, argv, "aAbcdfghlLo:O:nN:qsTu:vVX:Y:", longopts, &longidx)) != -1) { switch(c) { @@ -1517,13 +1522,14 @@ int main(int argc, char *argv[]) case OPT_NOREREAD: sf->noreread = 1; break; - + case OPT_BYTES: + fdisk_set_size_unit(sf->cxt, FDISK_SIZEUNIT_BYTES); + break; default: usage(stderr); } } - sfdisk_init(sf); if (outarg) init_fields(NULL, outarg, NULL); -- cgit v1.2.3-55-g7522