diff options
author | Karel Zak | 2017-08-22 14:59:42 +0200 |
---|---|---|
committer | Karel Zak | 2017-08-22 14:59:42 +0200 |
commit | 27c284b8482e121d3659d1d6abb640c5ac035e3e (patch) | |
tree | 76feddf27e04a29d2db61e9fb82140aa7ba2dd8a | |
parent | libfdisk: add fdisk_save_user_grain() (diff) | |
download | kernel-qcow2-util-linux-27c284b8482e121d3659d1d6abb640c5ac035e3e.tar.gz kernel-qcow2-util-linux-27c284b8482e121d3659d1d6abb640c5ac035e3e.tar.xz kernel-qcow2-util-linux-27c284b8482e121d3659d1d6abb640c5ac035e3e.zip |
libfdisk: add --grain to mkpart sample
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | libfdisk/samples/mkpart.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libfdisk/samples/mkpart.c b/libfdisk/samples/mkpart.c index 3c964de99..1e5fd99e5 100644 --- a/libfdisk/samples/mkpart.c +++ b/libfdisk/samples/mkpart.c @@ -70,11 +70,13 @@ int main(int argc, char *argv[]) const char *label = NULL, *device = NULL; int n = 0, c, nopartno = 0; unsigned int sectorsize; + uint64_t grain = 0; static const struct option longopts[] = { { "label", required_argument, NULL, 'x' }, { "device", required_argument, NULL, 'd' }, { "nopartno", no_argument, NULL, 'p' }, + { "grain", required_argument, NULL, 'g' }, { "help", no_argument, NULL, 'h' }, { NULL, 0, NULL, 0 }, }; @@ -83,7 +85,7 @@ int main(int argc, char *argv[]) fdisk_init_debug(0); - while((c = getopt_long(argc, argv, "x:d:h", longopts, NULL)) != -1) { + while((c = getopt_long(argc, argv, "g:x:d:h", longopts, NULL)) != -1) { switch(c) { case 'x': label = optarg; @@ -94,6 +96,9 @@ int main(int argc, char *argv[]) case 'p': nopartno = 1; break; + case 'g': + grain = strtosize_or_err(optarg, "failed to parse grain"); + break; case 'h': printf("%s [options] <size> ...", program_invocation_short_name); fputs(USAGE_SEPARATOR, stdout); @@ -118,6 +123,9 @@ int main(int argc, char *argv[]) err_oom(); fdisk_set_ask(cxt, ask_callback, NULL); + if (grain) + fdisk_save_user_grain(cxt, grain); + pa = fdisk_new_partition(); if (!pa) err_oom(); |