diff mbox

[18/22] mkfs: prevent sector/blocksize to be specified as a number of blocks

Message ID 1481117249-21273-19-git-send-email-jtulak@redhat.com (mailing list archive)
State Superseded
Headers show

Commit Message

Jan Tulak Dec. 7, 2016, 1:27 p.m. UTC
Documentation states that the options blocked in this patch accepts the
size only in bytes. So prevent blocksize or sectorsize to be specified as
a number of blocks or sectors.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 mkfs/xfs_mkfs.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Bill O'Donnell Jan. 16, 2017, 2:15 p.m. UTC | #1
On Wed, Dec 07, 2016 at 02:27:25PM +0100, Jan Tulak wrote:
> Documentation states that the options blocked in this patch accepts the
> size only in bytes. So prevent blocksize or sectorsize to be specified as
> a number of blocks or sectors.
> 
> Signed-off-by: Jan Tulak <jtulak@redhat.com>

Reviewed-by: Bill O'Donnell <billodo@redhat.com>

> ---
>  mkfs/xfs_mkfs.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index d55eb9a..e8fd49b 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -2041,6 +2041,27 @@ getnum(
>  		}
>  	}
>  
> +	/* Prevent things like specifying blocksize as a number of blocks. */
> +	if (opts->index == OPT_B || opts->index == OPT_S ||
> +		(opts->index == OPT_L && (index == L_SECTLOG ||
> +			index == L_SECTSIZE)) ||
> +		(opts->index == OPT_N && (index == N_SIZE)) ||
> +		(opts->index == OPT_D && (index == D_SECTLOG ||
> +			index == D_SECTSIZE))
> +
> +		) {
> +		switch (str[strlen(str)-1]) {
> +		case 'b':
> +		case 's':
> +			fprintf(stderr,
> +				_("You can't set a sector or block size in "
> +				  "number of blocks or sectors (-%c %s).\n"),
> +				opts->name, opts->subopts[index]);
> +			exit(1);
> +		}
> +
> +	}
> +
>  	sp->seen = true;
>  
>  	if (test_uvalue_num(sp->type, sp->minval, 0) &&
> -- 
> 2.8.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index d55eb9a..e8fd49b 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2041,6 +2041,27 @@  getnum(
 		}
 	}
 
+	/* Prevent things like specifying blocksize as a number of blocks. */
+	if (opts->index == OPT_B || opts->index == OPT_S ||
+		(opts->index == OPT_L && (index == L_SECTLOG ||
+			index == L_SECTSIZE)) ||
+		(opts->index == OPT_N && (index == N_SIZE)) ||
+		(opts->index == OPT_D && (index == D_SECTLOG ||
+			index == D_SECTSIZE))
+
+		) {
+		switch (str[strlen(str)-1]) {
+		case 'b':
+		case 's':
+			fprintf(stderr,
+				_("You can't set a sector or block size in "
+				  "number of blocks or sectors (-%c %s).\n"),
+				opts->name, opts->subopts[index]);
+			exit(1);
+		}
+
+	}
+
 	sp->seen = true;
 
 	if (test_uvalue_num(sp->type, sp->minval, 0) &&