From 27c284b8482e121d3659d1d6abb640c5ac035e3e Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 22 Aug 2017 14:59:42 +0200 Subject: [PATCH] libfdisk: add --grain to mkpart sample Signed-off-by: Karel Zak --- libfdisk/samples/mkpart.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libfdisk/samples/mkpart.c b/libfdisk/samples/mkpart.c index 3c964de996..1e5fd99e55 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] ...", 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(); -- 2.47.3