]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs.xfs: fix ftype-vs-crc option combination testing
authorEric Sandeen <sandeen@sandeen.net>
Tue, 18 Aug 2015 07:53:17 +0000 (17:53 +1000)
committerDave Chinner <david@fromorbit.com>
Tue, 18 Aug 2015 07:53:17 +0000 (17:53 +1000)
mkfs.xfs got weird along the way; today it has different outcomes
depending on the order of option specification:

$ mkfs/mkfs.xfs -n ftype=1 -m crc=0 -dfile,name=fsfile,size=16g
cannot specify both crc and ftype
$ mkfs/mkfs.xfs -m crc=0 -n ftype=1 -dfile,name=fsfile,size=16g
<succeeds>

Somehow the tests got written as being constrained on what options
are specified - and in what order! - vs actually testing for
incompatible feature sets.

It's fine to specify both crc & ftype options, as long as it's an
allowed combination, so just test for the incompatible combination
(crc=1 and ftype=0) after all options have been processed.

[dchinner: fix dirftype init value so mkfs default config works]

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
mkfs/xfs_mkfs.c

index 69d61c7da6c65e0ee7dd0087ae68733e31d39775..d993fc04baf150dedec7f627dbd94dcec5e84617 100644 (file)
@@ -966,7 +966,8 @@ main(
        logversion = 2;
        logagno = logblocks = rtblocks = rtextblocks = 0;
        Nflag = nlflag = nsflag = nvflag = nci = 0;
-       nftype = dirftype = 0;          /* inode type information in the dir */
+       dirftype = 1;           /* inode type information in the dir */
+       nftype = 0;
        dirblocklog = dirblocksize = 0;
        dirversion = XFS_DFL_DIR_VERSION;
        qflag = 0;
@@ -1477,11 +1478,6 @@ main(
                                        if (c < 0 || c > 1)
                                                illegal(value, "m crc");
                                        crcs_enabled = c;
-                                       if (nftype && crcs_enabled) {
-                                               fprintf(stderr,
-_("cannot specify both crc and ftype\n"));
-                                               usage();
-                                       }
                                        break;
                                case M_FINOBT:
                                        if (!value || *value == '\0')
@@ -1555,11 +1551,6 @@ _("cannot specify both crc and ftype\n"));
                                        if (nftype)
                                                respec('n', nopts, N_FTYPE);
                                        dirftype = atoi(value);
-                                       if (crcs_enabled) {
-                                               fprintf(stderr,
-_("cannot specify both crc and ftype\n"));
-                                               usage();
-                                       }
                                        nftype = 1;
                                        break;
                                default:
@@ -1714,6 +1705,10 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
                        XFS_MIN_CRC_BLOCKSIZE);
                usage();
        }
+       if (crcs_enabled && !dirftype) {
+               fprintf(stderr, _("cannot disable ftype with crcs enabled\n"));
+               usage();
+       }
 
        memset(&ft, 0, sizeof(ft));
        get_topology(&xi, &ft, force_overwrite);