Allow the caller to provide a pointer to a statfs change structure so
that it can do its own debug message printing. This is only used by
mkfs.gfs2.

Signed-off-by: Andrew Price <anpr...@redhat.com>
---
 gfs2/convert/gfs2_convert.c | 2 +-
 gfs2/fsck/initialize.c      | 2 +-
 gfs2/fsck/main.c            | 2 +-
 gfs2/libgfs2/libgfs2.h      | 2 +-
 gfs2/libgfs2/structures.c   | 8 +++-----
 gfs2/mkfs/main_mkfs.c       | 8 ++++++--
 6 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 8667d8fb..5bfc616b 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -2357,7 +2357,7 @@ int main(int argc, char **argv)
                                 strerror(error));
                        exit(-1);
                }
-               do_init_statfs(&sb2);
+               do_init_statfs(&sb2, NULL);
 
                /* Create the resource group index file */
                ip = build_rindex(&sb2);
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index a2bc44c0..fab9a1e7 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -867,7 +867,7 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
                                   "a valid statfs file; aborting.\n"));
                        goto fail;
                }
-               do_init_statfs(sdp);
+               do_init_statfs(sdp, NULL);
        }
        if (sdp->md.statfs->i_size) {
                buf = malloc(sdp->md.statfs->i_size);
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index 35b13950..cb667815 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -228,7 +228,7 @@ static int check_statfs(struct gfs2_sbd *sdp)
                return 0;
        }
 
-       do_init_statfs(sdp);
+       do_init_statfs(sdp, NULL);
        log_err( _("The statfs file was fixed.\n"));
        errors_corrected++;
        return 0;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 3396ddb0..fa710a6c 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -783,7 +783,7 @@ extern struct gfs2_inode *build_rindex(struct gfs2_sbd 
*sdp);
 extern struct gfs2_inode *build_quota(struct gfs2_sbd *sdp);
 extern int build_root(struct gfs2_sbd *sdp);
 extern int do_init_inum(struct gfs2_sbd *sdp);
-extern int do_init_statfs(struct gfs2_sbd *sdp);
+extern int do_init_statfs(struct gfs2_sbd *sdp, struct gfs2_statfs_change 
*res);
 extern int gfs2_check_meta(const char *buf, int type);
 extern unsigned lgfs2_bm_scan(struct rgrp_tree *rgd, unsigned idx,
                              uint64_t *buf, uint8_t state);
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 7ac38f92..d4a08c43 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -471,7 +471,7 @@ int do_init_inum(struct gfs2_sbd *sdp)
        return 0;
 }
 
-int do_init_statfs(struct gfs2_sbd *sdp)
+int do_init_statfs(struct gfs2_sbd *sdp, struct gfs2_statfs_change *res)
 {
        struct gfs2_inode *ip = sdp->md.statfs;
        struct gfs2_statfs_change sc;
@@ -485,10 +485,8 @@ int do_init_statfs(struct gfs2_sbd *sdp)
        if (count != sizeof(sc))
                return -1;
 
-       if (cfg_debug) {
-               printf("\nStatfs:\n");
-               lgfs2_statfs_change_print(&sc);
-       }
+       if (res)
+               *res = sc;
        return 0;
 }
 
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 9a73ff7b..36341d99 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -1196,6 +1196,7 @@ static int open_dev(struct mkfs_dev *dev, int withprobe)
 #ifndef UNITTESTS
 int main(int argc, char *argv[])
 {
+       struct gfs2_statfs_change sc;
        struct gfs2_sbd sbd;
        struct mkfs_opts opts;
        struct gfs2_inode *ip;
@@ -1355,8 +1356,11 @@ int main(int argc, char *argv[])
        sbd.sd_locktable[GFS2_LOCKNAME_LEN - 1] = '\0';
 
        do_init_inum(&sbd);
-       do_init_statfs(&sbd);
-
+       do_init_statfs(&sbd, &sc);
+       if (opts.debug) {
+               printf("\nStatfs:\n");
+               lgfs2_statfs_change_print(&sc);
+       }
        inode_put(&sbd.md.rooti);
        inode_put(&sbd.master_dir);
        inode_put(&sbd.md.inum);
-- 
2.34.1

Reply via email to