btrfs-progs: mkfs: more verbose output for --rootdir

Print the source directory for --rootdir and if --shrink is used. With
-vv then print the individual files as added:

  $ mkfs.btrfs --rootdir dir --shrink -vv img
  ...
  Rootdir from:       Documentation
  ADD: /btrfs-progs/Documentation/btrfs-check.rst
  ...
  ADD: /btrfs-progs/Documentation/btrfs-send.rst
    Shrink:           yes
  Label:              (null)
  UUID:               40d3a16f-02d8-40d7-824b-239cee528093
  ...

The 'Rootdir from' is printed before the files are added so there's now
message before the files are added which could take some time.

Issue: #627
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2023-05-26 21:52:27 +02:00
parent 95c1fa1871
commit ae73e89f28
3 changed files with 15 additions and 11 deletions

View file

@ -1721,12 +1721,14 @@ raid_groups:
}
if (source_dir) {
ret = btrfs_mkfs_fill_dir(source_dir, root, bconf.verbose);
pr_verbose(LOG_DEFAULT, "Rootdir from: %s\n", source_dir);
ret = btrfs_mkfs_fill_dir(source_dir, root);
if (ret) {
error("error while filling filesystem: %d", ret);
goto out;
}
if (shrink_rootdir) {
pr_verbose(LOG_DEFAULT, " Shrink: yes\n");
ret = btrfs_mkfs_shrink_fs(fs_info, &shrink_size,
shrink_rootdir);
if (ret < 0) {
@ -1734,6 +1736,8 @@ raid_groups:
ret);
goto out;
}
} else {
pr_verbose(LOG_DEFAULT, " Shrink: no\n");
}
}
@ -1783,9 +1787,8 @@ raid_groups:
btrfs_parse_runtime_features_to_string(features_buf, &features);
printf("Runtime features: %s\n", features_buf);
#endif
printf("Checksum: %s",
printf("Checksum: %s\n",
btrfs_super_csum_name(mkfs_cfg.csum_type));
printf("\n");
list_all_devices(root);

View file

@ -39,6 +39,7 @@
#include "common/internal.h"
#include "common/messages.h"
#include "common/path-utils.h"
#include "common/utils.h"
#include "mkfs/rootdir.h"
static u32 fs_block_size;
@ -510,6 +511,8 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
}
for (i = 0; i < count; i++) {
char tmp[PATH_MAX];
cur_file = files[i];
if (lstat(cur_file->d_name, &st) == -1) {
@ -518,6 +521,10 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
ret = -1;
goto fail;
}
if (bconf.verbose >= LOG_INFO) {
path_cat_out(tmp, parent_dir_entry->path, cur_file->d_name);
pr_verbose(LOG_INFO, "ADD: %s\n", tmp);
}
/*
* We can not directly use the source ino number,
@ -566,8 +573,6 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
}
if (S_ISDIR(st.st_mode)) {
char tmp[PATH_MAX];
dir_entry = malloc(sizeof(*dir_entry));
if (!dir_entry) {
ret = -ENOMEM;
@ -631,8 +636,7 @@ fail_no_dir:
goto out;
}
int btrfs_mkfs_fill_dir(const char *source_dir, struct btrfs_root *root,
bool verbose)
int btrfs_mkfs_fill_dir(const char *source_dir, struct btrfs_root *root)
{
int ret;
struct btrfs_trans_handle *trans;
@ -669,8 +673,6 @@ int btrfs_mkfs_fill_dir(const char *source_dir, struct btrfs_root *root,
goto out;
}
if (verbose)
printf("Making image is completed.\n");
return 0;
fail:
/*

View file

@ -36,8 +36,7 @@ struct directory_name_entry {
struct list_head list;
};
int btrfs_mkfs_fill_dir(const char *source_dir, struct btrfs_root *root,
bool verbose);
int btrfs_mkfs_fill_dir(const char *source_dir, struct btrfs_root *root);
u64 btrfs_mkfs_size_dir(const char *dir_name, u32 sectorsize, u64 min_dev_size,
u64 meta_profile, u64 data_profile);
int btrfs_mkfs_shrink_fs(struct btrfs_fs_info *fs_info, u64 *new_size_ret,