Commit 5723b8fb authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Pavel Emelyanov

criu --help: print a proper list of features

Remove that weird special case from check_add_feature() function, making
it a separate pr_check_features(), which prints a SEP-separated list of
feature names, obeying the max WIDTH, and prepending each line with
OFFSET. That way, we have a decept --help output:

  --feature FEAT        only check a particular feature, one of:
                            mnt_id, mem_dirty_track, aio_remap, timerfd, tun,
                            userns, fdinfo_lock, seccomp_suspend,
                            seccomp_filters, loginuid, cgroupns, autofs

Alternatively, we could just drop the functionality of showing all the
individual features to check.

[v2: use %s in pr_msg to fix a -Wformat-security warning]
Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent a00d3d8a
......@@ -1113,16 +1113,33 @@ static struct feature_list feature_list[] = {
{ NULL, NULL },
};
int check_add_feature(char *feat)
void pr_check_features(const char *offset, const char *sep, int width)
{
struct feature_list *fl;
int pos = width + 1;
int sep_len = strlen(sep);
int offset_len = strlen(offset);
for (fl = feature_list; fl->name; fl++) {
int len = strlen(fl->name);
if (!strcmp(feat, "list")) {
for (fl = feature_list; fl->name; fl++)
pr_msg("%s ", fl->name);
pr_msg("\n");
return 1;
if (pos + len + sep_len > width) {
pr_msg("\n%s", offset);
pos = offset_len;
}
pr_msg("%s", fl->name);
pos += len;
if ((fl + 1)->name) { // not the last item
pr_msg("%s", sep);
pos += sep_len;
}
}
pr_msg("\n");
}
int check_add_feature(char *feat)
{
struct feature_list *fl;
for (fl = feature_list; fl->name; fl++) {
if (!strcmp(feat, fl->name)) {
......
......@@ -906,7 +906,7 @@ usage:
" --all same as --extra --experimental\n"
" --feature FEAT only check a particular feature, one of:"
);
check_add_feature("list");
pr_check_features(" ", ", ", 80);
pr_msg(
"\n"
"* Logging:\n"
......
......@@ -25,5 +25,6 @@ extern int cr_exec(int pid, char **opts);
extern int cr_dedup(void);
extern int check_add_feature(char *arg);
extern void pr_check_features(const char *offset, const char *sep, int width);
#endif /* __CR_CRTOOLS_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment