* [PATCH 1/8] mkfs: remove intermediate getstr followed by getnum
2016-08-02 15:42 [RFC PATCH 0/8] mkfs: centralised conflict detection Jan Tulak
@ 2016-08-02 15:42 ` Jan Tulak
2016-08-02 15:42 ` [PATCH 2/8] mkfs: merge tables for opts parsing into one table Jan Tulak
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jan Tulak @ 2016-08-02 15:42 UTC (permalink / raw)
To: xfs; +Cc: Jan Tulak
Some options loaded a number as a stringi with getstr and converted it to
number with getnum later in the code, without any reason for this approach.
(They were probably forgotten in some past cleaning.)
This patch changes them to skip the string and use getnum directly in the main
option-parsing loop, as do all the other numerical options.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
mkfs/xfs_mkfs.c | 88 +++++++++++++++++++++++++--------------------------------
1 file changed, 38 insertions(+), 50 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 8007dd0..188adb4 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1395,7 +1395,7 @@ main(
char *dfile;
int dirblocklog;
int dirblocksize;
- char *dsize;
+ __uint64_t dbytes;
int dsu;
int dsw;
int dsunit;
@@ -1419,7 +1419,7 @@ main(
xfs_rfsblock_t logblocks;
char *logfile;
int loginternal;
- char *logsize;
+ __uint64_t logbytes;
xfs_fsblock_t logstart;
int lvflag;
int lsflag;
@@ -1448,11 +1448,11 @@ main(
char *protostring;
int qflag;
xfs_rfsblock_t rtblocks;
+ __uint64_t rtbytes;
xfs_extlen_t rtextblocks;
xfs_rtblock_t rtextents;
- char *rtextsize;
+ __uint64_t rtextbytes;
char *rtfile;
- char *rtsize;
xfs_sb_t *sbp;
int sectorlog;
__uint64_t sector_mask;
@@ -1498,7 +1498,8 @@ main(
qflag = 0;
imaxpct = inodelog = inopblock = isize = 0;
dfile = logfile = rtfile = NULL;
- dsize = logsize = rtsize = rtextsize = protofile = NULL;
+ protofile = NULL;
+ rtbytes = rtextbytes = logbytes = dbytes = 0;
dsu = dsw = dsunit = dswidth = lalign = lsu = lsunit = 0;
nodsflag = norsflag = 0;
force_overwrite = 0;
@@ -1564,7 +1565,7 @@ main(
xi.dname = getstr(value, &dopts, D_NAME);
break;
case D_SIZE:
- dsize = getstr(value, &dopts, D_SIZE);
+ dbytes = getnum(value, &dopts, D_SIZE);
break;
case D_SUNIT:
dsunit = getnum(value, &dopts, D_SUNIT);
@@ -1711,7 +1712,7 @@ main(
lvflag = 1;
break;
case L_SIZE:
- logsize = getstr(value, &lopts, L_SIZE);
+ logbytes = getnum(value, &lopts, L_SIZE);
break;
case L_SECTLOG:
lsectorlog = getnum(value, &lopts,
@@ -1835,8 +1836,7 @@ main(
switch (getsubopt(&p, (constpp)subopts,
&value)) {
case R_EXTSIZE:
- rtextsize = getstr(value, &ropts,
- R_EXTSIZE);
+ rtextbytes = getnum(value, &ropts, R_EXTSIZE);
break;
case R_FILE:
xi.risfile = getnum(value, &ropts,
@@ -1848,7 +1848,7 @@ main(
R_NAME);
break;
case R_SIZE:
- rtsize = getstr(value, &ropts, R_SIZE);
+ rtbytes = getnum(value, &ropts, R_SIZE);
break;
case R_NOALIGN:
norsflag = getnum(value, &ropts,
@@ -1952,14 +1952,14 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
* sector size mismatches between the new filesystem and the underlying
* host filesystem.
*/
- check_device_type(dfile, &xi.disfile, !dsize, !dfile,
+ check_device_type(dfile, &xi.disfile, !dbytes, !dfile,
Nflag ? NULL : &xi.dcreat, force_overwrite, "d");
if (!loginternal)
- check_device_type(xi.logname, &xi.lisfile, !logsize, !xi.logname,
+ check_device_type(xi.logname, &xi.lisfile, !logbytes, !xi.logname,
Nflag ? NULL : &xi.lcreat,
force_overwrite, "l");
if (xi.rtname)
- check_device_type(xi.rtname, &xi.risfile, !rtsize, !xi.rtname,
+ check_device_type(xi.rtname, &xi.risfile, !rtbytes, !xi.rtname,
Nflag ? NULL : &xi.rcreat,
force_overwrite, "r");
if (xi.disfile || xi.lisfile || xi.risfile)
@@ -2119,10 +2119,7 @@ _("sparse inodes not supported without CRC support\n"));
}
- if (dsize) {
- __uint64_t dbytes;
-
- dbytes = getnum(dsize, &dopts, D_SIZE);
+ if (dbytes) {
if (dbytes % XFS_MIN_BLOCKSIZE) {
fprintf(stderr,
_("illegal data length %lld, not a multiple of %d\n"),
@@ -2151,10 +2148,7 @@ _("sparse inodes not supported without CRC support\n"));
usage();
}
- if (logsize) {
- __uint64_t logbytes;
-
- logbytes = getnum(logsize, &lopts, L_SIZE);
+ if (logbytes) {
if (logbytes % XFS_MIN_BLOCKSIZE) {
fprintf(stderr,
_("illegal log length %lld, not a multiple of %d\n"),
@@ -2168,10 +2162,7 @@ _("sparse inodes not supported without CRC support\n"));
(long long)logbytes, blocksize,
(long long)(logblocks << blocklog));
}
- if (rtsize) {
- __uint64_t rtbytes;
-
- rtbytes = getnum(rtsize, &ropts, R_SIZE);
+ if (rtbytes) {
if (rtbytes % XFS_MIN_BLOCKSIZE) {
fprintf(stderr,
_("illegal rt length %lld, not a multiple of %d\n"),
@@ -2188,10 +2179,7 @@ _("sparse inodes not supported without CRC support\n"));
/*
* If specified, check rt extent size against its constraints.
*/
- if (rtextsize) {
- __uint64_t rtextbytes;
-
- rtextbytes = getnum(rtextsize, &ropts, R_EXTSIZE);
+ if (rtextbytes) {
if (rtextbytes % blocksize) {
fprintf(stderr,
_("illegal rt extent size %lld, not a multiple of %d\n"),
@@ -2208,7 +2196,7 @@ _("sparse inodes not supported without CRC support\n"));
__uint64_t rswidth;
__uint64_t rtextbytes;
- if (!norsflag && !xi.risfile && !(!rtsize && xi.disfile))
+ if (!norsflag && !xi.risfile && !(!rtbytes && xi.disfile))
rswidth = ft.rtswidth;
else
rswidth = 0;
@@ -2319,15 +2307,15 @@ _("sparse inodes not supported without CRC support\n"));
rtfile = _("volume rt");
else if (!xi.rtdev)
rtfile = _("none");
- if (dsize && xi.dsize > 0 && dblocks > DTOBT(xi.dsize)) {
+ if (dbytes && xi.dsize > 0 && dblocks > DTOBT(xi.dsize)) {
fprintf(stderr,
- _("size %s specified for data subvolume is too large, "
+ _("size %lld specified for data subvolume is too large, "
"maximum is %lld blocks\n"),
- dsize, (long long)DTOBT(xi.dsize));
+ (long long)dbytes, (long long)DTOBT(xi.dsize));
usage();
- } else if (!dsize && xi.dsize > 0)
+ } else if (!dbytes && xi.dsize > 0)
dblocks = DTOBT(xi.dsize);
- else if (!dsize) {
+ else if (!dbytes) {
fprintf(stderr, _("can't get size of data subvolume\n"));
usage();
}
@@ -2360,22 +2348,22 @@ reported by the device (%u).\n"),
reported by the device (%u).\n"),
lsectorsize, xi.lbsize);
}
- if (rtsize && xi.rtsize > 0 && xi.rtbsize > sectorsize) {
+ if (rtbytes && xi.rtsize > 0 && xi.rtbsize > sectorsize) {
fprintf(stderr, _(
"Warning: the realtime subvolume sector size %u is less than the sector size\n\
reported by the device (%u).\n"),
sectorsize, xi.rtbsize);
}
- if (rtsize && xi.rtsize > 0 && rtblocks > DTOBT(xi.rtsize)) {
+ if (rtbytes && xi.rtsize > 0 && rtblocks > DTOBT(xi.rtsize)) {
fprintf(stderr,
- _("size %s specified for rt subvolume is too large, "
+ _("size %lld specified for rt subvolume is too large, "
"maximum is %lld blocks\n"),
- rtsize, (long long)DTOBT(xi.rtsize));
+ (long long)rtbytes, (long long)DTOBT(xi.rtsize));
usage();
- } else if (!rtsize && xi.rtsize > 0)
+ } else if (!rtbytes && xi.rtsize > 0)
rtblocks = DTOBT(xi.rtsize);
- else if (rtsize && !xi.rtdev) {
+ else if (rtbytes && !xi.rtdev) {
fprintf(stderr,
_("size specified for non-existent rt subvolume\n"));
usage();
@@ -2578,26 +2566,26 @@ an AG size that is one stripe unit smaller, for example %llu.\n"),
sb_feat.log_version, lsunit, sb_feat.finobt);
ASSERT(min_logblocks);
min_logblocks = MAX(XFS_MIN_LOG_BLOCKS, min_logblocks);
- if (!logsize && dblocks >= (1024*1024*1024) >> blocklog)
+ if (!logbytes && dblocks >= (1024*1024*1024) >> blocklog)
min_logblocks = MAX(min_logblocks, XFS_MIN_LOG_BYTES>>blocklog);
- if (logsize && xi.logBBsize > 0 && logblocks > DTOBT(xi.logBBsize)) {
+ if (logbytes && xi.logBBsize > 0 && logblocks > DTOBT(xi.logBBsize)) {
fprintf(stderr,
-_("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
- logsize, (long long)DTOBT(xi.logBBsize));
+_("size %lld specified for log subvolume is too large, maximum is %lld blocks\n"),
+ (long long)logbytes, (long long)DTOBT(xi.logBBsize));
usage();
- } else if (!logsize && xi.logBBsize > 0) {
+ } else if (!logbytes && xi.logBBsize > 0) {
logblocks = DTOBT(xi.logBBsize);
- } else if (logsize && !xi.logdev && !loginternal) {
+ } else if (logbytes && !xi.logdev && !loginternal) {
fprintf(stderr,
_("size specified for non-existent log subvolume\n"));
usage();
- } else if (loginternal && logsize && logblocks >= dblocks) {
+ } else if (loginternal && logbytes && logblocks >= dblocks) {
fprintf(stderr, _("size %lld too large for internal log\n"),
(long long)logblocks);
usage();
} else if (!loginternal && !xi.logdev) {
logblocks = 0;
- } else if (loginternal && !logsize) {
+ } else if (loginternal && !logbytes) {
if (dblocks < GIGABYTES(1, blocklog)) {
/* tiny filesystems get minimum sized logs. */
@@ -2661,7 +2649,7 @@ _("size %s specified for log subvolume is too large, maximum is %lld blocks\n"),
* Readjust the log size to fit within an AG if it was sized
* automatically.
*/
- if (!logsize) {
+ if (!logbytes) {
logblocks = MIN(logblocks,
XFS_ALLOC_AG_MAX_USABLE(mp));
--
2.5.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/8] mkfs: merge tables for opts parsing into one table
2016-08-02 15:42 [RFC PATCH 0/8] mkfs: centralised conflict detection Jan Tulak
2016-08-02 15:42 ` [PATCH 1/8] mkfs: remove intermediate getstr followed by getnum Jan Tulak
@ 2016-08-02 15:42 ` Jan Tulak
2016-08-02 15:42 ` [PATCH 3/8] mkfs: extend opt_params with a value field Jan Tulak
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jan Tulak @ 2016-08-02 15:42 UTC (permalink / raw)
To: xfs; +Cc: Jan Tulak
Merge separate instances of opt_params into one indexable table. Git makes this
patch looks a bit more complicated, but it does not change values or structure
of anything else. It only moves all the "struct opt_params dopts = {...}",
changes indentation for these substructures and replaces their usage (dopts ->
opts[OPT_D]).
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
mkfs/xfs_mkfs.c | 1214 ++++++++++++++++++++++++++++---------------------------
1 file changed, 624 insertions(+), 590 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 188adb4..4741522 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -42,6 +42,7 @@ static int ispow2(unsigned int i);
unsigned int blocksize;
unsigned int sectorsize;
+#define MAX_OPTS 16
#define MAX_SUBOPTS 16
#define SUBOPT_NEEDS_VAL (-1LL)
#define MAX_CONFLICTS 8
@@ -52,6 +53,10 @@ unsigned int sectorsize;
*
* Description of the structure members follows:
*
+ * index MANDATORY
+ * An integer denoting the position of the specific option in opts array,
+ * counting from 0 up to MAX_OPTS.
+ *
* name MANDATORY
* Name is a single char, e.g., for '-d file', name is 'd'.
*
@@ -112,6 +117,7 @@ unsigned int sectorsize;
* value in any case.
*/
struct opt_params {
+ int index;
const char name;
const char *subopts[MAX_SUBOPTS];
@@ -126,568 +132,576 @@ struct opt_params {
long long maxval;
long long defaultval;
} subopt_params[MAX_SUBOPTS];
-};
-
-struct opt_params bopts = {
- .name = 'b',
- .subopts = {
+} opts[MAX_OPTS] = {
+#define OPT_B 0
+ {
+ .index = OPT_B,
+ .name = 'b',
+ .subopts = {
#define B_LOG 0
- "log",
+ "log",
#define B_SIZE 1
- "size",
- NULL
- },
- .subopt_params = {
- { .index = B_LOG,
- .conflicts = { B_SIZE,
- LAST_CONFLICT },
- .minval = XFS_MIN_BLOCKSIZE_LOG,
- .maxval = XFS_MAX_BLOCKSIZE_LOG,
- .defaultval = SUBOPT_NEEDS_VAL,
+ "size",
+ NULL
},
- { .index = B_SIZE,
- .convert = true,
- .is_power_2 = true,
- .conflicts = { B_LOG,
- LAST_CONFLICT },
- .minval = XFS_MIN_BLOCKSIZE,
- .maxval = XFS_MAX_BLOCKSIZE,
- .defaultval = SUBOPT_NEEDS_VAL,
+ .subopt_params = {
+ { .index = B_LOG,
+ .conflicts = { B_SIZE,
+ LAST_CONFLICT },
+ .minval = XFS_MIN_BLOCKSIZE_LOG,
+ .maxval = XFS_MAX_BLOCKSIZE_LOG,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = B_SIZE,
+ .convert = true,
+ .is_power_2 = true,
+ .conflicts = { B_LOG,
+ LAST_CONFLICT },
+ .minval = XFS_MIN_BLOCKSIZE,
+ .maxval = XFS_MAX_BLOCKSIZE,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
},
},
-};
-
-struct opt_params dopts = {
- .name = 'd',
- .subopts = {
-#define D_AGCOUNT 0
- "agcount",
-#define D_FILE 1
- "file",
-#define D_NAME 2
- "name",
-#define D_SIZE 3
- "size",
-#define D_SUNIT 4
- "sunit",
-#define D_SWIDTH 5
- "swidth",
-#define D_AGSIZE 6
- "agsize",
-#define D_SU 7
- "su",
-#define D_SW 8
- "sw",
-#define D_SECTLOG 9
- "sectlog",
-#define D_SECTSIZE 10
- "sectsize",
-#define D_NOALIGN 11
- "noalign",
-#define D_RTINHERIT 12
- "rtinherit",
-#define D_PROJINHERIT 13
- "projinherit",
-#define D_EXTSZINHERIT 14
- "extszinherit",
- NULL
- },
- .subopt_params = {
- { .index = D_AGCOUNT,
- .conflicts = { D_AGSIZE,
- LAST_CONFLICT },
- .minval = 1,
- .maxval = XFS_MAX_AGNUMBER,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = D_FILE,
- .conflicts = { LAST_CONFLICT },
- .minval = 0,
- .maxval = 1,
- .defaultval = 1,
- },
- { .index = D_NAME,
- .conflicts = { LAST_CONFLICT },
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = D_SIZE,
- .conflicts = { LAST_CONFLICT },
- .convert = true,
- .minval = XFS_AG_MIN_BYTES,
- .maxval = LLONG_MAX,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = D_SUNIT,
- .conflicts = { D_NOALIGN,
- D_SU,
- D_SW,
- LAST_CONFLICT },
- .minval = 0,
- .maxval = UINT_MAX,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = D_SWIDTH,
- .conflicts = { D_NOALIGN,
- D_SU,
- D_SW,
- LAST_CONFLICT },
- .minval = 0,
- .maxval = UINT_MAX,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = D_AGSIZE,
- .conflicts = { D_AGCOUNT,
- LAST_CONFLICT },
- .convert = true,
- .minval = XFS_AG_MIN_BYTES,
- .maxval = XFS_AG_MAX_BYTES,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = D_SU,
- .conflicts = { D_NOALIGN,
- D_SUNIT,
- D_SWIDTH,
- LAST_CONFLICT },
- .convert = true,
- .minval = 0,
- .maxval = UINT_MAX,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = D_SW,
- .conflicts = { D_NOALIGN,
- D_SUNIT,
- D_SWIDTH,
- LAST_CONFLICT },
- .minval = 0,
- .maxval = UINT_MAX,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = D_SECTLOG,
- .conflicts = { D_SECTSIZE,
- LAST_CONFLICT },
- .minval = XFS_MIN_SECTORSIZE_LOG,
- .maxval = XFS_MAX_SECTORSIZE_LOG,
- .defaultval = SUBOPT_NEEDS_VAL,
+#define OPT_D 1
+ {
+ .index = OPT_D,
+ .name = 'd',
+ .subopts = {
+ #define D_AGCOUNT 0
+ "agcount",
+ #define D_FILE 1
+ "file",
+ #define D_NAME 2
+ "name",
+ #define D_SIZE 3
+ "size",
+ #define D_SUNIT 4
+ "sunit",
+ #define D_SWIDTH 5
+ "swidth",
+ #define D_AGSIZE 6
+ "agsize",
+ #define D_SU 7
+ "su",
+ #define D_SW 8
+ "sw",
+ #define D_SECTLOG 9
+ "sectlog",
+ #define D_SECTSIZE 10
+ "sectsize",
+ #define D_NOALIGN 11
+ "noalign",
+ #define D_RTINHERIT 12
+ "rtinherit",
+ #define D_PROJINHERIT 13
+ "projinherit",
+ #define D_EXTSZINHERIT 14
+ "extszinherit",
+ NULL
},
- { .index = D_SECTSIZE,
- .conflicts = { D_SECTLOG,
- LAST_CONFLICT },
- .convert = true,
- .is_power_2 = true,
- .minval = XFS_MIN_SECTORSIZE,
- .maxval = XFS_MAX_SECTORSIZE,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = D_NOALIGN,
- .conflicts = { D_SU,
- D_SW,
- D_SUNIT,
- D_SWIDTH,
- LAST_CONFLICT },
- .minval = 0,
- .maxval = 1,
- .defaultval = 1,
- },
- { .index = D_RTINHERIT,
- .conflicts = { LAST_CONFLICT },
- .minval = 1,
- .maxval = 1,
- .defaultval = 1,
- },
- { .index = D_PROJINHERIT,
- .conflicts = { LAST_CONFLICT },
- .minval = 0,
- .maxval = UINT_MAX,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = D_EXTSZINHERIT,
- .conflicts = { LAST_CONFLICT },
- .minval = 0,
- .maxval = UINT_MAX,
- .defaultval = SUBOPT_NEEDS_VAL,
+ .subopt_params = {
+ { .index = D_AGCOUNT,
+ .conflicts = { D_AGSIZE,
+ LAST_CONFLICT },
+ .minval = 1,
+ .maxval = XFS_MAX_AGNUMBER,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = D_FILE,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 0,
+ .maxval = 1,
+ .defaultval = 1,
+ },
+ { .index = D_NAME,
+ .conflicts = { LAST_CONFLICT },
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = D_SIZE,
+ .conflicts = { LAST_CONFLICT },
+ .convert = true,
+ .minval = XFS_AG_MIN_BYTES,
+ .maxval = LLONG_MAX,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = D_SUNIT,
+ .conflicts = { D_NOALIGN,
+ D_SU,
+ D_SW,
+ LAST_CONFLICT },
+ .minval = 0,
+ .maxval = UINT_MAX,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = D_SWIDTH,
+ .conflicts = { D_NOALIGN,
+ D_SU,
+ D_SW,
+ LAST_CONFLICT },
+ .minval = 0,
+ .maxval = UINT_MAX,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = D_AGSIZE,
+ .conflicts = { D_AGCOUNT,
+ LAST_CONFLICT },
+ .convert = true,
+ .minval = XFS_AG_MIN_BYTES,
+ .maxval = XFS_AG_MAX_BYTES,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = D_SU,
+ .conflicts = { D_NOALIGN,
+ D_SUNIT,
+ D_SWIDTH,
+ LAST_CONFLICT },
+ .convert = true,
+ .minval = 0,
+ .maxval = UINT_MAX,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = D_SW,
+ .conflicts = { D_NOALIGN,
+ D_SUNIT,
+ D_SWIDTH,
+ LAST_CONFLICT },
+ .minval = 0,
+ .maxval = UINT_MAX,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = D_SECTLOG,
+ .conflicts = { D_SECTSIZE,
+ LAST_CONFLICT },
+ .minval = XFS_MIN_SECTORSIZE_LOG,
+ .maxval = XFS_MAX_SECTORSIZE_LOG,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = D_SECTSIZE,
+ .conflicts = { D_SECTLOG,
+ LAST_CONFLICT },
+ .convert = true,
+ .is_power_2 = true,
+ .minval = XFS_MIN_SECTORSIZE,
+ .maxval = XFS_MAX_SECTORSIZE,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = D_NOALIGN,
+ .conflicts = { D_SU,
+ D_SW,
+ D_SUNIT,
+ D_SWIDTH,
+ LAST_CONFLICT },
+ .minval = 0,
+ .maxval = 1,
+ .defaultval = 1,
+ },
+ { .index = D_RTINHERIT,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 1,
+ .maxval = 1,
+ .defaultval = 1,
+ },
+ { .index = D_PROJINHERIT,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 0,
+ .maxval = UINT_MAX,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = D_EXTSZINHERIT,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 0,
+ .maxval = UINT_MAX,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
},
},
-};
-
-
-struct opt_params iopts = {
- .name = 'i',
- .subopts = {
+#define OPT_I 2
+ {
+ .index = OPT_I,
+ .name = 'i',
+ .subopts = {
#define I_ALIGN 0
- "align",
+ "align",
#define I_LOG 1
- "log",
+ "log",
#define I_MAXPCT 2
- "maxpct",
+ "maxpct",
#define I_PERBLOCK 3
- "perblock",
+ "perblock",
#define I_SIZE 4
- "size",
+ "size",
#define I_ATTR 5
- "attr",
+ "attr",
#define I_PROJID32BIT 6
- "projid32bit",
+ "projid32bit",
#define I_SPINODES 7
- "sparse",
- NULL
- },
- .subopt_params = {
- { .index = I_ALIGN,
- .conflicts = { LAST_CONFLICT },
- .minval = 0,
- .maxval = 1,
- .defaultval = 1,
+ "sparse",
+ NULL
},
- { .index = I_LOG,
- .conflicts = { I_PERBLOCK,
- I_SIZE,
- LAST_CONFLICT },
- .minval = XFS_DINODE_MIN_LOG,
- .maxval = XFS_DINODE_MAX_LOG,
- .defaultval = SUBOPT_NEEDS_VAL,
+ .subopt_params = {
+ { .index = I_ALIGN,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 0,
+ .maxval = 1,
+ .defaultval = 1,
+ },
+ { .index = I_LOG,
+ .conflicts = { I_PERBLOCK,
+ I_SIZE,
+ LAST_CONFLICT },
+ .minval = XFS_DINODE_MIN_LOG,
+ .maxval = XFS_DINODE_MAX_LOG,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = I_MAXPCT,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 0,
+ .maxval = 100,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = I_PERBLOCK,
+ .conflicts = { I_LOG,
+ I_SIZE,
+ LAST_CONFLICT },
+ .is_power_2 = true,
+ .minval = XFS_MIN_INODE_PERBLOCK,
+ .maxval = XFS_MAX_BLOCKSIZE / XFS_DINODE_MIN_SIZE,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = I_SIZE,
+ .conflicts = { I_PERBLOCK,
+ I_LOG,
+ LAST_CONFLICT },
+ .is_power_2 = true,
+ .minval = XFS_DINODE_MIN_SIZE,
+ .maxval = XFS_DINODE_MAX_SIZE,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = I_ATTR,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 0,
+ .maxval = 2,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = I_PROJID32BIT,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 0,
+ .maxval = 1,
+ .defaultval = 1,
+ },
+ { .index = I_SPINODES,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 0,
+ .maxval = 1,
+ .defaultval = 1,
+ },
},
- { .index = I_MAXPCT,
- .conflicts = { LAST_CONFLICT },
- .minval = 0,
- .maxval = 100,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = I_PERBLOCK,
- .conflicts = { I_LOG,
- I_SIZE,
- LAST_CONFLICT },
- .is_power_2 = true,
- .minval = XFS_MIN_INODE_PERBLOCK,
- .maxval = XFS_MAX_BLOCKSIZE / XFS_DINODE_MIN_SIZE,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = I_SIZE,
- .conflicts = { I_PERBLOCK,
- I_LOG,
- LAST_CONFLICT },
- .is_power_2 = true,
- .minval = XFS_DINODE_MIN_SIZE,
- .maxval = XFS_DINODE_MAX_SIZE,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = I_ATTR,
- .conflicts = { LAST_CONFLICT },
- .minval = 0,
- .maxval = 2,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = I_PROJID32BIT,
- .conflicts = { LAST_CONFLICT },
- .minval = 0,
- .maxval = 1,
- .defaultval = 1,
- },
- { .index = I_SPINODES,
- .conflicts = { LAST_CONFLICT },
- .minval = 0,
- .maxval = 1,
- .defaultval = 1,
- },
- },
-};
-
-struct opt_params lopts = {
- .name = 'l',
- .subopts = {
-#define L_AGNUM 0
- "agnum",
-#define L_INTERNAL 1
- "internal",
-#define L_SIZE 2
- "size",
-#define L_VERSION 3
- "version",
-#define L_SUNIT 4
- "sunit",
-#define L_SU 5
- "su",
-#define L_DEV 6
- "logdev",
-#define L_SECTLOG 7
- "sectlog",
-#define L_SECTSIZE 8
- "sectsize",
-#define L_FILE 9
- "file",
-#define L_NAME 10
- "name",
-#define L_LAZYSBCNTR 11
- "lazy-count",
- NULL
},
- .subopt_params = {
- { .index = L_AGNUM,
- .conflicts = { L_DEV,
- LAST_CONFLICT },
- .minval = 0,
- .maxval = UINT_MAX,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = L_INTERNAL,
- .conflicts = { L_FILE,
- L_DEV,
- LAST_CONFLICT },
- .minval = 0,
- .maxval = 1,
- .defaultval = 1,
- },
- { .index = L_SIZE,
- .conflicts = { LAST_CONFLICT },
- .convert = true,
- .minval = 2 * 1024 * 1024LL, /* XXX: XFS_MIN_LOG_BYTES */
- .maxval = XFS_MAX_LOG_BYTES,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = L_VERSION,
- .conflicts = { LAST_CONFLICT },
- .minval = 1,
- .maxval = 2,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = L_SUNIT,
- .conflicts = { L_SU,
- LAST_CONFLICT },
- .minval = 1,
- .maxval = BTOBB(XLOG_MAX_RECORD_BSIZE),
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = L_SU,
- .conflicts = { L_SUNIT,
- LAST_CONFLICT },
- .convert = true,
- .minval = BBTOB(1),
- .maxval = XLOG_MAX_RECORD_BSIZE,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = L_DEV,
- .conflicts = { L_AGNUM,
- L_INTERNAL,
- LAST_CONFLICT },
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = L_SECTLOG,
- .conflicts = { L_SECTSIZE,
- LAST_CONFLICT },
- .minval = XFS_MIN_SECTORSIZE_LOG,
- .maxval = XFS_MAX_SECTORSIZE_LOG,
- .defaultval = SUBOPT_NEEDS_VAL,
+#define OPT_L 3
+ {
+ .index = OPT_L,
+ .name = 'l',
+ .subopts = {
+ #define L_AGNUM 0
+ "agnum",
+ #define L_INTERNAL 1
+ "internal",
+ #define L_SIZE 2
+ "size",
+ #define L_VERSION 3
+ "version",
+ #define L_SUNIT 4
+ "sunit",
+ #define L_SU 5
+ "su",
+ #define L_DEV 6
+ "logdev",
+ #define L_SECTLOG 7
+ "sectlog",
+ #define L_SECTSIZE 8
+ "sectsize",
+ #define L_FILE 9
+ "file",
+ #define L_NAME 10
+ "name",
+ #define L_LAZYSBCNTR 11
+ "lazy-count",
+ NULL
},
- { .index = L_SECTSIZE,
- .conflicts = { L_SECTLOG,
- LAST_CONFLICT },
- .convert = true,
- .is_power_2 = true,
- .minval = XFS_MIN_SECTORSIZE,
- .maxval = XFS_MAX_SECTORSIZE,
- .defaultval = SUBOPT_NEEDS_VAL,
+ .subopt_params = {
+ { .index = L_AGNUM,
+ .conflicts = { L_DEV,
+ LAST_CONFLICT },
+ .minval = 0,
+ .maxval = UINT_MAX,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = L_INTERNAL,
+ .conflicts = { L_FILE,
+ L_DEV,
+ LAST_CONFLICT },
+ .minval = 0,
+ .maxval = 1,
+ .defaultval = 1,
+ },
+ { .index = L_SIZE,
+ .conflicts = { LAST_CONFLICT },
+ .convert = true,
+ .minval = 2 * 1024 * 1024LL, /* XXX: XFS_MIN_LOG_BYTES */
+ .maxval = XFS_MAX_LOG_BYTES,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = L_VERSION,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 1,
+ .maxval = 2,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = L_SUNIT,
+ .conflicts = { L_SU,
+ LAST_CONFLICT },
+ .minval = 1,
+ .maxval = BTOBB(XLOG_MAX_RECORD_BSIZE),
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = L_SU,
+ .conflicts = { L_SUNIT,
+ LAST_CONFLICT },
+ .convert = true,
+ .minval = BBTOB(1),
+ .maxval = XLOG_MAX_RECORD_BSIZE,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = L_DEV,
+ .conflicts = { L_AGNUM,
+ L_INTERNAL,
+ LAST_CONFLICT },
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = L_SECTLOG,
+ .conflicts = { L_SECTSIZE,
+ LAST_CONFLICT },
+ .minval = XFS_MIN_SECTORSIZE_LOG,
+ .maxval = XFS_MAX_SECTORSIZE_LOG,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = L_SECTSIZE,
+ .conflicts = { L_SECTLOG,
+ LAST_CONFLICT },
+ .convert = true,
+ .is_power_2 = true,
+ .minval = XFS_MIN_SECTORSIZE,
+ .maxval = XFS_MAX_SECTORSIZE,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = L_FILE,
+ .conflicts = { L_INTERNAL,
+ LAST_CONFLICT },
+ .minval = 0,
+ .maxval = 1,
+ .defaultval = 1,
+ },
+ { .index = L_NAME,
+ .conflicts = { L_AGNUM,
+ L_INTERNAL,
+ LAST_CONFLICT },
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = L_LAZYSBCNTR,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 0,
+ .maxval = 1,
+ .defaultval = 1,
+ },
},
- { .index = L_FILE,
- .conflicts = { L_INTERNAL,
- LAST_CONFLICT },
- .minval = 0,
- .maxval = 1,
- .defaultval = 1,
- },
- { .index = L_NAME,
- .conflicts = { L_AGNUM,
- L_INTERNAL,
- LAST_CONFLICT },
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = L_LAZYSBCNTR,
- .conflicts = { LAST_CONFLICT },
- .minval = 0,
- .maxval = 1,
- .defaultval = 1,
- },
- },
-};
-
-struct opt_params nopts = {
- .name = 'n',
- .subopts = {
-#define N_LOG 0
- "log",
-#define N_SIZE 1
- "size",
-#define N_VERSION 2
- "version",
-#define N_FTYPE 3
- "ftype",
- NULL,
},
- .subopt_params = {
- { .index = N_LOG,
- .conflicts = { N_SIZE,
- LAST_CONFLICT },
- .minval = XFS_MIN_REC_DIRSIZE,
- .maxval = XFS_MAX_BLOCKSIZE_LOG,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = N_SIZE,
- .conflicts = { N_LOG,
- LAST_CONFLICT },
- .convert = true,
- .is_power_2 = true,
- .minval = 1 << XFS_MIN_REC_DIRSIZE,
- .maxval = XFS_MAX_BLOCKSIZE,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = N_VERSION,
- .conflicts = { LAST_CONFLICT },
- .minval = 2,
- .maxval = 2,
- .defaultval = SUBOPT_NEEDS_VAL,
+#define OPT_N 4
+ {
+ .index = OPT_N,
+ .name = 'n',
+ .subopts = {
+ #define N_LOG 0
+ "log",
+ #define N_SIZE 1
+ "size",
+ #define N_VERSION 2
+ "version",
+ #define N_FTYPE 3
+ "ftype",
+ NULL,
},
- { .index = N_FTYPE,
- .conflicts = { LAST_CONFLICT },
- .minval = 0,
- .maxval = 1,
- .defaultval = 1,
+ .subopt_params = {
+ { .index = N_LOG,
+ .conflicts = { N_SIZE,
+ LAST_CONFLICT },
+ .minval = XFS_MIN_REC_DIRSIZE,
+ .maxval = XFS_MAX_BLOCKSIZE_LOG,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = N_SIZE,
+ .conflicts = { N_LOG,
+ LAST_CONFLICT },
+ .convert = true,
+ .is_power_2 = true,
+ .minval = 1 << XFS_MIN_REC_DIRSIZE,
+ .maxval = XFS_MAX_BLOCKSIZE,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = N_VERSION,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 2,
+ .maxval = 2,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = N_FTYPE,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 0,
+ .maxval = 1,
+ .defaultval = 1,
+ },
},
},
-};
-
-struct opt_params ropts = {
- .name = 'r',
- .subopts = {
-#define R_EXTSIZE 0
- "extsize",
-#define R_SIZE 1
- "size",
-#define R_DEV 2
- "rtdev",
-#define R_FILE 3
- "file",
-#define R_NAME 4
- "name",
-#define R_NOALIGN 5
- "noalign",
- NULL
- },
- .subopt_params = {
- { .index = R_EXTSIZE,
- .conflicts = { LAST_CONFLICT },
- .convert = true,
- .minval = XFS_MIN_RTEXTSIZE,
- .maxval = XFS_MAX_RTEXTSIZE,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = R_SIZE,
- .conflicts = { LAST_CONFLICT },
- .convert = true,
- .minval = 0,
- .maxval = LLONG_MAX,
- .defaultval = SUBOPT_NEEDS_VAL,
+#define OPT_R 5
+ {
+ .index = OPT_R,
+ .name = 'r',
+ .subopts = {
+ #define R_EXTSIZE 0
+ "extsize",
+ #define R_SIZE 1
+ "size",
+ #define R_DEV 2
+ "rtdev",
+ #define R_FILE 3
+ "file",
+ #define R_NAME 4
+ "name",
+ #define R_NOALIGN 5
+ "noalign",
+ NULL
},
- { .index = R_DEV,
- .conflicts = { LAST_CONFLICT },
- .defaultval = SUBOPT_NEEDS_VAL,
+ .subopt_params = {
+ { .index = R_EXTSIZE,
+ .conflicts = { LAST_CONFLICT },
+ .convert = true,
+ .minval = XFS_MIN_RTEXTSIZE,
+ .maxval = XFS_MAX_RTEXTSIZE,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = R_SIZE,
+ .conflicts = { LAST_CONFLICT },
+ .convert = true,
+ .minval = 0,
+ .maxval = LLONG_MAX,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = R_DEV,
+ .conflicts = { LAST_CONFLICT },
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = R_FILE,
+ .minval = 0,
+ .maxval = 1,
+ .defaultval = 1,
+ .conflicts = { LAST_CONFLICT },
+ },
+ { .index = R_NAME,
+ .conflicts = { LAST_CONFLICT },
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = R_NOALIGN,
+ .minval = 0,
+ .maxval = 1,
+ .defaultval = 1,
+ .conflicts = { LAST_CONFLICT },
+ },
},
- { .index = R_FILE,
- .minval = 0,
- .maxval = 1,
- .defaultval = 1,
- .conflicts = { LAST_CONFLICT },
- },
- { .index = R_NAME,
- .conflicts = { LAST_CONFLICT },
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = R_NOALIGN,
- .minval = 0,
- .maxval = 1,
- .defaultval = 1,
- .conflicts = { LAST_CONFLICT },
- },
- },
-};
-
-struct opt_params sopts = {
- .name = 's',
- .subopts = {
-#define S_LOG 0
- "log",
-#define S_SECTLOG 1
- "sectlog",
-#define S_SIZE 2
- "size",
-#define S_SECTSIZE 3
- "sectsize",
- NULL
},
- .subopt_params = {
- { .index = S_LOG,
- .conflicts = { S_SIZE,
- S_SECTSIZE,
- LAST_CONFLICT },
- .minval = XFS_MIN_SECTORSIZE_LOG,
- .maxval = XFS_MAX_SECTORSIZE_LOG,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = S_SECTLOG,
- .conflicts = { S_SIZE,
- S_SECTSIZE,
- LAST_CONFLICT },
- .minval = XFS_MIN_SECTORSIZE_LOG,
- .maxval = XFS_MAX_SECTORSIZE_LOG,
- .defaultval = SUBOPT_NEEDS_VAL,
- },
- { .index = S_SIZE,
- .conflicts = { S_LOG,
- S_SECTLOG,
- LAST_CONFLICT },
- .convert = true,
- .is_power_2 = true,
- .minval = XFS_MIN_SECTORSIZE,
- .maxval = XFS_MAX_SECTORSIZE,
- .defaultval = SUBOPT_NEEDS_VAL,
+#define OPT_S 6
+ {
+ .index = OPT_S,
+ .name = 's',
+ .subopts = {
+ #define S_LOG 0
+ "log",
+ #define S_SECTLOG 1
+ "sectlog",
+ #define S_SIZE 2
+ "size",
+ #define S_SECTSIZE 3
+ "sectsize",
+ NULL
},
- { .index = S_SECTSIZE,
- .conflicts = { S_LOG,
- S_SECTLOG,
- LAST_CONFLICT },
- .convert = true,
- .is_power_2 = true,
- .minval = XFS_MIN_SECTORSIZE,
- .maxval = XFS_MAX_SECTORSIZE,
- .defaultval = SUBOPT_NEEDS_VAL,
+ .subopt_params = {
+ { .index = S_LOG,
+ .conflicts = { S_SIZE,
+ S_SECTSIZE,
+ LAST_CONFLICT },
+ .minval = XFS_MIN_SECTORSIZE_LOG,
+ .maxval = XFS_MAX_SECTORSIZE_LOG,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = S_SECTLOG,
+ .conflicts = { S_SIZE,
+ S_SECTSIZE,
+ LAST_CONFLICT },
+ .minval = XFS_MIN_SECTORSIZE_LOG,
+ .maxval = XFS_MAX_SECTORSIZE_LOG,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = S_SIZE,
+ .conflicts = { S_LOG,
+ S_SECTLOG,
+ LAST_CONFLICT },
+ .convert = true,
+ .is_power_2 = true,
+ .minval = XFS_MIN_SECTORSIZE,
+ .maxval = XFS_MAX_SECTORSIZE,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
+ { .index = S_SECTSIZE,
+ .conflicts = { S_LOG,
+ S_SECTLOG,
+ LAST_CONFLICT },
+ .convert = true,
+ .is_power_2 = true,
+ .minval = XFS_MIN_SECTORSIZE,
+ .maxval = XFS_MAX_SECTORSIZE,
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
},
},
-};
-
-struct opt_params mopts = {
- .name = 'm',
- .subopts = {
-#define M_CRC 0
- "crc",
-#define M_FINOBT 1
- "finobt",
-#define M_UUID 2
- "uuid",
- NULL
- },
- .subopt_params = {
- { .index = M_CRC,
- .conflicts = { LAST_CONFLICT },
- .minval = 0,
- .maxval = 1,
- .defaultval = 1,
- },
- { .index = M_FINOBT,
- .conflicts = { LAST_CONFLICT },
- .minval = 0,
- .maxval = 1,
- .defaultval = 1,
+#define OPT_M 7
+ {
+ .index = OPT_M,
+ .name = 'm',
+ .subopts = {
+ #define M_CRC 0
+ "crc",
+ #define M_FINOBT 1
+ "finobt",
+ #define M_UUID 2
+ "uuid",
+ NULL
},
- { .index = M_UUID,
- .conflicts = { LAST_CONFLICT },
- .defaultval = SUBOPT_NEEDS_VAL,
+ .subopt_params = {
+ { .index = M_CRC,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 0,
+ .maxval = 1,
+ .defaultval = 1,
+ },
+ { .index = M_FINOBT,
+ .conflicts = { LAST_CONFLICT },
+ .minval = 0,
+ .maxval = 1,
+ .defaultval = 1,
+ },
+ { .index = M_UUID,
+ .conflicts = { LAST_CONFLICT },
+ .defaultval = SUBOPT_NEEDS_VAL,
+ },
},
},
};
@@ -1519,18 +1533,19 @@ main(
case 'b':
p = optarg;
while (*p != '\0') {
- char **subopts = (char **)bopts.subopts;
+ char **subopts = (char **)opts[OPT_B].subopts;
char *value;
switch (getsubopt(&p, (constpp)subopts,
&value)) {
case B_LOG:
- blocklog = getnum(value, &bopts, B_LOG);
+ blocklog = getnum(value, &opts[OPT_B],
+ B_LOG);
blocksize = 1 << blocklog;
blflag = 1;
break;
case B_SIZE:
- blocksize = getnum(value, &bopts,
+ blocksize = getnum(value, &opts[OPT_B],
B_SIZE);
blocklog = libxfs_highbit32(blocksize);
bsflag = 1;
@@ -1543,74 +1558,79 @@ main(
case 'd':
p = optarg;
while (*p != '\0') {
- char **subopts = (char **)dopts.subopts;
+ char **subopts = (char **)opts[OPT_D].subopts;
char *value;
switch (getsubopt(&p, (constpp)subopts,
&value)) {
case D_AGCOUNT:
- agcount = getnum(value, &dopts,
+ agcount = getnum(value, &opts[OPT_D],
D_AGCOUNT);
daflag = 1;
break;
case D_AGSIZE:
- agsize = getnum(value, &dopts, D_AGSIZE);
+ agsize = getnum(value, &opts[OPT_D],
+ D_AGSIZE);
dasize = 1;
break;
case D_FILE:
- xi.disfile = getnum(value, &dopts,
+ xi.disfile = getnum(value, &opts[OPT_D],
D_FILE);
break;
case D_NAME:
- xi.dname = getstr(value, &dopts, D_NAME);
+ xi.dname = getstr(value, &opts[OPT_D],
+ D_NAME);
break;
case D_SIZE:
- dbytes = getnum(value, &dopts, D_SIZE);
+ dbytes = getnum(value, &opts[OPT_D],
+ D_SIZE);
break;
case D_SUNIT:
- dsunit = getnum(value, &dopts, D_SUNIT);
+ dsunit = getnum(value, &opts[OPT_D],
+ D_SUNIT);
break;
case D_SWIDTH:
- dswidth = getnum(value, &dopts,
+ dswidth = getnum(value, &opts[OPT_D],
D_SWIDTH);
break;
case D_SU:
- dsu = getnum(value, &dopts, D_SU);
+ dsu = getnum(value, &opts[OPT_D], D_SU);
break;
case D_SW:
- dsw = getnum(value, &dopts, D_SW);
+ dsw = getnum(value, &opts[OPT_D], D_SW);
break;
case D_NOALIGN:
- nodsflag = getnum(value, &dopts,
+ nodsflag = getnum(value, &opts[OPT_D],
D_NOALIGN);
break;
case D_SECTLOG:
- sectorlog = getnum(value, &dopts,
+ sectorlog = getnum(value, &opts[OPT_D],
D_SECTLOG);
sectorsize = 1 << sectorlog;
slflag = 1;
break;
case D_SECTSIZE:
- sectorsize = getnum(value, &dopts,
+ sectorsize = getnum(value, &opts[OPT_D],
D_SECTSIZE);
sectorlog =
libxfs_highbit32(sectorsize);
ssflag = 1;
break;
case D_RTINHERIT:
- c = getnum(value, &dopts, D_RTINHERIT);
+ c = getnum(value, &opts[OPT_D],
+ D_RTINHERIT);
if (c)
fsx.fsx_xflags |=
XFS_DIFLAG_RTINHERIT;
break;
case D_PROJINHERIT:
- fsx.fsx_projid = getnum(value, &dopts,
+ fsx.fsx_projid = getnum(value, &opts[OPT_D],
D_PROJINHERIT);
fsx.fsx_xflags |=
XFS_DIFLAG_PROJINHERIT;
break;
case D_EXTSZINHERIT:
- fsx.fsx_extsize = getnum(value, &dopts,
+ fsx.fsx_extsize = getnum(value, &opts[OPT_D],
D_EXTSZINHERIT);
fsx.fsx_xflags |=
XFS_DIFLAG_EXTSZINHERIT;
@@ -1623,47 +1643,52 @@ main(
case 'i':
p = optarg;
while (*p != '\0') {
- char **subopts = (char **)iopts.subopts;
+ char **subopts = (char **)opts[OPT_I].subopts;
char *value;
switch (getsubopt(&p, (constpp)subopts,
&value)) {
case I_ALIGN:
sb_feat.inode_align = getnum(value,
- &iopts, I_ALIGN);
+ &opts[OPT_I],
+ I_ALIGN);
break;
case I_LOG:
- inodelog = getnum(value, &iopts, I_LOG);
+ inodelog = getnum(value, &opts[OPT_I],
+ I_LOG);
isize = 1 << inodelog;
ilflag = 1;
break;
case I_MAXPCT:
- imaxpct = getnum(value, &iopts,
+ imaxpct = getnum(value, &opts[OPT_I],
I_MAXPCT);
imflag = 1;
break;
case I_PERBLOCK:
- inopblock = getnum(value, &iopts,
+ inopblock = getnum(value, &opts[OPT_I],
I_PERBLOCK);
ipflag = 1;
break;
case I_SIZE:
- isize = getnum(value, &iopts, I_SIZE);
+ isize = getnum(value, &opts[OPT_I],
+ I_SIZE);
inodelog = libxfs_highbit32(isize);
isflag = 1;
break;
case I_ATTR:
sb_feat.attr_version =
- getnum(value, &iopts, I_ATTR);
+ getnum(value, &opts[OPT_I],
+ I_ATTR);
break;
case I_PROJID32BIT:
sb_feat.projid16bit =
- !getnum(value, &iopts,
+ !getnum(value, &opts[OPT_I],
I_PROJID32BIT);
break;
case I_SPINODES:
sb_feat.spinodes = getnum(value,
- &iopts, I_SPINODES);
+ &opts[OPT_I],
+ I_SPINODES);
break;
default:
unknown('i', value);
@@ -1673,55 +1698,60 @@ main(
case 'l':
p = optarg;
while (*p != '\0') {
- char **subopts = (char **)lopts.subopts;
+ char **subopts = (char **)opts[OPT_L].subopts;
char *value;
switch (getsubopt(&p, (constpp)subopts,
&value)) {
case L_AGNUM:
- logagno = getnum(value, &lopts, L_AGNUM);
+ logagno = getnum(value, &opts[OPT_L],
+ L_AGNUM);
laflag = 1;
break;
case L_FILE:
- xi.lisfile = getnum(value, &lopts,
+ xi.lisfile = getnum(value, &opts[OPT_L],
L_FILE);
break;
case L_INTERNAL:
- loginternal = getnum(value, &lopts,
+ loginternal = getnum(value, &opts[OPT_L],
L_INTERNAL);
liflag = 1;
break;
case L_SU:
- lsu = getnum(value, &lopts, L_SU);
+ lsu = getnum(value, &opts[OPT_L], L_SU);
lsuflag = 1;
break;
case L_SUNIT:
- lsunit = getnum(value, &lopts, L_SUNIT);
+ lsunit = getnum(value, &opts[OPT_L],
+ L_SUNIT);
lsunitflag = 1;
break;
case L_NAME:
case L_DEV:
- logfile = getstr(value, &lopts, L_NAME);
+ logfile = getstr(value, &opts[OPT_L],
+ L_NAME);
xi.logname = logfile;
ldflag = 1;
loginternal = 0;
break;
case L_VERSION:
sb_feat.log_version =
- getnum(value, &lopts, L_VERSION);
+ getnum(value, &opts[OPT_L],
+ L_VERSION);
lvflag = 1;
break;
case L_SIZE:
- logbytes = getnum(value, &lopts, L_SIZE);
+ logbytes = getnum(value, &opts[OPT_L],
+ L_SIZE);
break;
case L_SECTLOG:
- lsectorlog = getnum(value, &lopts,
+ lsectorlog = getnum(value, &opts[OPT_L],
L_SECTLOG);
lsectorsize = 1 << lsectorlog;
lslflag = 1;
break;
case L_SECTSIZE:
- lsectorsize = getnum(value, &lopts,
+ lsectorsize = getnum(value, &opts[OPT_L],
L_SECTSIZE);
lsectorlog =
libxfs_highbit32(lsectorsize);
@@ -1729,7 +1759,7 @@ main(
break;
case L_LAZYSBCNTR:
sb_feat.lazy_sb_counters =
- getnum(value, &lopts,
+ getnum(value, &opts[OPT_L],
L_LAZYSBCNTR);
break;
default:
@@ -1745,20 +1775,21 @@ main(
case 'm':
p = optarg;
while (*p != '\0') {
- char **subopts = (char **)mopts.subopts;
+ char **subopts = (char **)opts[OPT_M].subopts;
char *value;
switch (getsubopt(&p, (constpp)subopts,
&value)) {
case M_CRC:
sb_feat.crcs_enabled =
- getnum(value, &mopts, M_CRC);
+ getnum(value, &opts[OPT_M],
+ M_CRC);
if (sb_feat.crcs_enabled)
sb_feat.dirftype = true;
break;
case M_FINOBT:
sb_feat.finobt = getnum(
- value, &mopts, M_FINOBT);
+ value, &opts[OPT_M], M_FINOBT);
break;
case M_UUID:
if (!value || *value == '\0')
@@ -1774,38 +1805,39 @@ main(
case 'n':
p = optarg;
while (*p != '\0') {
- char **subopts = (char **)nopts.subopts;
+ char **subopts = (char **)opts[OPT_N].subopts;
char *value;
switch (getsubopt(&p, (constpp)subopts,
&value)) {
case N_LOG:
- dirblocklog = getnum(value, &nopts,
+ dirblocklog = getnum(value, &opts[OPT_N],
N_LOG);
dirblocksize = 1 << dirblocklog;
nlflag = 1;
break;
case N_SIZE:
- dirblocksize = getnum(value, &nopts,
+ dirblocksize = getnum(value, &opts[OPT_N],
N_SIZE);
dirblocklog =
libxfs_highbit32(dirblocksize);
nsflag = 1;
break;
case N_VERSION:
- value = getstr(value, &nopts, N_VERSION);
+ value = getstr(value, &opts[OPT_N],
+ N_VERSION);
if (!strcasecmp(value, "ci")) {
/* ASCII CI mode */
sb_feat.nci = true;
} else {
sb_feat.dir_version =
- getnum(value, &nopts,
+ getnum(value, &opts[OPT_N],
N_VERSION);
}
nvflag = 1;
break;
case N_FTYPE:
- sb_feat.dirftype = getnum(value, &nopts,
+ sb_feat.dirftype = getnum(value, &opts[OPT_N],
N_FTYPE);
break;
default:
@@ -1830,28 +1862,30 @@ main(
case 'r':
p = optarg;
while (*p != '\0') {
- char **subopts = (char **)ropts.subopts;
+ char **subopts = (char **)opts[OPT_R].subopts;
char *value;
switch (getsubopt(&p, (constpp)subopts,
&value)) {
case R_EXTSIZE:
- rtextbytes = getnum(value, &ropts, R_EXTSIZE);
+ rtextbytes = getnum(value, &opts[OPT_R],
+ R_EXTSIZE);
break;
case R_FILE:
- xi.risfile = getnum(value, &ropts,
+ xi.risfile = getnum(value, &opts[OPT_R],
R_FILE);
break;
case R_NAME:
case R_DEV:
- xi.rtname = getstr(value, &ropts,
+ xi.rtname = getstr(value, &opts[OPT_R],
R_NAME);
break;
case R_SIZE:
- rtbytes = getnum(value, &ropts, R_SIZE);
+ rtbytes = getnum(value, &opts[OPT_R],
+ R_SIZE);
break;
case R_NOALIGN:
- norsflag = getnum(value, &ropts,
+ norsflag = getnum(value, &opts[OPT_R],
R_NOALIGN);
break;
default:
@@ -1862,7 +1896,7 @@ main(
case 's':
p = optarg;
while (*p != '\0') {
- char **subopts = (char **)sopts.subopts;
+ char **subopts = (char **)opts[OPT_S].subopts;
char *value;
switch (getsubopt(&p, (constpp)subopts,
@@ -1872,7 +1906,7 @@ main(
if (lssflag)
conflict('s', subopts,
S_SECTSIZE, S_SECTLOG);
- sectorlog = getnum(value, &sopts,
+ sectorlog = getnum(value, &opts[OPT_S],
S_SECTLOG);
lsectorlog = sectorlog;
sectorsize = 1 << sectorlog;
@@ -1884,7 +1918,7 @@ main(
if (lslflag)
conflict('s', subopts, S_SECTLOG,
S_SECTSIZE);
- sectorsize = getnum(value, &sopts,
+ sectorsize = getnum(value, &opts[OPT_S],
S_SECTSIZE);
lsectorsize = sectorsize;
sectorlog =
@@ -1908,7 +1942,7 @@ main(
fprintf(stderr, _("extra arguments\n"));
usage();
} else if (argc - optind == 1) {
- dfile = xi.volname = getstr(argv[optind], &dopts, D_NAME);
+ dfile = xi.volname = getstr(argv[optind], &opts[OPT_D], D_NAME);
} else
dfile = xi.dname;
@@ -2087,7 +2121,7 @@ _("32 bit Project IDs always enabled on CRC enabled filesytems\n"));
* then issue an error.
* The same is also for sparse inodes.
*/
- if (sb_feat.finobt && mopts.subopt_params[M_FINOBT].seen) {
+ if (sb_feat.finobt && opts[OPT_M].subopt_params[M_FINOBT].seen) {
fprintf(stderr,
_("finobt not supported without CRC support\n"));
usage();
--
2.5.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/8] mkfs: extend opt_params with a value field
2016-08-02 15:42 [RFC PATCH 0/8] mkfs: centralised conflict detection Jan Tulak
2016-08-02 15:42 ` [PATCH 1/8] mkfs: remove intermediate getstr followed by getnum Jan Tulak
2016-08-02 15:42 ` [PATCH 2/8] mkfs: merge tables for opts parsing into one table Jan Tulak
@ 2016-08-02 15:42 ` Jan Tulak
2016-08-02 15:42 ` [PATCH 4/8] mkfs: change conflicts array into a table capable of cross-option addressing Jan Tulak
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jan Tulak @ 2016-08-02 15:42 UTC (permalink / raw)
To: xfs; +Cc: Jan Tulak
Add a new field into opt_params: value, which is filled with user input.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
mkfs/xfs_mkfs.c | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 130 insertions(+)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 4741522..14cf7dd 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -115,6 +115,12 @@ unsigned int sectorsize;
* sets what is used with simple specifying the subopt (-d file).
* A special SUBOPT_NEEDS_VAL can be used to require a user-given
* value in any case.
+ *
+ * value INTERNAL
+ * Do not set this on initialization. Use defaultval for what you want
+ * to do. This is filled with user input and anything you write here now
+ * is overwritten. (If the user input is a string and not a number, this
+ * value is set to a positive non-zero number.)
*/
struct opt_params {
int index;
@@ -131,6 +137,7 @@ struct opt_params {
long long minval;
long long maxval;
long long defaultval;
+ long long value;
} subopt_params[MAX_SUBOPTS];
} opts[MAX_OPTS] = {
#define OPT_B 0
@@ -1543,12 +1550,20 @@ main(
B_LOG);
blocksize = 1 << blocklog;
blflag = 1;
+ opts[OPT_B].subopt_params[B_LOG].value =
+ blocklog;
+ opts[OPT_B].subopt_params[B_SIZE].value =
+ blocksize;
break;
case B_SIZE:
blocksize = getnum(value, &opts[OPT_B],
B_SIZE);
blocklog = libxfs_highbit32(blocksize);
bsflag = 1;
+ opts[OPT_B].subopt_params[B_LOG].value =
+ blocklog;
+ opts[OPT_B].subopt_params[B_SIZE].value =
+ blocksize;
break;
default:
unknown('b', value);
@@ -1567,47 +1582,70 @@ main(
agcount = getnum(value, &opts[OPT_D],
D_AGCOUNT);
daflag = 1;
+ opts[OPT_D].subopt_params[D_AGCOUNT].value =
+ agcount;
break;
case D_AGSIZE:
agsize = getnum(value, &opts[OPT_D],
D_AGSIZE);
dasize = 1;
+ opts[OPT_D].subopt_params[D_AGSIZE].value =
+ agsize;
break;
case D_FILE:
xi.disfile = getnum(value, &opts[OPT_D],
D_FILE);
+ opts[OPT_D].subopt_params[D_FILE].value =
+ xi.disfile;
break;
case D_NAME:
xi.dname = getstr(value, &opts[OPT_D],
D_NAME);
+ opts[OPT_D].subopt_params[D_NAME].value = 1;
break;
case D_SIZE:
dbytes = getnum(value, &opts[OPT_D],
D_SIZE);
+ opts[OPT_D].subopt_params[D_SIZE].value =
+ dbytes;
break;
case D_SUNIT:
dsunit = getnum(value, &opts[OPT_D],
D_SUNIT);
+ opts[OPT_D].subopt_params[D_SUNIT].value =
+ dsunit;
break;
case D_SWIDTH:
dswidth = getnum(value, &opts[OPT_D],
D_SWIDTH);
+ opts[OPT_D].subopt_params[D_SWIDTH].value =
+ dswidth;
break;
case D_SU:
dsu = getnum(value, &opts[OPT_D], D_SU);
+ opts[OPT_D].subopt_params[D_SU].value =
+ dsu;
break;
case D_SW:
dsw = getnum(value, &opts[OPT_D], D_SW);
+ opts[OPT_D].subopt_params[D_SW].value =
+ dsw;
break;
case D_NOALIGN:
nodsflag = getnum(value, &opts[OPT_D],
D_NOALIGN);
+ opts[OPT_D].subopt_params[D_NOALIGN].value =
+ nodsflag;
break;
case D_SECTLOG:
sectorlog = getnum(value, &opts[OPT_D],
D_SECTLOG);
sectorsize = 1 << sectorlog;
slflag = 1;
+ opts[OPT_D].subopt_params[D_SECTSIZE].value =
+ sectorsize;
+ opts[OPT_D].subopt_params[D_SECTLOG].value =
+ sectorlog;
break;
case D_SECTSIZE:
sectorsize = getnum(value, &opts[OPT_D],
@@ -1615,6 +1653,10 @@ main(
sectorlog =
libxfs_highbit32(sectorsize);
ssflag = 1;
+ opts[OPT_D].subopt_params[D_SECTSIZE].value =
+ sectorsize;
+ opts[OPT_D].subopt_params[D_SECTLOG].value =
+ sectorlog;
break;
case D_RTINHERIT:
c = getnum(value, &opts[OPT_D],
@@ -1622,18 +1664,24 @@ main(
if (c)
fsx.fsx_xflags |=
XFS_DIFLAG_RTINHERIT;
+ opts[OPT_D].subopt_params[D_RTINHERIT].value =
+ c;
break;
case D_PROJINHERIT:
fsx.fsx_projid = getnum(value, &opts[OPT_D],
D_PROJINHERIT);
fsx.fsx_xflags |=
XFS_DIFLAG_PROJINHERIT;
+ opts[OPT_D].subopt_params[D_PROJINHERIT].value =
+ fsx.fsx_projid;
break;
case D_EXTSZINHERIT:
fsx.fsx_extsize = getnum(value, &opts[OPT_D],
D_EXTSZINHERIT);
fsx.fsx_xflags |=
XFS_DIFLAG_EXTSZINHERIT;
+ opts[OPT_D].subopt_params[D_EXTSZINHERIT].value =
+ fsx.fsx_extsize;
break;
default:
unknown('d', value);
@@ -1652,43 +1700,64 @@ main(
sb_feat.inode_align = getnum(value,
&opts[OPT_I],
I_ALIGN);
+ opts[OPT_I].subopt_params[I_ALIGN].value =
+ sb_feat.inode_align;
break;
case I_LOG:
inodelog = getnum(value, &opts[OPT_I],
I_LOG);
isize = 1 << inodelog;
ilflag = 1;
+ opts[OPT_I].subopt_params[I_SIZE].value =
+ isize;
+ opts[OPT_I].subopt_params[I_LOG].value =
+ inodelog;
break;
case I_MAXPCT:
imaxpct = getnum(value, &opts[OPT_I],
I_MAXPCT);
imflag = 1;
+ opts[OPT_I].subopt_params[I_MAXPCT].value =
+ imaxpct;
break;
case I_PERBLOCK:
inopblock = getnum(value, &opts[OPT_I],
I_PERBLOCK);
ipflag = 1;
+ opts[OPT_I].subopt_params[I_PERBLOCK].value =
+ inopblock;
break;
case I_SIZE:
isize = getnum(value, &opts[OPT_I],
I_SIZE);
inodelog = libxfs_highbit32(isize);
isflag = 1;
+ opts[OPT_I].subopt_params[I_SIZE].value =
+ isize;
+ opts[OPT_I].subopt_params[I_LOG].value =
+ inodelog;
break;
case I_ATTR:
sb_feat.attr_version =
+
getnum(value, &opts[OPT_I],
I_ATTR);
+ opts[OPT_I].subopt_params[I_ATTR].value =
+ sb_feat.attr_version;
break;
case I_PROJID32BIT:
sb_feat.projid16bit =
!getnum(value, &opts[OPT_I],
I_PROJID32BIT);
+ opts[OPT_I].subopt_params[I_PROJID32BIT].value =
+ sb_feat.projid16bit;
break;
case I_SPINODES:
sb_feat.spinodes = getnum(value,
&opts[OPT_I],
I_SPINODES);
+ opts[OPT_I].subopt_params[I_SPINODES].value =
+ sb_feat.spinodes;
break;
default:
unknown('i', value);
@@ -1707,24 +1776,34 @@ main(
logagno = getnum(value, &opts[OPT_L],
L_AGNUM);
laflag = 1;
+ opts[OPT_L].subopt_params[L_AGNUM].value =
+ logagno;
break;
case L_FILE:
xi.lisfile = getnum(value, &opts[OPT_L],
L_FILE);
+ opts[OPT_L].subopt_params[L_FILE].value =
+ xi.lisfile;
break;
case L_INTERNAL:
loginternal = getnum(value, &opts[OPT_L],
L_INTERNAL);
liflag = 1;
+ opts[OPT_L].subopt_params[L_INTERNAL].value =
+ loginternal;
break;
case L_SU:
lsu = getnum(value, &opts[OPT_L], L_SU);
lsuflag = 1;
+ opts[OPT_L].subopt_params[L_SU].value =
+ lsu;
break;
case L_SUNIT:
lsunit = getnum(value, &opts[OPT_L],
L_SUNIT);
lsunitflag = 1;
+ opts[OPT_L].subopt_params[L_SUNIT].value =
+ lsunit;
break;
case L_NAME:
case L_DEV:
@@ -1733,22 +1812,32 @@ main(
xi.logname = logfile;
ldflag = 1;
loginternal = 0;
+ opts[OPT_L].subopt_params[L_NAME].value = 1;
+ opts[OPT_L].subopt_params[L_DEV].value = 1;
break;
case L_VERSION:
sb_feat.log_version =
getnum(value, &opts[OPT_L],
L_VERSION);
lvflag = 1;
+ opts[OPT_L].subopt_params[L_VERSION].value =
+ sb_feat.log_version;
break;
case L_SIZE:
logbytes = getnum(value, &opts[OPT_L],
L_SIZE);
+ opts[OPT_L].subopt_params[L_SIZE].value =
+ logbytes;
break;
case L_SECTLOG:
lsectorlog = getnum(value, &opts[OPT_L],
L_SECTLOG);
lsectorsize = 1 << lsectorlog;
lslflag = 1;
+ opts[OPT_L].subopt_params[L_SECTSIZE].value =
+ lsectorsize;
+ opts[OPT_L].subopt_params[L_SECTLOG].value =
+ lsectorlog;
break;
case L_SECTSIZE:
lsectorsize = getnum(value, &opts[OPT_L],
@@ -1756,11 +1845,17 @@ main(
lsectorlog =
libxfs_highbit32(lsectorsize);
lssflag = 1;
+ opts[OPT_L].subopt_params[L_SECTSIZE].value =
+ lsectorsize;
+ opts[OPT_L].subopt_params[L_SECTLOG].value =
+ lsectorlog;
break;
case L_LAZYSBCNTR:
sb_feat.lazy_sb_counters =
getnum(value, &opts[OPT_L],
L_LAZYSBCNTR);
+ opts[OPT_L].subopt_params[L_LAZYSBCNTR].value =
+ sb_feat.lazy_sb_counters;
break;
default:
unknown('l', value);
@@ -1786,10 +1881,14 @@ main(
M_CRC);
if (sb_feat.crcs_enabled)
sb_feat.dirftype = true;
+ opts[OPT_M].subopt_params[M_CRC].value =
+ sb_feat.crcs_enabled;
break;
case M_FINOBT:
sb_feat.finobt = getnum(
value, &opts[OPT_M], M_FINOBT);
+ opts[OPT_M].subopt_params[M_FINOBT].value =
+ sb_feat.finobt;
break;
case M_UUID:
if (!value || *value == '\0')
@@ -1797,6 +1896,7 @@ main(
if (platform_uuid_parse(value, &uuid))
illegal(optarg, "m uuid");
break;
+ opts[OPT_M].subopt_params[M_UUID].value = 1;
default:
unknown('m', value);
}
@@ -1815,6 +1915,10 @@ main(
N_LOG);
dirblocksize = 1 << dirblocklog;
nlflag = 1;
+ opts[OPT_N].subopt_params[N_SIZE].value =
+ dirblocksize;
+ opts[OPT_N].subopt_params[N_LOG].value =
+ dirblocklog;
break;
case N_SIZE:
dirblocksize = getnum(value, &opts[OPT_N],
@@ -1822,6 +1926,10 @@ main(
dirblocklog =
libxfs_highbit32(dirblocksize);
nsflag = 1;
+ opts[OPT_N].subopt_params[N_SIZE].value =
+ dirblocksize;
+ opts[OPT_N].subopt_params[N_LOG].value =
+ dirblocklog;
break;
case N_VERSION:
value = getstr(value, &opts[OPT_N],
@@ -1835,10 +1943,14 @@ main(
N_VERSION);
}
nvflag = 1;
+ opts[OPT_N].subopt_params[N_VERSION].value =
+ sb_feat.dir_version;
break;
case N_FTYPE:
sb_feat.dirftype = getnum(value, &opts[OPT_N],
N_FTYPE);
+ opts[OPT_N].subopt_params[N_FTYPE].value =
+ sb_feat.dirftype;
break;
default:
unknown('n', value);
@@ -1870,23 +1982,33 @@ main(
case R_EXTSIZE:
rtextbytes = getnum(value, &opts[OPT_R],
R_EXTSIZE);
+ opts[OPT_R].subopt_params[R_EXTSIZE].value =
+ rtextbytes;
break;
case R_FILE:
xi.risfile = getnum(value, &opts[OPT_R],
R_FILE);
+ opts[OPT_R].subopt_params[R_FILE].value =
+ xi.risfile;
break;
case R_NAME:
case R_DEV:
xi.rtname = getstr(value, &opts[OPT_R],
R_NAME);
+ opts[OPT_R].subopt_params[R_NAME].value = 1;
+ opts[OPT_R].subopt_params[R_DEV].value = 1;
break;
case R_SIZE:
rtbytes = getnum(value, &opts[OPT_R],
R_SIZE);
+ opts[OPT_R].subopt_params[R_SIZE].value =
+ rtbytes;
break;
case R_NOALIGN:
norsflag = getnum(value, &opts[OPT_R],
R_NOALIGN);
+ opts[OPT_R].subopt_params[R_NOALIGN].value =
+ norsflag;
break;
default:
unknown('r', value);
@@ -1912,6 +2034,10 @@ main(
sectorsize = 1 << sectorlog;
lsectorsize = sectorsize;
lslflag = slflag = 1;
+ opts[OPT_S].subopt_params[S_LOG].value =
+ sectorsize;
+ opts[OPT_S].subopt_params[S_SECTLOG].value =
+ sectorsize;
break;
case S_SIZE:
case S_SECTSIZE:
@@ -1925,6 +2051,10 @@ main(
libxfs_highbit32(sectorsize);
lsectorlog = sectorlog;
lssflag = ssflag = 1;
+ opts[OPT_S].subopt_params[S_SIZE].value =
+ sectorlog;
+ opts[OPT_S].subopt_params[S_SECTSIZE].value =
+ sectorlog;
break;
default:
unknown('s', value);
--
2.5.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/8] mkfs: change conflicts array into a table capable of cross-option addressing
2016-08-02 15:42 [RFC PATCH 0/8] mkfs: centralised conflict detection Jan Tulak
` (2 preceding siblings ...)
2016-08-02 15:42 ` [PATCH 3/8] mkfs: extend opt_params with a value field Jan Tulak
@ 2016-08-02 15:42 ` Jan Tulak
2016-08-02 15:42 ` [PATCH 5/8] mkfs: add a check for conflicting values Jan Tulak
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jan Tulak @ 2016-08-02 15:42 UTC (permalink / raw)
To: xfs; +Cc: Jan Tulak
Change subopt_param.conflicts from array of integers into array of structures.
This prepares the ground for more universal conflict detection in future
patches.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
mkfs/xfs_mkfs.c | 239 ++++++++++++++++++++++++++++++--------------------------
1 file changed, 127 insertions(+), 112 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 14cf7dd..b2fbc58 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -93,8 +93,16 @@ unsigned int sectorsize;
*
* conflicts MANDATORY
* If your subopt is in a conflict with some other option, specify it.
- * Accepts the .index values of the conflicting subopts and the last
- * member of this list has to be LAST_CONFLICT.
+ * Accepts the .index values of the conflicting subopt as .opt (e.g. OPT_D)
+ * and .subopt (e.g. D_FILE). If .test_values is true, then the conflict
+ * is raised only when the "remote" suboption .value is equal to
+ * .invalid_value field and the "current" suboption has .value equal to
+ * .at_value.
+ * If .test_values is false, a conflict is raised when the suboption appears
+ * on the CLI, no matter its value. The field .message contains an optional
+ * explanatory string for the user. This string can't be translated here,
+ * so it has to be enveloped with _() when printed.
+ * The last member of this list has to be {LAST_CONFLICT}.
*
* minval, maxval OPTIONAL
* These options are used for automatic range check and they have to be
@@ -133,7 +141,14 @@ struct opt_params {
bool str_seen;
bool convert;
bool is_power_2;
- int conflicts[MAX_CONFLICTS];
+ struct subopt_conflict {
+ int opt;
+ int subopt;
+ bool test_values;
+ long long invalid_value;
+ long long at_value;
+ const char *message;
+ } conflicts [MAX_CONFLICTS];
long long minval;
long long maxval;
long long defaultval;
@@ -153,8 +168,8 @@ struct opt_params {
},
.subopt_params = {
{ .index = B_LOG,
- .conflicts = { B_SIZE,
- LAST_CONFLICT },
+ .conflicts = { {OPT_B, B_SIZE, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = XFS_MIN_BLOCKSIZE_LOG,
.maxval = XFS_MAX_BLOCKSIZE_LOG,
.defaultval = SUBOPT_NEEDS_VAL,
@@ -162,8 +177,8 @@ struct opt_params {
{ .index = B_SIZE,
.convert = true,
.is_power_2 = true,
- .conflicts = { B_LOG,
- LAST_CONFLICT },
+ .conflicts = { {OPT_B, B_LOG, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = XFS_MIN_BLOCKSIZE,
.maxval = XFS_MAX_BLOCKSIZE,
.defaultval = SUBOPT_NEEDS_VAL,
@@ -209,84 +224,84 @@ struct opt_params {
},
.subopt_params = {
{ .index = D_AGCOUNT,
- .conflicts = { D_AGSIZE,
- LAST_CONFLICT },
+ .conflicts = { {OPT_D, D_AGSIZE, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = 1,
.maxval = XFS_MAX_AGNUMBER,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = D_FILE,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
},
{ .index = D_NAME,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = D_SIZE,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.convert = true,
.minval = XFS_AG_MIN_BYTES,
.maxval = LLONG_MAX,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = D_SUNIT,
- .conflicts = { D_NOALIGN,
- D_SU,
- D_SW,
- LAST_CONFLICT },
+ .conflicts = { {OPT_D, D_NOALIGN, false, 0, 0},
+ {OPT_D, D_SU, false, 0, 0},
+ {OPT_D, D_SW, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = 0,
.maxval = UINT_MAX,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = D_SWIDTH,
- .conflicts = { D_NOALIGN,
- D_SU,
- D_SW,
- LAST_CONFLICT },
+ .conflicts = { {OPT_D, D_NOALIGN, false, 0, 0},
+ {OPT_D, D_SU, false, 0, 0},
+ {OPT_D, D_SW, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = 0,
.maxval = UINT_MAX,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = D_AGSIZE,
- .conflicts = { D_AGCOUNT,
- LAST_CONFLICT },
+ .conflicts = { {OPT_D, D_AGCOUNT, false, 0, 0},
+ {LAST_CONFLICT} },
.convert = true,
.minval = XFS_AG_MIN_BYTES,
.maxval = XFS_AG_MAX_BYTES,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = D_SU,
- .conflicts = { D_NOALIGN,
- D_SUNIT,
- D_SWIDTH,
- LAST_CONFLICT },
+ .conflicts = { {OPT_D, D_NOALIGN, false, 0, 0},
+ {OPT_D, D_SUNIT, false, 0, 0},
+ {OPT_D, D_SWIDTH, false, 0, 0},
+ {LAST_CONFLICT} },
.convert = true,
.minval = 0,
.maxval = UINT_MAX,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = D_SW,
- .conflicts = { D_NOALIGN,
- D_SUNIT,
- D_SWIDTH,
- LAST_CONFLICT },
+ .conflicts = { {OPT_D, D_NOALIGN, false, 0, 0},
+ {OPT_D, D_SUNIT, false, 0, 0},
+ {OPT_D, D_SWIDTH, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = 0,
.maxval = UINT_MAX,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = D_SECTLOG,
- .conflicts = { D_SECTSIZE,
- LAST_CONFLICT },
+ .conflicts = { {OPT_D, D_SECTSIZE, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = XFS_MIN_SECTORSIZE_LOG,
.maxval = XFS_MAX_SECTORSIZE_LOG,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = D_SECTSIZE,
- .conflicts = { D_SECTLOG,
- LAST_CONFLICT },
+ .conflicts = { {OPT_D, D_SECTLOG, false, 0, 0},
+ {LAST_CONFLICT} },
.convert = true,
.is_power_2 = true,
.minval = XFS_MIN_SECTORSIZE,
@@ -294,29 +309,29 @@ struct opt_params {
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = D_NOALIGN,
- .conflicts = { D_SU,
- D_SW,
- D_SUNIT,
- D_SWIDTH,
- LAST_CONFLICT },
+ .conflicts = { {OPT_D, D_SU, false, 0, 0},
+ {OPT_D, D_SW, false, 0, 0},
+ {OPT_D, D_SUNIT, false, 0, 0},
+ {OPT_D, D_SWIDTH, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
},
{ .index = D_RTINHERIT,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 1,
.maxval = 1,
.defaultval = 1,
},
{ .index = D_PROJINHERIT,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 0,
.maxval = UINT_MAX,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = D_EXTSZINHERIT,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 0,
.maxval = UINT_MAX,
.defaultval = SUBOPT_NEEDS_VAL,
@@ -348,57 +363,57 @@ struct opt_params {
},
.subopt_params = {
{ .index = I_ALIGN,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
},
{ .index = I_LOG,
- .conflicts = { I_PERBLOCK,
- I_SIZE,
- LAST_CONFLICT },
+ .conflicts = { {OPT_I, I_PERBLOCK, false, 0, 0},
+ {OPT_I, I_SIZE, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = XFS_DINODE_MIN_LOG,
.maxval = XFS_DINODE_MAX_LOG,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = I_MAXPCT,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 0,
.maxval = 100,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = I_PERBLOCK,
- .conflicts = { I_LOG,
- I_SIZE,
- LAST_CONFLICT },
+ .conflicts = { {OPT_I, I_LOG, false, 0, 0},
+ {OPT_I, I_SIZE, false, 0, 0},
+ {LAST_CONFLICT} },
.is_power_2 = true,
.minval = XFS_MIN_INODE_PERBLOCK,
.maxval = XFS_MAX_BLOCKSIZE / XFS_DINODE_MIN_SIZE,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = I_SIZE,
- .conflicts = { I_PERBLOCK,
- I_LOG,
- LAST_CONFLICT },
+ .conflicts = { {OPT_I, I_PERBLOCK, false, 0, 0},
+ {OPT_I, I_LOG, false, 0, 0},
+ {LAST_CONFLICT} },
.is_power_2 = true,
.minval = XFS_DINODE_MIN_SIZE,
.maxval = XFS_DINODE_MAX_SIZE,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = I_ATTR,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 0,
.maxval = 2,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = I_PROJID32BIT,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
},
{ .index = I_SPINODES,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
@@ -438,64 +453,64 @@ struct opt_params {
},
.subopt_params = {
{ .index = L_AGNUM,
- .conflicts = { L_DEV,
- LAST_CONFLICT },
+ .conflicts = { {OPT_L, L_DEV, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = 0,
.maxval = UINT_MAX,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = L_INTERNAL,
- .conflicts = { L_FILE,
- L_DEV,
- LAST_CONFLICT },
+ .conflicts = { {OPT_L, L_FILE, false, 0, 0},
+ {OPT_L, L_DEV, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
},
{ .index = L_SIZE,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.convert = true,
.minval = 2 * 1024 * 1024LL, /* XXX: XFS_MIN_LOG_BYTES */
.maxval = XFS_MAX_LOG_BYTES,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = L_VERSION,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 1,
.maxval = 2,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = L_SUNIT,
- .conflicts = { L_SU,
- LAST_CONFLICT },
+ .conflicts = { {OPT_L, L_SU, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = 1,
.maxval = BTOBB(XLOG_MAX_RECORD_BSIZE),
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = L_SU,
- .conflicts = { L_SUNIT,
- LAST_CONFLICT },
+ .conflicts = { {OPT_L, L_SUNIT, false, 0, 0},
+ {LAST_CONFLICT} },
.convert = true,
.minval = BBTOB(1),
.maxval = XLOG_MAX_RECORD_BSIZE,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = L_DEV,
- .conflicts = { L_AGNUM,
- L_INTERNAL,
- LAST_CONFLICT },
+ .conflicts = { {OPT_L, L_AGNUM, false, 0, 0},
+ {OPT_L, L_INTERNAL, false, 0, 0},
+ {LAST_CONFLICT} },
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = L_SECTLOG,
- .conflicts = { L_SECTSIZE,
- LAST_CONFLICT },
+ .conflicts = { {OPT_L, L_SECTSIZE, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = XFS_MIN_SECTORSIZE_LOG,
.maxval = XFS_MAX_SECTORSIZE_LOG,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = L_SECTSIZE,
- .conflicts = { L_SECTLOG,
- LAST_CONFLICT },
+ .conflicts = { {OPT_L, L_SECTLOG, false, 0, 0},
+ {LAST_CONFLICT} },
.convert = true,
.is_power_2 = true,
.minval = XFS_MIN_SECTORSIZE,
@@ -503,20 +518,20 @@ struct opt_params {
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = L_FILE,
- .conflicts = { L_INTERNAL,
- LAST_CONFLICT },
+ .conflicts = { {OPT_L, L_INTERNAL, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
},
{ .index = L_NAME,
- .conflicts = { L_AGNUM,
- L_INTERNAL,
- LAST_CONFLICT },
+ .conflicts = { {OPT_L, L_AGNUM, false, 0, 0},
+ {OPT_L, L_INTERNAL, false, 0, 0},
+ {LAST_CONFLICT} },
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = L_LAZYSBCNTR,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
@@ -540,15 +555,15 @@ struct opt_params {
},
.subopt_params = {
{ .index = N_LOG,
- .conflicts = { N_SIZE,
- LAST_CONFLICT },
+ .conflicts = { {OPT_N, N_SIZE, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = XFS_MIN_REC_DIRSIZE,
.maxval = XFS_MAX_BLOCKSIZE_LOG,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = N_SIZE,
- .conflicts = { N_LOG,
- LAST_CONFLICT },
+ .conflicts = { {OPT_N, N_LOG, false, 0, 0},
+ {LAST_CONFLICT} },
.convert = true,
.is_power_2 = true,
.minval = 1 << XFS_MIN_REC_DIRSIZE,
@@ -556,13 +571,13 @@ struct opt_params {
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = N_VERSION,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 2,
.maxval = 2,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = N_FTYPE,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
@@ -590,38 +605,38 @@ struct opt_params {
},
.subopt_params = {
{ .index = R_EXTSIZE,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.convert = true,
.minval = XFS_MIN_RTEXTSIZE,
.maxval = XFS_MAX_RTEXTSIZE,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = R_SIZE,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.convert = true,
.minval = 0,
.maxval = LLONG_MAX,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = R_DEV,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = R_FILE,
.minval = 0,
.maxval = 1,
.defaultval = 1,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
},
{ .index = R_NAME,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = R_NOALIGN,
.minval = 0,
.maxval = 1,
.defaultval = 1,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
},
},
},
@@ -642,25 +657,25 @@ struct opt_params {
},
.subopt_params = {
{ .index = S_LOG,
- .conflicts = { S_SIZE,
- S_SECTSIZE,
- LAST_CONFLICT },
+ .conflicts = { {OPT_S, S_SIZE, false, 0, 0},
+ {OPT_S, S_SECTSIZE, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = XFS_MIN_SECTORSIZE_LOG,
.maxval = XFS_MAX_SECTORSIZE_LOG,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = S_SECTLOG,
- .conflicts = { S_SIZE,
- S_SECTSIZE,
- LAST_CONFLICT },
+ .conflicts = { {OPT_S, S_SIZE, false, 0, 0},
+ {OPT_S, S_SECTSIZE, false, 0, 0},
+ {LAST_CONFLICT} },
.minval = XFS_MIN_SECTORSIZE_LOG,
.maxval = XFS_MAX_SECTORSIZE_LOG,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = S_SIZE,
- .conflicts = { S_LOG,
- S_SECTLOG,
- LAST_CONFLICT },
+ .conflicts = { {OPT_S, S_LOG, false, 0, 0},
+ {OPT_S, S_SECTLOG, false, 0, 0},
+ {LAST_CONFLICT} },
.convert = true,
.is_power_2 = true,
.minval = XFS_MIN_SECTORSIZE,
@@ -668,9 +683,9 @@ struct opt_params {
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = S_SECTSIZE,
- .conflicts = { S_LOG,
- S_SECTLOG,
- LAST_CONFLICT },
+ .conflicts = { {OPT_S, S_LOG, false, 0, 0},
+ {OPT_S, S_SECTLOG, false, 0, 0},
+ {LAST_CONFLICT} },
.convert = true,
.is_power_2 = true,
.minval = XFS_MIN_SECTORSIZE,
@@ -694,19 +709,19 @@ struct opt_params {
},
.subopt_params = {
{ .index = M_CRC,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
},
{ .index = M_FINOBT,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
},
{ .index = M_UUID,
- .conflicts = { LAST_CONFLICT },
+ .conflicts = { {LAST_CONFLICT} },
.defaultval = SUBOPT_NEEDS_VAL,
},
},
@@ -1308,14 +1323,14 @@ check_opt(
/* check for conflicts with the option */
for (i = 0; i < MAX_CONFLICTS; i++) {
- int conflict_opt = sp->conflicts[i];
+ struct subopt_conflict conflict_opt = sp->conflicts[i];
- if (conflict_opt == LAST_CONFLICT)
+ if (conflict_opt.opt == LAST_CONFLICT)
break;
- if (opts->subopt_params[conflict_opt].seen ||
- opts->subopt_params[conflict_opt].str_seen)
+ if (opts->subopt_params[conflict_opt.subopt].seen ||
+ opts->subopt_params[conflict_opt.subopt].str_seen)
conflict(opts->name, (char **)opts->subopts,
- conflict_opt, index);
+ conflict_opt.subopt, index);
}
}
--
2.5.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/8] mkfs: add a check for conflicting values
2016-08-02 15:42 [RFC PATCH 0/8] mkfs: centralised conflict detection Jan Tulak
` (3 preceding siblings ...)
2016-08-02 15:42 ` [PATCH 4/8] mkfs: change conflicts array into a table capable of cross-option addressing Jan Tulak
@ 2016-08-02 15:42 ` Jan Tulak
2016-08-02 15:42 ` [PATCH 6/8] mkfs: add cross-section conflict checks Jan Tulak
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Jan Tulak @ 2016-08-02 15:42 UTC (permalink / raw)
To: xfs; +Cc: Jan Tulak
Add a check that reports a conflict only when subopts are mixed with specific values.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
mkfs/xfs_mkfs.c | 52 ++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 44 insertions(+), 8 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index b2fbc58..6f3f278 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1289,18 +1289,18 @@ illegal_option(
*/
static void
check_opt(
- struct opt_params *opts,
+ struct opt_params *opt,
int index,
bool str_seen)
{
- struct subopt_param *sp = &opts->subopt_params[index];
+ struct subopt_param *sp = &opt->subopt_params[index];
int i;
if (sp->index != index) {
fprintf(stderr,
("Developer screwed up option parsing (%d/%d)! Please report!\n"),
sp->index, index);
- reqval(opts->name, (char **)opts->subopts, index);
+ reqval(opt->name, (char **)opt->subopts, index);
}
/*
@@ -1313,11 +1313,11 @@ check_opt(
*/
if (!str_seen) {
if (sp->seen)
- respec(opts->name, (char **)opts->subopts, index);
+ respec(opt->name, (char **)opt->subopts, index);
sp->seen = true;
} else {
if (sp->str_seen)
- respec(opts->name, (char **)opts->subopts, index);
+ respec(opt->name, (char **)opt->subopts, index);
sp->str_seen = true;
}
@@ -1327,10 +1327,44 @@ check_opt(
if (conflict_opt.opt == LAST_CONFLICT)
break;
- if (opts->subopt_params[conflict_opt.subopt].seen ||
- opts->subopt_params[conflict_opt.subopt].str_seen)
- conflict(opts->name, (char **)opts->subopts,
+ if (conflict_opt.test_values)
+ break;
+ if (opt->subopt_params[conflict_opt.subopt].seen ||
+ opt->subopt_params[conflict_opt.subopt].str_seen) {
+ conflict(opt->name, (char **)opt->subopts,
conflict_opt.subopt, index);
+ }
+ }
+}
+
+/*
+ * Check for conflict values between options.
+ */
+static void
+check_opt_value(
+ struct opt_params *opt,
+ int index,
+ long long value)
+{
+ struct subopt_param *sp = &opt->subopt_params[index];
+ int i;
+
+ /* check for conflicts with the option */
+ for (i = 0; i < MAX_CONFLICTS; i++) {
+ struct subopt_conflict conflict_opt = sp->conflicts[i];
+
+ if (conflict_opt.opt == LAST_CONFLICT)
+ break;
+ if (!conflict_opt.test_values)
+ break;
+ if ((opt->subopt_params[conflict_opt.subopt].seen ||
+ opt->subopt_params[conflict_opt.subopt].str_seen) &&
+ opt->subopt_params[conflict_opt.subopt].value
+ == conflict_opt.invalid_value &&
+ value == conflict_opt.at_value) {
+ conflict(opt->name, (char **)opt->subopts,
+ conflict_opt.subopt, index);
+ }
}
}
@@ -1377,6 +1411,8 @@ getnum(
illegal_option(str, opts, index, NULL);
}
+ check_opt_value(opts, index, c);
+
/* Validity check the result. */
if (c < sp->minval)
illegal_option(str, opts, index, _("value is too small"));
--
2.5.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 6/8] mkfs: add cross-section conflict checks
2016-08-02 15:42 [RFC PATCH 0/8] mkfs: centralised conflict detection Jan Tulak
` (4 preceding siblings ...)
2016-08-02 15:42 ` [PATCH 5/8] mkfs: add a check for conflicting values Jan Tulak
@ 2016-08-02 15:42 ` Jan Tulak
2016-08-02 15:42 ` [PATCH 7/8] mkfs: Move opts related #define to one place Jan Tulak
2016-08-02 15:42 ` [PATCH 8/8] mkfs: move conflicts into the table Jan Tulak
7 siblings, 0 replies; 9+ messages in thread
From: Jan Tulak @ 2016-08-02 15:42 UTC (permalink / raw)
To: xfs; +Cc: Jan Tulak
Checks are modified to work with cross-section conflicts (data, metada, log, ...).
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
mkfs/xfs_mkfs.c | 43 ++++++++++++++++++++++++++++++++++---------
1 file changed, 34 insertions(+), 9 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 6f3f278..2eca989 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -728,6 +728,9 @@ struct opt_params {
},
};
+static void conflict_struct(struct opt_params *opt, struct subopt_param *subopt,
+ struct subopt_conflict *conflict);
+
#define TERABYTES(count, blog) ((__uint64_t)(count) << (40 - (blog)))
#define GIGABYTES(count, blog) ((__uint64_t)(count) << (30 - (blog)))
#define MEGABYTES(count, blog) ((__uint64_t)(count) << (20 - (blog)))
@@ -1329,10 +1332,9 @@ check_opt(
break;
if (conflict_opt.test_values)
break;
- if (opt->subopt_params[conflict_opt.subopt].seen ||
- opt->subopt_params[conflict_opt.subopt].str_seen) {
- conflict(opt->name, (char **)opt->subopts,
- conflict_opt.subopt, index);
+ if (opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].seen ||
+ opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].str_seen) {
+ conflict_struct(opt, sp, &conflict_opt);
}
}
}
@@ -1357,13 +1359,12 @@ check_opt_value(
break;
if (!conflict_opt.test_values)
break;
- if ((opt->subopt_params[conflict_opt.subopt].seen ||
- opt->subopt_params[conflict_opt.subopt].str_seen) &&
- opt->subopt_params[conflict_opt.subopt].value
+ if ((opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].seen ||
+ opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].str_seen) &&
+ opts[conflict_opt.opt].subopt_params[conflict_opt.subopt].value
== conflict_opt.invalid_value &&
value == conflict_opt.at_value) {
- conflict(opt->name, (char **)opt->subopts,
- conflict_opt.subopt, index);
+ conflict_struct(opt, sp, &conflict_opt);
}
}
}
@@ -3430,12 +3431,36 @@ conflict(
char *tab[],
int oldidx,
int newidx)
+
{
fprintf(stderr, _("Cannot specify both -%c %s and -%c %s\n"),
opt, tab[oldidx], opt, tab[newidx]);
usage();
}
+static void
+conflict_struct(
+ struct opt_params *opt,
+ struct subopt_param *subopt,
+ struct subopt_conflict *conflict)
+{
+ if(conflict->message) {
+ fprintf(stderr, _("Cannot specify both -%c %s and -%c %s: %s\n"),
+ opt->name,
+ opt->subopts[subopt->index],
+ opts[conflict->opt].name,
+ opts[conflict->opt].subopts[conflict->subopt],
+ _(conflict->message));
+ } else {
+ fprintf(stderr, _("Cannot specify both -%c %s and -%c %s\n"),
+ opt->name,
+ opt->subopts[subopt->index],
+ opts[conflict->opt].name,
+ opts[conflict->opt].subopts[conflict->subopt]);
+ }
+ usage();
+}
+
static void
illegal(
--
2.5.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 7/8] mkfs: Move opts related #define to one place
2016-08-02 15:42 [RFC PATCH 0/8] mkfs: centralised conflict detection Jan Tulak
` (5 preceding siblings ...)
2016-08-02 15:42 ` [PATCH 6/8] mkfs: add cross-section conflict checks Jan Tulak
@ 2016-08-02 15:42 ` Jan Tulak
2016-08-02 15:42 ` [PATCH 8/8] mkfs: move conflicts into the table Jan Tulak
7 siblings, 0 replies; 9+ messages in thread
From: Jan Tulak @ 2016-08-02 15:42 UTC (permalink / raw)
To: xfs; +Cc: Jan Tulak
Takes all the "#define M_CRC x" from struct opt_params declaration and moves
them into a single place before the struct. This is because we need to
cross-link conflicts and we can't link -l version to -m crc if M_CRC is defined
after the conflict section.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
mkfs/xfs_mkfs.c | 134 ++++++++++++++++++++++++++++++--------------------------
1 file changed, 72 insertions(+), 62 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 2eca989..91c7fee 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -48,6 +48,78 @@ unsigned int sectorsize;
#define MAX_CONFLICTS 8
#define LAST_CONFLICT (-1)
+#define OPT_B 0
+#define B_LOG 0
+#define B_SIZE 1
+
+#define OPT_D 1
+#define D_AGCOUNT 0
+#define D_FILE 1
+#define D_NAME 2
+#define D_SIZE 3
+#define D_SUNIT 4
+#define D_SWIDTH 5
+#define D_AGSIZE 6
+#define D_SU 7
+#define D_SW 8
+#define D_SECTLOG 9
+#define D_SECTSIZE 10
+#define D_NOALIGN 11
+#define D_RTINHERIT 12
+#define D_PROJINHERIT 13
+#define D_EXTSZINHERIT 14
+
+
+#define OPT_I 2
+#define I_ALIGN 0
+#define I_LOG 1
+#define I_MAXPCT 2
+#define I_PERBLOCK 3
+#define I_SIZE 4
+#define I_ATTR 5
+#define I_PROJID32BIT 6
+#define I_SPINODES 7
+
+#define OPT_L 3
+#define L_AGNUM 0
+#define L_INTERNAL 1
+#define L_SIZE 2
+#define L_VERSION 3
+#define L_SUNIT 4
+#define L_SU 5
+#define L_DEV 6
+#define L_SECTLOG 7
+#define L_SECTSIZE 8
+#define L_FILE 9
+#define L_NAME 10
+#define L_LAZYSBCNTR 11
+
+
+#define OPT_N 4
+#define N_LOG 0
+#define N_SIZE 1
+#define N_VERSION 2
+#define N_FTYPE 3
+
+#define OPT_R 5
+#define R_EXTSIZE 0
+#define R_SIZE 1
+#define R_DEV 2
+#define R_FILE 3
+#define R_NAME 4
+#define R_NOALIGN 5
+
+#define OPT_S 6
+#define S_LOG 0
+#define S_SECTLOG 1
+#define S_SIZE 2
+#define S_SECTSIZE 3
+
+#define OPT_M 7
+#define M_CRC 0
+#define M_FINOBT 1
+#define M_UUID 2
+
/*
* Table for parsing mkfs parameters.
*
@@ -155,14 +227,11 @@ struct opt_params {
long long value;
} subopt_params[MAX_SUBOPTS];
} opts[MAX_OPTS] = {
-#define OPT_B 0
{
.index = OPT_B,
.name = 'b',
.subopts = {
-#define B_LOG 0
"log",
-#define B_SIZE 1
"size",
NULL
},
@@ -185,40 +254,24 @@ struct opt_params {
},
},
},
-#define OPT_D 1
{
.index = OPT_D,
.name = 'd',
.subopts = {
- #define D_AGCOUNT 0
"agcount",
- #define D_FILE 1
"file",
- #define D_NAME 2
"name",
- #define D_SIZE 3
"size",
- #define D_SUNIT 4
"sunit",
- #define D_SWIDTH 5
"swidth",
- #define D_AGSIZE 6
"agsize",
- #define D_SU 7
"su",
- #define D_SW 8
"sw",
- #define D_SECTLOG 9
"sectlog",
- #define D_SECTSIZE 10
"sectsize",
- #define D_NOALIGN 11
"noalign",
- #define D_RTINHERIT 12
"rtinherit",
- #define D_PROJINHERIT 13
"projinherit",
- #define D_EXTSZINHERIT 14
"extszinherit",
NULL
},
@@ -338,26 +391,17 @@ struct opt_params {
},
},
},
-#define OPT_I 2
{
.index = OPT_I,
.name = 'i',
.subopts = {
-#define I_ALIGN 0
"align",
-#define I_LOG 1
"log",
-#define I_MAXPCT 2
"maxpct",
-#define I_PERBLOCK 3
"perblock",
-#define I_SIZE 4
"size",
-#define I_ATTR 5
"attr",
-#define I_PROJID32BIT 6
"projid32bit",
-#define I_SPINODES 7
"sparse",
NULL
},
@@ -420,34 +464,21 @@ struct opt_params {
},
},
},
-#define OPT_L 3
{
.index = OPT_L,
.name = 'l',
.subopts = {
- #define L_AGNUM 0
"agnum",
- #define L_INTERNAL 1
"internal",
- #define L_SIZE 2
"size",
- #define L_VERSION 3
"version",
- #define L_SUNIT 4
"sunit",
- #define L_SU 5
"su",
- #define L_DEV 6
"logdev",
- #define L_SECTLOG 7
"sectlog",
- #define L_SECTSIZE 8
"sectsize",
- #define L_FILE 9
"file",
- #define L_NAME 10
"name",
- #define L_LAZYSBCNTR 11
"lazy-count",
NULL
},
@@ -538,18 +569,13 @@ struct opt_params {
},
},
},
-#define OPT_N 4
{
.index = OPT_N,
.name = 'n',
.subopts = {
- #define N_LOG 0
"log",
- #define N_SIZE 1
"size",
- #define N_VERSION 2
"version",
- #define N_FTYPE 3
"ftype",
NULL,
},
@@ -584,22 +610,15 @@ struct opt_params {
},
},
},
-#define OPT_R 5
{
.index = OPT_R,
.name = 'r',
.subopts = {
- #define R_EXTSIZE 0
"extsize",
- #define R_SIZE 1
"size",
- #define R_DEV 2
"rtdev",
- #define R_FILE 3
"file",
- #define R_NAME 4
"name",
- #define R_NOALIGN 5
"noalign",
NULL
},
@@ -640,18 +659,13 @@ struct opt_params {
},
},
},
-#define OPT_S 6
{
.index = OPT_S,
.name = 's',
.subopts = {
- #define S_LOG 0
"log",
- #define S_SECTLOG 1
"sectlog",
- #define S_SIZE 2
"size",
- #define S_SECTSIZE 3
"sectsize",
NULL
},
@@ -694,16 +708,12 @@ struct opt_params {
},
},
},
-#define OPT_M 7
{
.index = OPT_M,
.name = 'm',
.subopts = {
- #define M_CRC 0
"crc",
- #define M_FINOBT 1
"finobt",
- #define M_UUID 2
"uuid",
NULL
},
--
2.5.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 8/8] mkfs: move conflicts into the table
2016-08-02 15:42 [RFC PATCH 0/8] mkfs: centralised conflict detection Jan Tulak
` (6 preceding siblings ...)
2016-08-02 15:42 ` [PATCH 7/8] mkfs: Move opts related #define to one place Jan Tulak
@ 2016-08-02 15:42 ` Jan Tulak
7 siblings, 0 replies; 9+ messages in thread
From: Jan Tulak @ 2016-08-02 15:42 UTC (permalink / raw)
To: xfs; +Cc: Jan Tulak
Fill the table with conflicts data and remove now-duplicate code for their
detection from other parts of mkfs.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
mkfs/xfs_mkfs.c | 109 ++++++++++++++++++++++++++------------------------------
1 file changed, 50 insertions(+), 59 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 91c7fee..44fa65a 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -45,7 +45,7 @@ unsigned int sectorsize;
#define MAX_OPTS 16
#define MAX_SUBOPTS 16
#define SUBOPT_NEEDS_VAL (-1LL)
-#define MAX_CONFLICTS 8
+#define MAX_CONFLICTS 32
#define LAST_CONFLICT (-1)
#define OPT_B 0
@@ -407,7 +407,9 @@ struct opt_params {
},
.subopt_params = {
{ .index = I_ALIGN,
- .conflicts = { {LAST_CONFLICT} },
+ .conflicts = { {OPT_M, M_CRC, true, 1, 0,
+ "Inodes always aligned for CRC enabled filesytems."},
+ {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
@@ -445,19 +447,26 @@ struct opt_params {
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = I_ATTR,
- .conflicts = { {LAST_CONFLICT} },
+ .conflicts = { {OPT_M, M_CRC, true, 1, 1,
+ "V2 attribute format always enabled on CRC enabled filesytems."},
+ {LAST_CONFLICT} },
.minval = 0,
.maxval = 2,
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = I_PROJID32BIT,
- .conflicts = { {LAST_CONFLICT} },
+ .conflicts = { {OPT_M, M_CRC, true, 1, 0,
+ "32 bit Project IDs always enabled on CRC enabled filesytems."},
+ {LAST_CONFLICT} },
+
.minval = 0,
.maxval = 1,
.defaultval = 1,
},
{ .index = I_SPINODES,
- .conflicts = { {LAST_CONFLICT} },
+ .conflicts = { {OPT_M, M_CRC, true, 0, 1,
+ "Sparse inodes not supported without CRC support."},
+ {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
@@ -506,7 +515,9 @@ struct opt_params {
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = L_VERSION,
- .conflicts = { {LAST_CONFLICT} },
+ .conflicts = { {OPT_M, M_CRC, true, 1, 1,
+ "V2 logs are required for CRC enabled filesystems."},
+ {LAST_CONFLICT} },
.minval = 1,
.maxval = 2,
.defaultval = SUBOPT_NEEDS_VAL,
@@ -562,7 +573,9 @@ struct opt_params {
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = L_LAZYSBCNTR,
- .conflicts = { {LAST_CONFLICT} },
+ .conflicts = { {OPT_M, M_CRC, true, 1, 0,
+ "Lazy superblock counted always enabled for CRC enabled filesytems."},
+ {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
@@ -603,7 +616,9 @@ struct opt_params {
.defaultval = SUBOPT_NEEDS_VAL,
},
{ .index = N_FTYPE,
- .conflicts = { {LAST_CONFLICT} },
+ .conflicts = { {OPT_M, M_CRC, true, 1, 0,
+ "Cannot disable ftype with crcs enabled."},
+ {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
@@ -719,13 +734,31 @@ struct opt_params {
},
.subopt_params = {
{ .index = M_CRC,
- .conflicts = { {LAST_CONFLICT} },
+ .conflicts = { {OPT_L, L_VERSION, true, 1, 1,
+ "V2 logs are required for CRC enabled filesystems."},
+ {OPT_I, I_ALIGN, true, 0, 1,
+ "Inodes always aligned for CRC enabled filesytems."},
+ {OPT_I, I_PROJID32BIT, true, 0, 1,
+ "32 bit Project IDs always enabled on CRC enabled filesytems."},
+ {OPT_I, I_ATTR, true, 1, 1,
+ "V2 attribute format always enabled on CRC enabled filesytems."},
+ {OPT_L, L_LAZYSBCNTR, true, 0, 1,
+ "Lazy superblock counted always enabled for CRC enabled filesytems."},
+ {OPT_M, M_FINOBT, true, 1, 0,
+ "Finobt not supported without CRC support."},
+ {OPT_I, I_SPINODES, true, 1, 0,
+ "Sparse inodes not supported without CRC support."},
+ {OPT_N, N_FTYPE, true, 0, 1,
+ "Cannot disable ftype with crcs enabled."},
+ {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
},
{ .index = M_FINOBT,
- .conflicts = { {LAST_CONFLICT} },
+ .conflicts = { {OPT_M, M_CRC, true, 0, 1,
+ "Finobt not supported without CRC support."},
+ {LAST_CONFLICT} },
.minval = 0,
.maxval = 1,
.defaultval = 1,
@@ -2157,11 +2190,16 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
XFS_MIN_CRC_BLOCKSIZE);
usage();
}
+
+ /*
+ * If user explicitly stated -m crc=1 -n ftype=0, an error was already
+ * issued. But if -n ftype=0 was stated alone, then it is a conflict
+ * with a default value for crc enabled and has to be detected here.
+ */
if (sb_feat.crcs_enabled && !sb_feat.dirftype) {
fprintf(stderr, _("cannot disable ftype with crcs enabled\n"));
usage();
}
-
if (!slflag && !ssflag) {
sectorlog = XFS_MIN_SECTORSIZE_LOG;
sectorsize = XFS_MIN_SECTORSIZE;
@@ -2267,42 +2305,6 @@ _("Minimum inode size for CRCs is %d bytes\n"),
1 << XFS_DINODE_DFL_CRC_LOG);
usage();
}
-
- /* inodes always aligned */
- if (!sb_feat.inode_align) {
- fprintf(stderr,
-_("Inodes always aligned for CRC enabled filesytems\n"));
- usage();
- }
-
- /* lazy sb counters always on */
- if (!sb_feat.lazy_sb_counters) {
- fprintf(stderr,
-_("Lazy superblock counted always enabled for CRC enabled filesytems\n"));
- usage();
- }
-
- /* version 2 logs always on */
- if (sb_feat.log_version != 2) {
- fprintf(stderr,
-_("V2 logs always enabled for CRC enabled filesytems\n"));
- usage();
- }
-
- /* attr2 always on */
- if (sb_feat.attr_version != 2) {
- fprintf(stderr,
-_("V2 attribute format always enabled on CRC enabled filesytems\n"));
- usage();
- }
-
- /* 32 bit project quota always on */
- /* attr2 always on */
- if (sb_feat.projid16bit) {
- fprintf(stderr,
-_("32 bit Project IDs always enabled on CRC enabled filesytems\n"));
- usage();
- }
} else {
/*
* The kernel doesn't currently support crc=0,finobt=1
@@ -2310,21 +2312,10 @@ _("32 bit Project IDs always enabled on CRC enabled filesytems\n"));
* explicitly turned finobt on, then silently turn it off to
* avoid an unnecessary warning.
* If the user explicitly tried to use crc=0,finobt=1,
- * then issue an error.
+ * the error was already issued during args parsing.
* The same is also for sparse inodes.
*/
- if (sb_feat.finobt && opts[OPT_M].subopt_params[M_FINOBT].seen) {
- fprintf(stderr,
-_("finobt not supported without CRC support\n"));
- usage();
- }
sb_feat.finobt = 0;
-
- if (sb_feat.spinodes) {
- fprintf(stderr,
-_("sparse inodes not supported without CRC support\n"));
- usage();
- }
sb_feat.spinodes = 0;
}
--
2.5.5
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 9+ messages in thread