btrfs-progs: subvol list: use pr_verbose for messages

Replace printf by the level-aware helper. No change for commands that
don't have the global -q/-v options, otherwise the output can be
quieted.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2022-10-04 16:50:09 +02:00
parent 2def07ac1d
commit 032e68ba34

View File

@ -1132,19 +1132,19 @@ static void print_subvolume_column(struct root_info *subv,
switch (column) { switch (column) {
case BTRFS_LIST_OBJECTID: case BTRFS_LIST_OBJECTID:
printf("%llu", subv->root_id); pr_verbose(LOG_DEFAULT, "%llu", subv->root_id);
break; break;
case BTRFS_LIST_GENERATION: case BTRFS_LIST_GENERATION:
printf("%llu", subv->gen); pr_verbose(LOG_DEFAULT, "%llu", subv->gen);
break; break;
case BTRFS_LIST_OGENERATION: case BTRFS_LIST_OGENERATION:
printf("%llu", subv->ogen); pr_verbose(LOG_DEFAULT, "%llu", subv->ogen);
break; break;
case BTRFS_LIST_PARENT: case BTRFS_LIST_PARENT:
printf("%llu", subv->ref_tree); pr_verbose(LOG_DEFAULT, "%llu", subv->ref_tree);
break; break;
case BTRFS_LIST_TOP_LEVEL: case BTRFS_LIST_TOP_LEVEL:
printf("%llu", subv->top_id); pr_verbose(LOG_DEFAULT, "%llu", subv->top_id);
break; break;
case BTRFS_LIST_OTIME: case BTRFS_LIST_OTIME:
if (subv->otime) { if (subv->otime) {
@ -1154,32 +1154,32 @@ static void print_subvolume_column(struct root_info *subv,
strftime(tstr, 256, "%Y-%m-%d %X", &tm); strftime(tstr, 256, "%Y-%m-%d %X", &tm);
} else } else
strcpy(tstr, "-"); strcpy(tstr, "-");
printf("%s", tstr); pr_verbose(LOG_DEFAULT, "%s", tstr);
break; break;
case BTRFS_LIST_UUID: case BTRFS_LIST_UUID:
if (uuid_is_null(subv->uuid)) if (uuid_is_null(subv->uuid))
strcpy(uuidparse, "-"); strcpy(uuidparse, "-");
else else
uuid_unparse(subv->uuid, uuidparse); uuid_unparse(subv->uuid, uuidparse);
printf("%-36s", uuidparse); pr_verbose(LOG_DEFAULT, "%-36s", uuidparse);
break; break;
case BTRFS_LIST_PUUID: case BTRFS_LIST_PUUID:
if (uuid_is_null(subv->puuid)) if (uuid_is_null(subv->puuid))
strcpy(uuidparse, "-"); strcpy(uuidparse, "-");
else else
uuid_unparse(subv->puuid, uuidparse); uuid_unparse(subv->puuid, uuidparse);
printf("%-36s", uuidparse); pr_verbose(LOG_DEFAULT, "%-36s", uuidparse);
break; break;
case BTRFS_LIST_RUUID: case BTRFS_LIST_RUUID:
if (uuid_is_null(subv->ruuid)) if (uuid_is_null(subv->ruuid))
strcpy(uuidparse, "-"); strcpy(uuidparse, "-");
else else
uuid_unparse(subv->ruuid, uuidparse); uuid_unparse(subv->ruuid, uuidparse);
printf("%-36s", uuidparse); pr_verbose(LOG_DEFAULT, "%-36s", uuidparse);
break; break;
case BTRFS_LIST_PATH: case BTRFS_LIST_PATH:
BUG_ON(!subv->full_path); BUG_ON(!subv->full_path);
printf("%s", subv->full_path); pr_verbose(LOG_DEFAULT, "%s", subv->full_path);
break; break;
default: default:
break; break;
@ -1196,11 +1196,11 @@ static void print_one_subvol_info_raw(struct root_info *subv,
continue; continue;
if (raw_prefix) if (raw_prefix)
printf("%s",raw_prefix); pr_verbose(LOG_DEFAULT, "%s",raw_prefix);
print_subvolume_column(subv, i); print_subvolume_column(subv, i);
} }
printf("\n"); pr_verbose(LOG_DEFAULT, "\n");
} }
static void print_one_subvol_info_table(struct root_info *subv) static void print_one_subvol_info_table(struct root_info *subv)
@ -1214,12 +1214,12 @@ static void print_one_subvol_info_table(struct root_info *subv)
print_subvolume_column(subv, i); print_subvolume_column(subv, i);
if (i != BTRFS_LIST_PATH) if (i != BTRFS_LIST_PATH)
printf("\t"); pr_verbose(LOG_DEFAULT, "\t");
if (i == BTRFS_LIST_TOP_LEVEL) if (i == BTRFS_LIST_TOP_LEVEL)
printf("\t"); pr_verbose(LOG_DEFAULT, "\t");
} }
printf("\n"); pr_verbose(LOG_DEFAULT, "\n");
} }
static void print_one_subvol_info_default(struct root_info *subv) static void print_one_subvol_info_default(struct root_info *subv)
@ -1230,13 +1230,13 @@ static void print_one_subvol_info_default(struct root_info *subv)
if (!btrfs_list_columns[i].need_print) if (!btrfs_list_columns[i].need_print)
continue; continue;
printf("%s ", btrfs_list_columns[i].name); pr_verbose(LOG_DEFAULT, "%s ", btrfs_list_columns[i].name);
print_subvolume_column(subv, i); print_subvolume_column(subv, i);
if (i != BTRFS_LIST_PATH) if (i != BTRFS_LIST_PATH)
printf(" "); pr_verbose(LOG_DEFAULT, " ");
} }
printf("\n"); pr_verbose(LOG_DEFAULT, "\n");
} }
static void print_all_subvol_info_tab_head(void) static void print_all_subvol_info_tab_head(void)
@ -1247,10 +1247,10 @@ static void print_all_subvol_info_tab_head(void)
for (i = 0; i < BTRFS_LIST_ALL; i++) { for (i = 0; i < BTRFS_LIST_ALL; i++) {
if (btrfs_list_columns[i].need_print) if (btrfs_list_columns[i].need_print)
printf("%s\t", btrfs_list_columns[i].name); pr_verbose(LOG_DEFAULT, "%s\t", btrfs_list_columns[i].name);
if (i == BTRFS_LIST_ALL-1) if (i == BTRFS_LIST_ALL-1)
printf("\n"); pr_verbose(LOG_DEFAULT, "\n");
} }
for (i = 0; i < BTRFS_LIST_ALL; i++) { for (i = 0; i < BTRFS_LIST_ALL; i++) {
@ -1261,10 +1261,10 @@ static void print_all_subvol_info_tab_head(void)
while (len--) while (len--)
strcat(barrier, "-"); strcat(barrier, "-");
printf("%s\t", barrier); pr_verbose(LOG_DEFAULT, "%s\t", barrier);
} }
if (i == BTRFS_LIST_ALL-1) if (i == BTRFS_LIST_ALL-1)
printf("\n"); pr_verbose(LOG_DEFAULT, "\n");
} }
} }