Merge pull request #451 from mmlb/push-szykyztyxswv
Some checks failed
build / bcachefs-tools-msrv (push) Has been cancelled
.deb build orchestrator / source-only (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:forky], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:forky], map[build-arch:amd64 host-arch:ppc64el machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:forky], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:trixie], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:trixie], map[build-arch:amd64 host-arch:ppc64el machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:trixie], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:unstable], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:unstable], map[build-arch:amd64 host-arch:ppc64el machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:debian version:unstable], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:ubuntu version:plucky], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:ubuntu version:plucky], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:ubuntu version:questing], map[build-arch:amd64 host-arch:amd64 machine-arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
.deb build orchestrator / buildd (map[name:ubuntu version:questing], map[build-arch:arm64 host-arch:arm64 machine-arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
.deb build orchestrator / reprotest (push) Has been cancelled
.deb build orchestrator / publish (push) Has been cancelled
Nix Flake actions / nix-matrix (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled

Bunch of -h/--help related fixess to c_src based cmds
This commit is contained in:
koverstreet 2025-10-07 16:33:04 -04:00 committed by GitHub
commit d72b17aa09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 158 additions and 122 deletions

View File

@ -128,7 +128,8 @@ static void setattr_usage(void)
bch2_opts_usage(OPT_INODE);
puts(" --remove-all Remove all file options\n"
" To remove specific options, use: --option=-\n"
" -h Display this help and exit\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}
@ -138,6 +139,14 @@ int cmd_setattr(int argc, char *argv[])
bool remove_all = false;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "--help") == 0) {
setattr_usage();
exit(EXIT_SUCCESS);
}
if (strcmp(argv[i], "-h") == 0) {
setattr_usage();
exit(EXIT_SUCCESS);
}
if (strcmp(argv[i], "--remove-all") == 0) {
remove_all = true;
bch_remove_arg_from_argv(&argc, argv, i);

View File

@ -11,6 +11,7 @@ static void reset_counters_usage(void)
"\n"
"Options:\n"
" -h, --help display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS);
}
@ -18,7 +19,7 @@ static void reset_counters_usage(void)
int cmd_reset_counters(int argc, char *argv[])
{
static const struct option longopts[] = {
{ "help", 0, NULL, 'h' },
{ "help", no_argument, NULL, 'h' },
{ NULL }
};
int opt;

View File

@ -19,7 +19,8 @@ static void data_rereplicate_usage(void)
"of any degraded data\n"
"\n"
"Options:\n"
" -h, --help display this help and exit\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS);
}
@ -27,7 +28,7 @@ static void data_rereplicate_usage(void)
static int cmd_data_rereplicate(int argc, char *argv[])
{
static const struct option longopts[] = {
{ "help", 0, NULL, 'h' },
{ "help", no_argument, NULL, 'h' },
{ NULL }
};
int opt;
@ -63,8 +64,9 @@ static void data_scrub_usage(void)
"Check data for errors, fix from another replica if possible\n"
"\n"
"Options:\n"
" -m, --metadata check metadata only\n"
" -h, --help display this help and exit\n"
" -m, --metadata Check metadata only\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS);
}
@ -271,10 +273,11 @@ static void data_job_usage(void)
"job: one of scrub, rereplicate, migrate, rewrite_old_nodes, or drop_extra_replicas\n"
"\n"
"Options:\n"
" -b, --btree btree btree to operate on\n"
" -s, --start inode:offset start position\n"
" -e, --end inode:offset end position\n"
" -h, --help display this help and exit\n"
" -b, --btree btree Btree to operate on\n"
" -s, --start inode:offset Start position\n"
" -e, --end inode:offset End position\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS);
}
@ -340,6 +343,7 @@ static int data_usage(void)
"\n"
"Commands:\n"
" rereplicate Rereplicate degraded data\n"
" scrub Verify checksums and correct errors, if possible\n"
" job Kick off low level data jobs\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");

View File

@ -140,11 +140,10 @@ static void device_remove_usage(void)
" bcachefs device remove <device>|<devid> <path>\n"
"\n"
"Options:\n"
" -f, --force Force removal, even if some data\n"
" couldn't be migrated\n"
" -F, --force-metadata Force removal, even if some metadata\n"
" couldn't be migrated\n"
" -h, --help display this help and exit\n"
" -f, --force Force removal, even if some data couldn't be migrated\n"
" -F, --force-metadata Force removal, even if some metadata couldn't be migrated\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS);
}
@ -152,10 +151,10 @@ static void device_remove_usage(void)
static int cmd_device_remove(int argc, char *argv[])
{
static const struct option longopts[] = {
{ "by-id", 0, NULL, 'i' },
{ "force", 0, NULL, 'f' },
{ "force-metadata", 0, NULL, 'F' },
{ "help", 0, NULL, 'h' },
{ "by-id", no_argument, NULL, 'i' },
{ "force", no_argument, NULL, 'f' },
{ "force-metadata", no_argument, NULL, 'F' },
{ "help", no_argument, NULL, 'h' },
{ NULL }
};
struct bchfs_handle fs;
@ -218,7 +217,7 @@ static void device_online_usage(void)
static int cmd_device_online(int argc, char *argv[])
{
static const struct option longopts[] = {
{ "help", 0, NULL, 'h' },
{ "help", no_argument, NULL, 'h' },
{ NULL }
};
int opt;
@ -259,7 +258,8 @@ static void device_offline_usage(void)
static int cmd_device_offline(int argc, char *argv[])
{
static const struct option longopts[] = {
{ "force", 0, NULL, 'f' },
{ "force", no_argument, NULL, 'f' },
{ "help", no_argument, NULL, 'h' },
{ NULL }
};
int opt, flags = 0;
@ -362,7 +362,8 @@ static void device_set_state_usage(void)
" -f, --force Force if data redundancy will be degraded\n"
" --force-if-data-lost Force if data will be lost\n"
" -o, --offline Set state of an offline device\n"
" -h, --help display this help and exit\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS);
}
@ -466,7 +467,8 @@ static void device_resize_usage(void)
"Usage: bcachefs device resize device [ size ]\n"
"\n"
"Options:\n"
" -h, --help display this help and exit\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS);
}
@ -474,7 +476,7 @@ static void device_resize_usage(void)
static int cmd_device_resize(int argc, char *argv[])
{
static const struct option longopts[] = {
{ "help", 0, NULL, 'h' },
{ "help", no_argument, NULL, 'h' },
{ NULL }
};
u64 size;
@ -573,7 +575,8 @@ static void device_resize_journal_usage(void)
"Usage: bcachefs device resize-journal device size\n"
"\n"
"Options:\n"
" -h, --help display this help and exit\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS);
}
@ -581,7 +584,7 @@ static void device_resize_journal_usage(void)
static int cmd_device_resize_journal(int argc, char *argv[])
{
static const struct option longopts[] = {
{ "help", 0, NULL, 'h' },
{ "help", no_argument, NULL, 'h' },
{ NULL }
};
u64 size;
@ -671,14 +674,14 @@ static int device_usage(void)
"Usage: bcachefs device <CMD> [OPTION]\n"
"\n"
"Commands:\n"
" add add a new device to an existing filesystem\n"
" remove remove a device from an existing filesystem\n"
" online re-add an existing member to a filesystem\n"
" offline take a device offline, without removing it\n"
" evacuate migrate data off a specific device\n"
" set-state mark a device as failed\n"
" resize resize filesystem on a device\n"
" resize-journal resize journal on a device\n"
" add Add a new device to an existing filesystem\n"
" remove Remove a device from an existing filesystem\n"
" online Re-add an existing member to a filesystem\n"
" offline Take a device offline, without removing it\n"
" evacuate Migrate data off a specific device\n"
" set-state Mark a device as failed\n"
" resize Resize filesystem on a device\n"
" resize-journal Resize journal on a device\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
return 0;

View File

@ -320,6 +320,7 @@ static void dump_usage(void)
" --noexcl Open devices with O_NOEXCL (not recommended)\n"
" -v, --verbose\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}
@ -400,6 +401,7 @@ static void undump_usage(void)
"Options:\n"
" -f, --force Force; overwrite when needed\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}

View File

@ -597,11 +597,12 @@ static void fs_usage_usage(void)
"Usage: bcachefs fs usage [OPTION]... <mountpoint>\n"
"\n"
"Options:\n"
" -f, --fields=FIELDS List of accounting sections to print\n"
" replicas,btree,compression,rebalance_work,devices\n"
" -f, --fields=FIELDS List of accounting sections to print:\n"
" replicas, btree, compression, rebalance_work, devices\n"
" -a Print all accounting fields\n"
" -h, --human-readable Human readable units\n"
" -H, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}

View File

@ -213,6 +213,7 @@ static void fsck_usage(void)
" -K, --no-kernel\n"
" -v Be verbose\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}
@ -386,6 +387,7 @@ static void recovery_pass_usage(void)
" -s, --set Schedule a recovery pass in the superblock\n"
" -u, --unset Deschedule a recovery pass\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}

View File

@ -23,6 +23,7 @@ static void unlock_usage(void)
" Keyring to add to (default: user)\n"
" -f, --file Passphrase file to read from (disables passphrase prompt)\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}
@ -103,6 +104,7 @@ static void set_passphrase_usage(void)
"\n"
"Options:\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}
@ -168,6 +170,7 @@ static void remove_passphrase_usage(void)
"\n"
"Options:\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}

View File

@ -22,7 +22,8 @@ static void kill_btree_node_usage(void)
"Options:\n"
" -n, --node btree:level:idx Node to kill\n"
" -d, --dev dev Device index (default: kill all replicas)\n"
" -h Display this help and exit\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}

View File

@ -440,6 +440,7 @@ static void list_journal_usage(void)
" Or entries not matching the range bbpos-bbpos\n"
" -v, --verbose Verbose mode\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}

View File

@ -192,13 +192,15 @@ static void migrate_usage(void)
" --encrypted Enable whole filesystem encryption (chacha20/poly1305)\n"
" --no_passphrase Don't encrypt master encryption key\n"
" -F Force, even if metadata file already exists\n"
" -h Display this help and exit\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}
static const struct option migrate_opts[] = {
{ "encrypted", no_argument, NULL, 'e' },
{ "no_passphrase", no_argument, NULL, 'p' },
{ "help", no_argument, NULL, 'h' },
{ NULL }
};
@ -386,6 +388,7 @@ static void migrate_superblock_usage(void)
" -d, --dev device Device to create superblock for\n"
" -o, --offset offset Offset of existing superblock\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}

View File

@ -35,6 +35,7 @@ static void set_option_usage(void)
bch2_opts_usage(OPT_MOUNT|OPT_RUNTIME);
puts(" -d, --dev-idx index for device specific options\n"
" -h, --help display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS);
}

View File

@ -77,6 +77,7 @@ static void strip_alloc_usage(void)
"\n"
"Options:\n"
" -h, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}

View File

@ -44,6 +44,7 @@ static void show_super_usage(void)
" --field-only=fiel) print superblock section only, no header\n"
" -l, --layout print superblock layout\n"
" -h, --help display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS);
}
@ -122,8 +123,8 @@ int cmd_show_super(int argc, char *argv[])
static const struct option longopts[] = {
{ "fields", 1, NULL, 'f' },
{ "field-only", 1, NULL, 'F' },
{ "layout", 0, NULL, 'l' },
{ "help", 0, NULL, 'h' },
{ "layout", no_argument, NULL, 'l' },
{ "help", no_argument, NULL, 'h' },
{ NULL }
};
unsigned fields = 0;
@ -387,6 +388,7 @@ static void recover_super_usage(void)
" -y, --yes Recover without prompting\n"
" -v, --verbose Increase logging level\n"
" -h, --help display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS);
}

View File

@ -78,6 +78,7 @@ static void fs_top_usage(void)
"Options:\n"
" -h, --human-readable Human readable units\n"
" -H, --help Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>");
}

View File

@ -869,7 +869,7 @@ struct bch_opts bch2_parse_opts(struct bch_opt_strs strs)
void bch2_opts_usage(unsigned opt_types)
{
const struct bch_option *opt;
unsigned i, c = 0, helpcol = 30;
unsigned i, c = 0, helpcol = 32;
for (opt = bch2_opt_table;
opt < bch2_opt_table + bch2_opts_nr;
@ -899,13 +899,14 @@ void bch2_opts_usage(unsigned opt_types)
if (opt->help) {
const char *l = opt->help;
if (c >= helpcol)
if (c > helpcol) {
newline(c);
}
while (1) {
const char *n = strchrnul(l, '\n');
while (c < helpcol) {
while (c < helpcol-1) {
putchar(' ');
c++;
}

View File

@ -527,7 +527,7 @@ enum fsck_err_opts {
OPT_DEVICE|OPT_RUNTIME, \
OPT_STR(bch2_member_states), \
BCH_MEMBER_STATE, BCH_MEMBER_STATE_rw, \
"state", "rw,ro,failed,spare") \
"state", "Specifies device state") \
x(bucket_size, u32, \
OPT_DEVICE|OPT_HUMAN_READABLE|OPT_SB_FIELD_SECTORS, \
OPT_UINT(0, S64_MAX), \