c_src: Align and standardize help outputs

While adding scrub to data in last commit I noticed that the help output
where all over the place, both "physically" on the console and also
things like inconsistent case and newlines before "Report bugs to ...",
so I decided to fix all that up.
This commit is contained in:
Manuel Mendez 2025-10-07 13:01:24 -04:00
parent eb75b55d59
commit 7873eb976e
19 changed files with 136 additions and 111 deletions

View File

@ -129,6 +129,7 @@ static void setattr_usage(void)
puts(" --remove-all Remove all file options\n" puts(" --remove-all Remove all file options\n"
" To remove specific options, use: --option=-\n" " To remove specific options, use: --option=-\n"
" -h Display this help and exit\n" " -h Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
} }

View File

@ -11,6 +11,7 @@ static void reset_counters_usage(void)
"\n" "\n"
"Options:\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }

View File

@ -19,7 +19,8 @@ static void data_rereplicate_usage(void)
"of any degraded data\n" "of any degraded data\n"
"\n" "\n"
"Options:\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -63,8 +64,9 @@ static void data_scrub_usage(void)
"Check data for errors, fix from another replica if possible\n" "Check data for errors, fix from another replica if possible\n"
"\n" "\n"
"Options:\n" "Options:\n"
" -m, --metadata check metadata only\n" " -m, --metadata Check metadata only\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS); 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" "job: one of scrub, rereplicate, migrate, rewrite_old_nodes, or drop_extra_replicas\n"
"\n" "\n"
"Options:\n" "Options:\n"
" -b, --btree btree btree to operate on\n" " -b, --btree btree Btree to operate on\n"
" -s, --start inode:offset start position\n" " -s, --start inode:offset Start position\n"
" -e, --end inode:offset end position\n" " -e, --end inode:offset End position\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }

View File

@ -140,11 +140,10 @@ static void device_remove_usage(void)
" bcachefs device remove <device>|<devid> <path>\n" " bcachefs device remove <device>|<devid> <path>\n"
"\n" "\n"
"Options:\n" "Options:\n"
" -f, --force Force removal, even if some data\n" " -f, --force Force removal, even if some data couldn't be migrated\n"
" couldn't be migrated\n" " -F, --force-metadata Force removal, even if some metadata couldn't be migrated\n"
" -F, --force-metadata Force removal, even if some metadata\n" " -h, --help Display this help and exit\n"
" couldn't be migrated\n" "\n"
" -h, --help display this help and exit\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -362,7 +361,8 @@ static void device_set_state_usage(void)
" -f, --force Force if data redundancy will be degraded\n" " -f, --force Force if data redundancy will be degraded\n"
" --force-if-data-lost Force if data will be lost\n" " --force-if-data-lost Force if data will be lost\n"
" -o, --offline Set state of an offline device\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -466,7 +466,8 @@ static void device_resize_usage(void)
"Usage: bcachefs device resize device [ size ]\n" "Usage: bcachefs device resize device [ size ]\n"
"\n" "\n"
"Options:\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -573,7 +574,8 @@ static void device_resize_journal_usage(void)
"Usage: bcachefs device resize-journal device size\n" "Usage: bcachefs device resize-journal device size\n"
"\n" "\n"
"Options:\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -671,14 +673,14 @@ static int device_usage(void)
"Usage: bcachefs device <CMD> [OPTION]\n" "Usage: bcachefs device <CMD> [OPTION]\n"
"\n" "\n"
"Commands:\n" "Commands:\n"
" add add a new device to an existing filesystem\n" " add Add a new device to an existing filesystem\n"
" remove remove a device from an existing filesystem\n" " remove Remove a device from an existing filesystem\n"
" online re-add an existing member to a filesystem\n" " online Re-add an existing member to a filesystem\n"
" offline take a device offline, without removing it\n" " offline Take a device offline, without removing it\n"
" evacuate migrate data off a specific device\n" " evacuate Migrate data off a specific device\n"
" set-state mark a device as failed\n" " set-state Mark a device as failed\n"
" resize resize filesystem on a device\n" " resize Resize filesystem on a device\n"
" resize-journal resize journal on a device\n" " resize-journal Resize journal on a device\n"
"\n" "\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
return 0; return 0;

View File

