From 8c9dddb00ae85b7c7bceeac0e66dfceae2d81839 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sat, 23 Dec 2023 18:16:15 -0500 Subject: [PATCH] getattr skeleton --- cmd_attr.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/cmd_attr.c b/cmd_attr.c index 9e7f5639..d3b20672 100644 --- a/cmd_attr.c +++ b/cmd_attr.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -112,3 +113,38 @@ int cmd_setattr(int argc, char *argv[]) return 0; } + +static void getattr_usage(void) +{ + puts("bcachefs getattr - get attributes on files in a bcachefs filesystem\n" + "Usage: bcachefs getattr \n" + "\n" + "Options:\n" + " -h, --help Display this help and exit\n" + "Report bugs to "); +} + +int cmd_getattr(int argc, char *argv[]) +{ + static const struct option longopts[] = { + { "help", no_argument, NULL, 'h' }, + { NULL } + }; + int opt; + + while ((opt = getopt_long(argc, argv, "h", + longopts, NULL)) != -1) + switch (opt) { + case 'h': + getattr_usage(); + exit(EXIT_SUCCESS); + default: + getattr_usage(); + exit(EXIT_FAILURE); + } + args_shift(optind); + + //for (i = 1; i < argc; i++) + // do_setattr(argv[i], opts); + return 0; +}