diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2025-07-04 12:34:24 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-07-04 12:47:30 -0400 |
commit | e7cc6bb9cfd0d5de310d5eb61fd17693a2b4d60b (patch) | |
tree | 71c4c24abd6cfed054555c0de906827fe5266d8e /c_src/cmd_key.c | |
parent | 7d69a303d1c5eafd860c2377a013fd2aaad43ba2 (diff) |
getopt() -> getopt_long()
Kill all remaining getopt() uses - all options can now be passed as
longopts.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'c_src/cmd_key.c')
-rw-r--r-- | c_src/cmd_key.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/c_src/cmd_key.c b/c_src/cmd_key.c index c1b72ff4..6cdf1d3f 100644 --- a/c_src/cmd_key.c +++ b/c_src/cmd_key.c @@ -1,5 +1,6 @@ #include <errno.h> #include <fcntl.h> +#include <getopt.h> #include <unistd.h> #include <uuid/uuid.h> @@ -15,16 +16,23 @@ static void unlock_usage(void) "Usage: bcachefs unlock [OPTION] device\n" "\n" "Options:\n" - " -c Check if a device is encrypted\n" - " -k (session|user|user_session)\n" + " -c, --check Check if a device is encrypted\n" + " -k, --keyring (session|user|user_session)\n" " Keyring to add to (default: user)\n" - " -f Passphrase file to read from (disables passphrase prompt)\n" - " -h Display this help and exit\n" + " -f, --file Passphrase file to read from (disables passphrase prompt)\n" + " -h, --help Display this help and exit\n" "Report bugs to <linux-bcachefs@vger.kernel.org>"); } int cmd_unlock(int argc, char *argv[]) { + static const struct option longopts[] = { + { "check", no_argument, NULL, 'c' }, + { "keyring", required_argument, NULL, 'k' }, + { "file", required_argument, NULL, 'f' }, + { "help", no_argument, NULL, 'h' }, + { NULL } + }; const char *keyring = "user"; bool check = false; const char *passphrase_file_path = NULL; @@ -32,7 +40,7 @@ int cmd_unlock(int argc, char *argv[]) int opt; - while ((opt = getopt(argc, argv, "cf:k:h")) != -1) + while ((opt = getopt_long(argc, argv, "cf:k:h", longopts, NULL)) != -1) switch (opt) { case 'c': check = true; |