]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: use geometry generation / helper functions
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 23 May 2018 21:30:48 +0000 (16:30 -0500)
committerEric Sandeen <sandeen@redhat.com>
Wed, 23 May 2018 21:30:48 +0000 (16:30 -0500)
Since libxfs now has a function to fill out the geometry structure
and libfrog has a function to pretty-print the geometry, have mkfs
use the two helpers instead of open-coding it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/libxfs_api_defs.h
mkfs/xfs_mkfs.c

index e519799533a1374c1913e6b620bd9e4364d96597..56f9f8caa1d7d69858b5c072295fdc77e93ef8ad 100644 (file)
 #define xfs_rmap_compare               libxfs_rmap_compare
 #define xfs_dir_get_ops                        libxfs_dir_get_ops
 #define xfs_default_ifork_ops          libxfs_default_ifork_ops
+#define xfs_fs_geometry                        libxfs_fs_geometry
 
 #endif /* __LIBXFS_API_DEFS_H__ */
index 3804814b3b8a71034aebc0d8613f7239cda3ffb4..2de0171308317fd4de0a880b294ce58fc5be3df3 100644 (file)
@@ -20,7 +20,7 @@
 #include <ctype.h>
 #include "xfs_multidisk.h"
 #include "libxcmd.h"
-
+#include "fsgeom.h"
 
 
 #define TERABYTES(count, blog) ((uint64_t)(count) << (40 - (blog)))
@@ -3172,40 +3172,6 @@ initialise_mount(
        mp->m_sectbb_log = sbp->sb_sectlog - BBSHIFT;
 }
 
-static void
-print_mkfs_cfg(
-       struct mkfs_params      *cfg,
-       char                    *dfile,
-       char                    *logfile,
-       char                    *rtfile)
-{
-       struct sb_feat_args     *fp = &cfg->sb_feat;
-
-       printf(_(
-"meta-data=%-22s isize=%-6d agcount=%lld, agsize=%lld blks\n"
-"         =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n"
-"         =%-22s crc=%-8u finobt=%u, sparse=%u, rmapbt=%u, reflink=%u\n"
-"data     =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n"
-"         =%-22s sunit=%-6u swidth=%u blks\n"
-"naming   =version %-14u bsize=%-6u ascii-ci=%d ftype=%d\n"
-"log      =%-22s bsize=%-6d blocks=%lld, version=%d\n"
-"         =%-22s sectsz=%-5u sunit=%d blks, lazy-count=%d\n"
-"realtime =%-22s extsz=%-6d blocks=%lld, rtextents=%lld\n"),
-               dfile, cfg->inodesize, (long long)cfg->agcount,
-                       (long long)cfg->agsize,
-               "", cfg->sectorsize, fp->attr_version, fp->projid32bit,
-               "", fp->crcs_enabled, fp->finobt, fp->spinodes, fp->rmapbt,
-                       fp->reflink,
-               "", cfg->blocksize, (long long)cfg->dblocks, cfg->imaxpct,
-               "", cfg->dsunit, cfg->dswidth,
-               fp->dir_version, cfg->dirblocksize, fp->nci, fp->dirftype,
-               logfile, cfg->blocksize, (long long)cfg->logblocks,
-                       fp->log_version,
-               "", cfg->lsectorsize, cfg->lsunit, fp->lazy_sb_counters,
-               rtfile, (int)cfg->rtextblocks << cfg->blocklog,
-                       (long long)cfg->rtblocks, (long long)cfg->rtextents);
-}
-
 /*
  * Format everything from the generated config into the superblock that
  * will be used to initialise the on-disk superblock. This is the in-memory
@@ -3967,12 +3933,26 @@ main(
         */
        calculate_log_size(&cfg, &cli, mp);
 
+       finish_superblock_setup(&cfg, mp, sbp);
+
+       /* Print the intended geometry of the fs. */
        if (!quiet || dry_run) {
-               print_mkfs_cfg(&cfg, dfile, logfile, rtfile);
+               struct xfs_fsop_geom    geo;
+               int                     error;
+
+               error = -libxfs_fs_geometry(sbp, &geo,
+                               XFS_FS_GEOM_MAX_STRUCT_VER);
+               if (error) {
+                       fprintf(stderr,
+       _("%s: failed to generate filesystem geometry\n"),
+                               progname);
+                       exit(1);
+               }
+
+               xfs_report_geom(&geo, dfile, logfile, rtfile);
                if (dry_run)
                        exit(0);
        }
-       finish_superblock_setup(&cfg, mp, sbp);
 
        /*
         * we need the libxfs buffer cache from here on in.