Skip to content

Commit ae73e89

Browse files
committed
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: kdave#627 Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 95c1fa1 commit ae73e89

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

mkfs/main.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,19 +1721,23 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
17211721
}
17221722

17231723
if (source_dir) {
1724-
ret = btrfs_mkfs_fill_dir(source_dir, root, bconf.verbose);
1724+
pr_verbose(LOG_DEFAULT, "Rootdir from: %s\n", source_dir);
1725+
ret = btrfs_mkfs_fill_dir(source_dir, root);
17251726
if (ret) {
17261727
error("error while filling filesystem: %d", ret);
17271728
goto out;
17281729
}
17291730
if (shrink_rootdir) {
1731+
pr_verbose(LOG_DEFAULT, " Shrink: yes\n");
17301732
ret = btrfs_mkfs_shrink_fs(fs_info, &shrink_size,
17311733
shrink_rootdir);
17321734
if (ret < 0) {
17331735
error("error while shrinking filesystem: %d",
17341736
ret);
17351737
goto out;
17361738
}
1739+
} else {
1740+
pr_verbose(LOG_DEFAULT, " Shrink: no\n");
17371741
}
17381742
}
17391743

@@ -1783,9 +1787,8 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
17831787
btrfs_parse_runtime_features_to_string(features_buf, &features);
17841788
printf("Runtime features: %s\n", features_buf);
17851789
#endif
1786-
printf("Checksum: %s",
1790+
printf("Checksum: %s\n",
17871791
btrfs_super_csum_name(mkfs_cfg.csum_type));
1788-
printf("\n");
17891792

17901793
list_all_devices(root);
17911794

mkfs/rootdir.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "common/internal.h"
4040
#include "common/messages.h"
4141
#include "common/path-utils.h"
42+
#include "common/utils.h"
4243
#include "mkfs/rootdir.h"
4344

4445
static u32 fs_block_size;
@@ -510,6 +511,8 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
510511
}
511512

512513
for (i = 0; i < count; i++) {
514+
char tmp[PATH_MAX];
515+
513516
cur_file = files[i];
514517

515518
if (lstat(cur_file->d_name, &st) == -1) {
@@ -518,6 +521,10 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
518521
ret = -1;
519522
goto fail;
520523
}
524+
if (bconf.verbose >= LOG_INFO) {
525+
path_cat_out(tmp, parent_dir_entry->path, cur_file->d_name);
526+
pr_verbose(LOG_INFO, "ADD: %s\n", tmp);
527+
}
521528

522529
/*
523530
* We can not directly use the source ino number,
@@ -566,8 +573,6 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
566573
}
567574

568575
if (S_ISDIR(st.st_mode)) {
569-
char tmp[PATH_MAX];
570-
571576
dir_entry = malloc(sizeof(*dir_entry));
572577
if (!dir_entry) {
573578
ret = -ENOMEM;
@@ -631,8 +636,7 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
631636
goto out;
632637
}
633638

634-
int btrfs_mkfs_fill_dir(const char *source_dir, struct btrfs_root *root,
635-
bool verbose)
639+
int btrfs_mkfs_fill_dir(const char *source_dir, struct btrfs_root *root)
636640
{
637641
int ret;
638642
struct btrfs_trans_handle *trans;
@@ -669,8 +673,6 @@ int btrfs_mkfs_fill_dir(const char *source_dir, struct btrfs_root *root,
669673
goto out;
670674
}
671675

672-
if (verbose)
673-
printf("Making image is completed.\n");
674676
return 0;
675677
fail:
676678
/*

mkfs/rootdir.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ struct directory_name_entry {
3636
struct list_head list;
3737
};
3838

39-
int btrfs_mkfs_fill_dir(const char *source_dir, struct btrfs_root *root,
40-
bool verbose);
39+
int btrfs_mkfs_fill_dir(const char *source_dir, struct btrfs_root *root);
4140
u64 btrfs_mkfs_size_dir(const char *dir_name, u32 sectorsize, u64 min_dev_size,
4241
u64 meta_profile, u64 data_profile);
4342
int btrfs_mkfs_shrink_fs(struct btrfs_fs_info *fs_info, u64 *new_size_ret,

0 commit comments

Comments
 (0)