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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>

--
Change:
  * sectsize can be set in blocks and vice versa now
---
 mkfs/xfs_mkfs.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

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

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux