From: Andrew Price Date: Thu, 1 Oct 2020 15:32:08 +0100 Subject: [Cluster-devel] [PATCH 3/3] mkfs.gfs2: Check for negative -j option In-Reply-To: <20201001143208.1893890-1-anprice@redhat.com> References: <20201001143208.1893890-1-anprice@redhat.com> Message-ID: <20201001143208.1893890-3-anprice@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit When a bad -j argument like -j -2 is given, mkfs.gfs2 prints a confusing error that the fs will not fit on the disk. Add a specific check and error message for that case. Tidy up some other bad option error messages while we're at it. Signed-off-by: Andrew Price --- gfs2/mkfs/main_mkfs.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c index b8aa22b4..17643e59 100644 --- a/gfs2/mkfs/main_mkfs.c +++ b/gfs2/mkfs/main_mkfs.c @@ -119,7 +119,7 @@ struct mkfs_opts { unsigned long sunit; unsigned long swidth; uint64_t fssize; - uint32_t journals; + int journals; const char *lockproto; const char *locktable; struct mkfs_dev dev; @@ -582,22 +582,25 @@ static int opts_check(struct mkfs_opts *opts) if (GFS2_MIN_RGSIZE > opts->rgsize || opts->rgsize > GFS2_MAX_RGSIZE) { /* Translators: gfs2 file systems are split into equal sized chunks called resource groups. We're checking that the user gave a valid size for them. */ - fprintf(stderr, _("bad resource group size\n")); + fprintf(stderr, _("Bad resource group size\n")); return -1; } if (!opts->journals) { - fprintf(stderr, _("no journals specified\n")); + fprintf(stderr, _("No journals specified\n")); + return -1; + } + if (opts->journals < 0) { + fprintf(stderr, _("Number of journals cannot be negative: %d\n"), opts->journals); return -1; } - if (opts->jsize < GFS2_MIN_JSIZE || opts->jsize > GFS2_MAX_JSIZE) { - fprintf(stderr, _("bad journal size\n")); + fprintf(stderr, _("Bad journal size\n")); return -1; } if (!opts->qcsize || opts->qcsize > 64) { - fprintf(stderr, _("bad quota change size\n")); + fprintf(stderr, _("Bad quota change size\n")); return -1; } -- 2.26.2