diff options
author | Eric Sandeen <sandeen@redhat.com> | 2018-02-02 09:32:45 -0600 |
---|---|---|
committer | Eric Sandeen <sandeen@redhat.com> | 2018-02-02 09:32:45 -0600 |
commit | 16adcb8831cf75d405ab8f4b581e70af79f4dba8 (patch) | |
tree | 35d17db3a1eb666dd657ed980d36b85db2a117a9 | |
parent | 7d25f65f268565c07ef094ff7d25fb5a36cd3b9d (diff) | |
download | xfsprogs-dev-16adcb8831cf75d405ab8f4b581e70af79f4dba8.tar.gz |
mkfs: more sunit/swidth sanity checking
This fixes 2 issues with stripe geometry validation.
# mkfs.xfs -d sunit=64,swidth=0 ...
both data sunit and data swidth options must be specified
But I did specify it, I specified 0!
So use cli_opt_set() to detect that it was specified.
But we can't allow the above configuration (in fact it causes
a % 0 later in mkfs), so catch it in the "swidth must be a
multiple of sunit" test a bit further down.
(sunit=0,swidth=0 /is/ valid, it's used to override disk
geometry if desired.)
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
-rw-r--r-- | mkfs/xfs_mkfs.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index f527476f55..219b209b47 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -2233,7 +2233,7 @@ calc_stripe_factors( dsw = cli->dsw; /* data sunit/swidth options */ - if ((dsunit && !dswidth) || (!dsunit && dswidth)) { + if (cli_opt_set(&dopts, D_SUNIT) != cli_opt_set(&dopts, D_SWIDTH)) { fprintf(stderr, _("both data sunit and data swidth options must be specified\n")); usage(); @@ -2241,7 +2241,7 @@ _("both data sunit and data swidth options must be specified\n")); /* convert dsu/dsw to dsunit/dswidth and use them from now on */ if (dsu || dsw) { - if ((dsu && !dsw) || (!dsu && dsw)) { + if (cli_opt_set(&dopts, D_SU) != cli_opt_set(&dopts, D_SW)) { fprintf(stderr, _("both data su and data sw options must be specified\n")); usage(); @@ -2264,7 +2264,7 @@ _("data stripe width (%lld) is too large of a multiple of the data stripe unit ( dswidth = big_dswidth; } - if (dsunit && (dswidth % dsunit != 0)) { + if (dsunit && (!dswidth || (dswidth % dsunit != 0))) { fprintf(stderr, _("data stripe width (%d) must be a multiple of the data stripe unit (%d)\n"), dswidth, dsunit); |