From: "Luis R. Rodriguez" <mcgrof@kernel.org>
To: sandeen@sandeen.net, linux-xfs@vger.kernel.org
Cc: jack@suse.com, jeffm@suse.com, okurz@suse.com,
lpechacek@suse.com, "Luis R. Rodriguez" <mcgrof@kernel.org>
Subject: [PATCH 8/9] mkfs.xfs: use parse_subopts() to parse sopts
Date: Fri, 3 Mar 2017 15:13:15 -0800 [thread overview]
Message-ID: <20170303231316.12716-9-mcgrof@kernel.org> (raw)
In-Reply-To: <20170303231316.12716-1-mcgrof@kernel.org>
All sopt parameters are already part of struct mkfs_xfs_opts, so
all we need to do is use the helper.
Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
mkfs/xfs_mkfs.c | 70 +++++++++++++++++++++++++++------------------------------
1 file changed, 33 insertions(+), 37 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 39ab08148687..2a3786ece6b6 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1760,6 +1760,38 @@ parse_subopts(
}
}
break;
+ case 's':
+ while (*p != '\0') {
+ switch (getsubopt(&p, (char **)sopts.subopts, &value)) {
+ case S_LOG:
+ case S_SECTLOG:
+ if (params->lssflag)
+ conflict('s', (char **)sopts.subopts,
+ S_SECTSIZE, S_SECTLOG);
+ params->sectorlog =
+ getnum(value, &sopts, S_SECTLOG);
+ params->lsectorlog = params->sectorlog;
+ sectorsize = 1 << params->sectorlog;
+ params->lsectorsize = sectorsize;
+ params->lslflag = params->slflag = 1;
+ break;
+ case S_SIZE:
+ case S_SECTSIZE:
+ if (params->lslflag)
+ conflict('s', (char **)sopts.subopts,
+ S_SECTLOG, S_SECTSIZE);
+ sectorsize = getnum(value, &sopts, S_SECTSIZE);
+ params->lsectorsize = sectorsize;
+ params->sectorlog =
+ libxfs_highbit32(sectorsize);
+ params->lsectorlog = params->sectorlog;
+ params->lssflag = params->ssflag = 1;
+ break;
+ default:
+ unknown('s', value);
+ }
+ }
+ break;
default:
usage();
}
@@ -1865,6 +1897,7 @@ main(
case 'm':
case 'n':
case 'r':
+ case 's':
p = optarg;
parse_subopts(c, p, ¶ms);
break;
@@ -1887,43 +1920,6 @@ main(
case 'q':
qflag = 1;
break;
- case 's':
- p = optarg;
- while (*p != '\0') {
- char **subopts = (char **)sopts.subopts;
- char *value;
-
- switch (getsubopt(&p, subopts, &value)) {
- case S_LOG:
- case S_SECTLOG:
- if (params.lssflag)
- conflict('s', subopts,
- S_SECTSIZE, S_SECTLOG);
- params.sectorlog = getnum(value, &sopts,
- S_SECTLOG);
- params.lsectorlog = params.sectorlog;
- sectorsize = 1 << params.sectorlog;
- params.lsectorsize = sectorsize;
- params.lslflag = params.slflag = 1;
- break;
- case S_SIZE:
- case S_SECTSIZE:
- if (params.lslflag)
- conflict('s', subopts, S_SECTLOG,
- S_SECTSIZE);
- sectorsize = getnum(value, &sopts,
- S_SECTSIZE);
- params.lsectorsize = sectorsize;
- params.sectorlog =
- libxfs_highbit32(sectorsize);
- params.lsectorlog = params.sectorlog;
- params.lssflag = params.ssflag = 1;
- break;
- default:
- unknown('s', value);
- }
- }
- break;
case 'V':
printf(_("%s version %s\n"), progname, VERSION);
exit(0);
--
2.11.0
next prev parent reply other threads:[~2017-03-03 23:14 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-03 23:13 [PATCH 0/9] mkfs.xfs: add mkfs.xfs.conf support Luis R. Rodriguez
2017-03-03 23:13 ` [PATCH 1/9] mkfs.xfs: add helper to parse command line options Luis R. Rodriguez
2017-03-03 23:13 ` [PATCH 2/9] mkfs.xfs: move dopts to struct mkfs_xfs_opts Luis R. Rodriguez
2017-03-03 23:13 ` [PATCH 3/9] mkfs.xfs: move iopts to " Luis R. Rodriguez
2017-03-03 23:13 ` [PATCH 4/9] mkfs.xfs: move lopts " Luis R. Rodriguez
2017-03-03 23:13 ` [PATCH 5/9] mkfs.xfs: move mopts " Luis R. Rodriguez
2017-03-03 23:13 ` [PATCH 6/9] mkfs.xfs: move nopts " Luis R. Rodriguez
2017-03-03 23:13 ` [PATCH 7/9] mkfs.xfs: move ropts " Luis R. Rodriguez
2017-03-03 23:13 ` Luis R. Rodriguez [this message]
2017-03-03 23:13 ` [PATCH 9/9] mkfs.xfs: add mkfs.xfs.conf parse support Luis R. Rodriguez
2017-03-03 23:55 ` Dave Chinner
2017-03-09 5:38 ` Eric Sandeen
2017-03-03 23:24 ` [PATCH 0/9] mkfs.xfs: add mkfs.xfs.conf support Luis R. Rodriguez
2017-03-04 3:49 ` Eric Sandeen
2017-03-04 4:56 ` Dave Chinner
2017-03-06 0:08 ` Eric Sandeen
2017-03-07 20:07 ` Jeff Mahoney
2017-03-07 20:09 ` Eric Sandeen
2017-03-06 8:50 ` Jan Kara
2017-03-09 0:16 ` Eric Sandeen
2017-03-09 0:51 ` Luis R. Rodriguez
2017-03-09 4:41 ` Eric Sandeen
2017-03-09 10:12 ` Jan Tulak
2017-03-09 14:31 ` Eric Sandeen
2017-03-09 15:21 ` Jan Tulak
2017-03-09 17:57 ` Luis R. Rodriguez
2017-03-09 22:34 ` Dave Chinner
2017-04-24 5:00 ` Luis R. Rodriguez
2017-04-24 7:26 ` Jan Tulak
2017-04-24 8:25 ` Luis R. Rodriguez
2017-05-11 22:46 ` Luis R. Rodriguez
2017-05-11 22:57 ` Eric Sandeen
2017-05-11 23:08 ` Luis R. Rodriguez
2017-05-12 0:48 ` Darrick J. Wong
2017-05-12 16:05 ` Eric Sandeen
2017-05-12 17:03 ` Luis R. Rodriguez
2017-05-12 17:05 ` Jeff Mahoney
2017-05-12 17:30 ` Luis R. Rodriguez
2017-05-11 23:00 ` Darrick J. Wong
2017-05-11 23:19 ` Luis R. Rodriguez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170303231316.12716-9-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=jack@suse.com \
--cc=jeffm@suse.com \
--cc=linux-xfs@vger.kernel.org \
--cc=lpechacek@suse.com \
--cc=okurz@suse.com \
--cc=sandeen@sandeen.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).