xfsprogs: consolidate filesystem info reporting
RFC PATCH 1/1 xfsprogs: consolidate filesystem info reporting
mkfs.xfs and xfs_growfs/xfs_info had /almost/ the same output format, but not quite. Differences included "internal" vs "internal log," "spinodes" vs. "sparse," commas in one and not the other, etc.
xfs_growfs uses report_info() to encapsulate this printing; sharing with mkfs is a little awkward because growfs is using an xfs_fsop_geom_t geo to query a mounted filesystem, whereas mkfs has an xfs superblock for an unmounted filesystem, so some translation is needed.
This patch makes a new libxcmd/util.c file for the report_info function, and uses it for both mkfs and xfs_growfs with minor tweaks on each side for consistency.
---
I don't know if the console output for mkfs & growfs are considered an informal API - if so, then this patch should just be ignored and we'll have to live with the inconsistencies that are in the wild already.
This is only lightly tested because I want to address the API aspect of it before going off and writing tests, etc.
growfs/xfs_growfs.c | 52 ++-------------------------------------- include/libxcmd.h | 19 +++++++++++++- libxcmd/Makefile | 2 - libxcmd/util.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ mkfs/xfs_mkfs.c | 50 ++++++++++++++++++++------------------ 5 files changed, 115 insertions(+), 75 deletions(-)
growfs/xfs_growfs.c +3 -49
@@ -17,6 +17,7 @@*/ #include "libxfs.h" +#include "libxcmd.h" #include "path.h" static void
@@ -42,53 +43,6 @@ Options:\n\exit (2 ); } -void -report_info ( -xfs_fsop_geom_t geo, -char *mntpoint, -int isint, -char *logname, -char *rtname, -int lazycount, -int dirversion, -int logversion, -int attrversion, -int projid32bit, -int crcs_enabled, -int cimode, -int ftype_enabled, -int finobt_enabled, -int spinodes, -int rmapbt_enabled, -int reflink_enabled) -{ -printf (_ ( -"meta-data=%-22s isize=%-6u agcount=%u, agsize=%u blks\n" -" =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n" -" =%-22s crc=%-8u finobt=%u spinodes=%u rmapbt=%u\n" -" =%-22s 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=%-6u blocks=%u, version=%u\n" -" =%-22s sectsz=%-5u sunit=%u blks, lazy-count=%u\n" -"realtime =%-22s extsz=%-6u blocks=%llu, rtextents=%llu\n" ), - - mntpoint, geo.inodesize, geo.agcount, geo.agblocks, -"" , geo.sectsize, attrversion, projid32bit, -"" , crcs_enabled, finobt_enabled, spinodes, rmapbt_enabled, -"" , reflink_enabled, -"" , geo.blocksize, (unsigned long long )geo.datablocks, - geo.imaxpct, -"" , geo.sunit, geo.swidth, - dirversion, geo.dirblocksize, cimode, ftype_enabled, - isint ?_ ("internal" ) : logname ? logname :_ ("external" ), - geo.blocksize, geo.logblocks, logversion, -"" , geo.logsectsize, geo.logsunit / geo.blocksize, lazycount, - !geo.rtblocks ?_ ("none" ) : rtname ? rtname :_ ("external" ), - geo.rtextsize * geo.blocksize, (unsigned long long )geo.rtblocks, - (unsigned long long )geo.rtextents); -}int main (int argc,char **argv)
@@ -259,7 +213,7 @@ main(int argc, char **argv) rmapbt_enabled = geo.flags &XFS_FSOP_GEOM_FLAGS_RMAPBT ?1 :0 ; reflink_enabled = geo.flags &XFS_FSOP_GEOM_FLAGS_REFLINK ?1 :0 ;if (nflag) { - report_info(geo, datadev, isint, logdev, rtdev, + report_info(geo, datadev, logdev, rtdev, lazycount, dirversion, logversion, attrversion, projid32bit, crcs_enabled, ci, ftype_enabled, finobt_enabled, spinodes,
@@ -298,7 +252,7 @@ main(int argc, char **argv)exit (1 ); } - report_info(geo, datadev, isint, logdev, rtdev, + report_info(geo, datadev, logdev, rtdev, lazycount, dirversion, logversion, attrversion, projid32bit, crcs_enabled, ci, ftype_enabled, finobt_enabled, spinodes, rmapbt_enabled,
include/libxcmd.h +18 -1
@@ -51,6 +51,23 @@ extern intcheck_overwrite ( const char *device); - +extern void +report_info ( +xfs_fsop_geom_t geo, +char *mntpoint, +char *logname, +char *rtname, +int lazycount, +int dirversion, +int logversion, +int attrversion, +int projid32bit, +int crcs_enabled, +int cimode, +int ftype_enabled, +int finobt_enabled, +int spinodes, +int rmapbt_enabled, +int reflink_enabled);#endif /* __LIBXCMD_H__ */
libxcmd/Makefile +1 -1
@@ -10,7 +10,7 @@ LT_CURRENT = 0 LT_REVISION = 0 LT_AGE = 0 -CFILES = command.c input.c paths.c projects.c help.c quit.c topology.c +CFILES = command.c input.c paths.c projects.c help.c quit.c topology.c util.c ifeq ($(HAVE_GETMNTENT),yes) LCFLAGS += -DHAVE_GETMNTENT
libxcmd/util.c new file +67 -0
67 lines not on this page · raw message
mkfs/xfs_mkfs.c +26 -24
56 lines not on this page · raw message