As Eric suggested, we could set both of the size/log flags after we have parsed the options - and from there on it simply means "manually set". After that, we could use just one flag, e.g. *sflag, to check whether the corresponding value is manually set or not. Signed-off-by: Li Zhong <zhong@xxxxxxxxxxxxxxxxxx> --- mkfs/xfs_mkfs.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 34bf2ff..aa3f391 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -1667,11 +1667,26 @@ main( dfile = xi.dname; /* + * Later code wants to know if the user manually set a value. + * There are two ways to specify on the cmdline; as size or as a log. + * if either was used, set both flags - from here on it simply means + * "manually set" + */ + if (bsflag || blflag) + bsflag = blflag = 1; + if (ssflag || slflag) + ssflag = slflag = 1; + if (isflag || ilflag) + isflag = ilflag = 1; + if (nsflag || nlflag) + nsflag = nlflag = 1; + + /* * Blocksize and sectorsize first, other things depend on them * For RAID4/5/6 we want to align sector size and block size, * so we need to start with the device geometry extraction too. */ - if (!blflag && !bsflag) { + if (!bsflag) { blocklog = XFS_DFL_BLOCKSIZE_LOG; blocksize = 1 << XFS_DFL_BLOCKSIZE_LOG; } @@ -1693,7 +1708,7 @@ main( * ft.sectoralign will never be set. */ sectorsize = blocksize; - } else if (!ssflag && !slflag) { + } else if (!ssflag) { /* * Unless specified manually on the command line use the * advertised sector size of the device. We use the physical @@ -1721,7 +1736,7 @@ _("switching to logical sector size %d\n"), } } - if (ft.sectoralign || (!ssflag && !slflag)) { + if (ft.sectoralign || !ssflag) { sectorlog = libxfs_highbit32(sectorsize); if (loginternal) { lsectorsize = sectorsize; @@ -1731,7 +1746,7 @@ _("switching to logical sector size %d\n"), if (sectorsize < XFS_MIN_SECTORSIZE || sectorsize > XFS_MAX_SECTORSIZE || sectorsize > blocksize) { - if (ssflag || slflag) + if (ssflag) fprintf(stderr, _("illegal sector size %d\n"), sectorsize); else fprintf(stderr, @@ -1760,7 +1775,7 @@ _("block size %d cannot be smaller than logical sector size %d\n"), */ if (crcs_enabled) { /* minimum inode size is 512 bytes, ipflag checked later */ - if ((isflag || ilflag) && inodelog < XFS_DINODE_DFL_CRC_LOG) { + if (isflag && inodelog < XFS_DINODE_DFL_CRC_LOG) { fprintf(stderr, _("Minimum inode size for CRCs is %d bytes\n"), 1 << XFS_DINODE_DFL_CRC_LOG); @@ -1804,7 +1819,7 @@ _("32 bit Project IDs always enabled on CRC enabled filesytems\n")); } } - if (nsflag || nlflag) { + if (nsflag) { if (dirblocksize < blocksize || dirblocksize > XFS_MAX_BLOCKSIZE) { fprintf(stderr, _("illegal directory block size %d\n"), @@ -1850,7 +1865,7 @@ _("32 bit Project IDs always enabled on CRC enabled filesytems\n")); if (ipflag) { inodelog = blocklog - libxfs_highbit32(inopblock); isize = 1 << inodelog; - } else if (!ilflag && !isflag) { + } else if (!isflag) { inodelog = crcs_enabled ? XFS_DINODE_DFL_CRC_LOG : XFS_DINODE_DFL_LOG; isize = 1 << inodelog; -- 1.8.1.4 _______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs