diff --git a/cmds/filesystem.c b/cmds/filesystem.c index 8e2697de6..41ad2f8d3 100644 --- a/cmds/filesystem.c +++ b/cmds/filesystem.c @@ -365,7 +365,6 @@ static void print_one_uuid(struct btrfs_fs_devices *fs_devices, if (devs_found < total) { pr_verbose(LOG_DEFAULT, "\t*** Some devices missing\n"); } - pr_verbose(LOG_DEFAULT, "\n"); } /* adds up all the used spaces as reported by the space info ioctl @@ -431,7 +430,6 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info, free(canonical_path); } - pr_verbose(LOG_DEFAULT, "\n"); return 0; } @@ -481,6 +479,10 @@ static int btrfs_scan_kernel(void *search, unsigned unit_mode) fd = open(mnt->mnt_dir, O_RDONLY); if ((fd != -1) && !get_df(fd, &space_info_arg)) { + /* Put space between filesystem entries for readability. */ + if (found != 0) + pr_verbose(LOG_DEFAULT, "\n"); + print_one_fs(&fs_info_arg, dev_info_arg, space_info_arg, label, unit_mode); free(space_info_arg); @@ -757,6 +759,7 @@ static int cmd_filesystem_show(const struct cmd_struct *cmd, char uuid_buf[BTRFS_UUID_UNPARSED_SIZE]; unsigned unit_mode; int found = 0; + bool needs_newline = false; unit_mode = get_unit_mode_from_arg(&argc, argv, 0); @@ -845,6 +848,12 @@ static int cmd_filesystem_show(const struct cmd_struct *cmd, goto out; } + /* + * The above call will return 0 if it found anything, in those cases we + * need an extra newline below. + */ + needs_newline = !ret; + /* shows mounted only */ if (where == BTRFS_SCAN_MOUNTED) goto out; @@ -882,8 +891,14 @@ static int cmd_filesystem_show(const struct cmd_struct *cmd, goto out; } - list_for_each_entry(fs_devices, &all_uuids, fs_list) + list_for_each_entry(fs_devices, &all_uuids, fs_list) { + /* Put space between filesystem entries for readability. */ + if (needs_newline) + pr_verbose(LOG_DEFAULT, "\n"); + print_one_uuid(fs_devices, unit_mode); + needs_newline = true; + } if (search && !found) { error("not a valid btrfs filesystem: %s", search);