@ -320,6 +320,7 @@ static void dump_usage(void)
" --noexcl Open devices with O_NOEXCL (not recommended)\n" " --noexcl Open devices with O_NOEXCL (not recommended)\n"
" -v, --verbose\n" " -v, --verbose\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
} }
@ -400,6 +401,7 @@ static void undump_usage(void)
"Options:\n" "Options:\n"
" -f, --force Force; overwrite when needed\n" " -f, --force Force; overwrite when needed\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>"); "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" "Usage: bcachefs fs usage [OPTION]... <mountpoint>\n"
"\n" "\n"
"Options:\n" "Options:\n"
" -f, --fields=FIELDS List of accounting sections to print\n" " -f, --fields=FIELDS List of accounting sections to print:\n"
" replicas, btree, compression, rebalance_work, devices\n" " replicas, btree, compression, rebalance_work, devices\n"
" -a Print all accounting fields\n" " -a Print all accounting fields\n"
" -h, --human-readable Human readable units\n" " -h, --human-readable Human readable units\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
} }

View File

@ -213,6 +213,7 @@ static void fsck_usage(void)
" -K, --no-kernel\n" " -K, --no-kernel\n"
" -v Be verbose\n" " -v Be verbose\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>"); "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" " -s, --set Schedule a recovery pass in the superblock\n"
" -u, --unset Deschedule a recovery pass\n" " -u, --unset Deschedule a recovery pass\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>"); "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" " Keyring to add to (default: user)\n"
" -f, --file Passphrase file to read from (disables passphrase prompt)\n" " -f, --file Passphrase file to read from (disables passphrase prompt)\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
} }
@ -103,6 +104,7 @@ static void set_passphrase_usage(void)
"\n" "\n"
"Options:\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
} }
@ -168,6 +170,7 @@ static void remove_passphrase_usage(void)
"\n" "\n"
"Options:\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
} }

View File

@ -22,7 +22,8 @@ static void kill_btree_node_usage(void)
"Options:\n" "Options:\n"
" -n, --node btree:level:idx Node to kill\n" " -n, --node btree:level:idx Node to kill\n"
" -d, --dev dev Device index (default: kill all replicas)\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>"); "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" " Or entries not matching the range bbpos-bbpos\n"
" -v, --verbose Verbose mode\n" " -v, --verbose Verbose mode\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
} }

View File

@ -193,6 +193,7 @@ static void migrate_usage(void)
" --no_passphrase Don't encrypt master encryption key\n" " --no_passphrase Don't encrypt master encryption key\n"
" -F Force, even if metadata file already exists\n" " -F Force, even if metadata file already exists\n"
" -h Display this help and exit\n" " -h Display this help and exit\n"
"\n"
"Report bugs to <linux-bcachefs@vger.kernel.org>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
} }
@ -386,6 +387,7 @@ static void migrate_superblock_usage(void)
" -d, --dev device Device to create superblock for\n" " -d, --dev device Device to create superblock for\n"
" -o, --offset offset Offset of existing superblock\n" " -o, --offset offset Offset of existing superblock\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>"); "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); bch2_opts_usage(OPT_MOUNT|OPT_RUNTIME);
puts(" -d, --dev-idx index for device specific options\n" puts(" -d, --dev-idx index for device specific 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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }

View File

@ -77,6 +77,7 @@ static void strip_alloc_usage(void)
"\n" "\n"
"Options:\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>"); "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" " --field-only=fiel) print superblock section only, no header\n"
" -l, --layout print superblock layout\n" " -l, --layout print superblock layout\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
@ -387,6 +388,7 @@ static void recover_super_usage(void)
" -y, --yes Recover without prompting\n" " -y, --yes Recover without prompting\n"
" -v, --verbose Increase logging level\n" " -v, --verbose Increase logging level\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>"); "Report bugs to <linux-bcachefs@vger.kernel.org>");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }

View File

@ -78,6 +78,7 @@ static void fs_top_usage(void)
"Options:\n" "Options:\n"
" -h, --human-readable Human readable units\n" " -h, --human-readable Human readable units\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>"); "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) void bch2_opts_usage(unsigned opt_types)
{ {
const struct bch_option *opt; const struct bch_option *opt;
unsigned i, c = 0, helpcol = 30; unsigned i, c = 0, helpcol = 32;
for (opt = bch2_opt_table; for (opt = bch2_opt_table;
opt < bch2_opt_table + bch2_opts_nr; opt < bch2_opt_table + bch2_opts_nr;
@ -899,13 +899,14 @@ void bch2_opts_usage(unsigned opt_types)
if (opt->help) { if (opt->help) {
const char *l = opt->help; const char *l = opt->help;
if (c >= helpcol) if (c > helpcol) {
newline(c); newline(c);
}
while (1) { while (1) {
const char *n = strchrnul(l, '\n'); const char *n = strchrnul(l, '\n');
while (c < helpcol) { while (c < helpcol-1) {
putchar(' '); putchar(' ');
c++; c++;
} }

View File

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