From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 8/8] zramctl: allow use of --algorithm and --streams alone
Date: Mon, 4 Aug 2014 00:08:10 +0100 [thread overview]
Message-ID: <1407107290-5806-1-git-send-email-kerolasa@iki.fi> (raw)
Earlier the --algorithm and --streams had to be combined with --size. To
user requirement to combine with --size was indirectly told using
following message.
$ zramctl --stream 3 zram3
zramctl: options --algorithm, --find and --streams are mutually exclusive
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
sys-utils/zramctl.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c
index afbc0e8..43b7dcb 100644
--- a/sys-utils/zramctl.c
+++ b/sys-utils/zramctl.c
@@ -388,7 +388,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)
fputs(_(" --raw use raw status output format\n"), out);
fputs(_(" -r, --reset reset all specified devices\n"), out);
fputs(_(" -s, --size <size> device size\n"), out);
- fputs(_(" -t, --streams <number> number of compressoin streams\n\n"), out);
+ fputs(_(" -t, --streams <number> number of compressoin streams\n"), out);
fputs(USAGE_SEPARATOR, out);
fputs(USAGE_HELP, out);
@@ -408,6 +408,7 @@ enum {
A_STATUS,
A_CREATE,
A_FINDONLY,
+ A_SETTINGS,
A_RESET
};
@@ -502,8 +503,12 @@ int main(int argc, char **argv)
if (find && optind < argc)
errx(EXIT_FAILURE, _("option --find is mutually exclusive "
"with <device>"));
- if (act == A_NONE)
- act = find ? A_FINDONLY : A_STATUS;
+ if (act == A_NONE) {
+ if (algorithm || nstreams)
+ act = A_SETTINGS;
+ else
+ act = find ? A_FINDONLY : A_STATUS;
+ }
if (act != A_RESET && optind + 1 < argc)
errx(EXIT_FAILURE, _("only one <device> at a time is allowed"));
@@ -552,6 +557,7 @@ int main(int argc, char **argv)
free_zram(zram);
break;
case A_CREATE:
+ case A_SETTINGS:
if (find) {
zram = find_free_zram();
if (!zram)
@@ -561,8 +567,9 @@ int main(int argc, char **argv)
else
zram = new_zram(argv[optind]);
- if (zram_set_u64parm(zram, "reset", 1))
- err(EXIT_FAILURE, _("%s: failed to reset"), zram->devname);
+ if (act == A_CREATE)
+ if (zram_set_u64parm(zram, "reset", 1))
+ err(EXIT_FAILURE, _("%s: failed to reset"), zram->devname);
if (nstreams &&
zram_set_u64parm(zram, "max_comp_streams", nstreams))
@@ -572,9 +579,10 @@ int main(int argc, char **argv)
zram_set_strparm(zram, "comp_algorithm", algorithm))
err(EXIT_FAILURE, _("%s: failed to set algorithm"), zram->devname);
- if (zram_set_u64parm(zram, "disksize", size))
- err(EXIT_FAILURE, _("%s: failed to set disksize (%ju bytes)"),
- zram->devname, size);
+ if (act == A_CREATE)
+ if (zram_set_u64parm(zram, "disksize", size))
+ err(EXIT_FAILURE, _("%s: failed to set disksize (%ju bytes)"),
+ zram->devname, size);
if (find)
printf("%s\n", zram->devname);
free_zram(zram);
--
2.0.3
next reply other threads:[~2014-08-03 23:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-03 23:08 Sami Kerola [this message]
2014-08-03 23:24 ` [PATCH 8/8] zramctl: allow use of --algorithm and --streams alone Bernhard Voelker
2014-08-04 11:55 ` Karel Zak
2014-08-05 22:36 ` Sami Kerola
2014-08-06 8:20 ` Karel Zak
2014-08-06 12:19 ` Sergey Senozhatsky
2014-08-06 20:48 ` Sami Kerola
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=1407107290-5806-1-git-send-email-kerolasa@iki.fi \
--to=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/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