From: Luca Bruno <lucab@debian.org>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] Add -V|--version to mkfs.btrfs argument parser
Date: Sun, 15 Mar 2009 12:23:52 +0100 [thread overview]
Message-ID: <1237116232-29808-1-git-send-email-lucab@debian.org> (raw)
mkfs.btrfs now prints its version when invoked with -V|--version
and exits without error.
All other mkfs.* tools provide this feature and follow this
implicit argument naming convention, as it is commonly used to
check for helper tools presence.
The corrisponding manual already mentions this option, no need to
touch it.
Signed-off-by: Luca Bruno <lucab@debian.org>
---
mkfs.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/mkfs.c b/mkfs.c
index d664254..af7d12c 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -275,6 +275,12 @@ static void print_usage(void)
exit(1);
}
+static void print_version(void)
+{
+ fprintf(stderr, "mkfs.btrfs, part of %s\n", BTRFS_BUILD_VERSION);
+ exit(0);
+}
+
static u64 parse_profile(char *s)
{
if (strcmp(s, "raid0") == 0) {
@@ -320,6 +326,7 @@ static struct option long_options[] = {
{ "nodesize", 1, NULL, 'n' },
{ "sectorsize", 1, NULL, 's' },
{ "data", 1, NULL, 'd' },
+ { "version", 0, NULL, 'V' },
{ 0, 0, 0, 0}
};
@@ -349,7 +356,7 @@ int main(int ac, char **av)
while(1) {
int c;
- c = getopt_long(ac, av, "A:b:l:n:s:m:d:L:", long_options,
+ c = getopt_long(ac, av, "A:b:l:n:s:m:d:L:V", long_options,
&option_index);
if (c < 0)
break;
@@ -386,6 +393,9 @@ int main(int ac, char **av)
}
zero_end = 0;
break;
+ case 'V':
+ print_version();
+ break;
default:
print_usage();
}
--
1.6.2
reply other threads:[~2009-03-15 11:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1237116232-29808-1-git-send-email-lucab@debian.org \
--to=lucab@debian.org \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox