util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Libor Bukata <lbukata@gmail.com>
To: util-linux@vger.kernel.org
Cc: Nefelim4ag@gmail.com, kzak@redhat.com
Subject: Patch to add support for lz4hc and deflate optimization algorithms in zramctl.
Date: Mon, 22 Jan 2018 21:45:54 +0100	[thread overview]
Message-ID: <90fb3b4a-38b8-17fc-f1b6-03e8c23eb808@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 216 bytes --]

Dear developers of Linux utils,

I extended the zramctl utility to handle also lz4hc and deflate formats.
The patch is included in the attachment. Thank you in advance for your
comments.

Kind regards,
Libor Bukata.

[-- Attachment #2: new_comp_alg.patch --]
[-- Type: text/x-patch, Size: 2186 bytes --]

diff --git a/sys-utils/zramctl.8 b/sys-utils/zramctl.8
index 9ca2983b9..ef44435ed 100644
--- a/sys-utils/zramctl.8
+++ b/sys-utils/zramctl.8
@@ -44,7 +44,7 @@ query the status of used zram devices.
 If no option is given, all non-zero size zram devices are shown.
 .SH OPTIONS
 .TP
-.BR \-a , " \-\-algorithm lzo" | lz4
+.BR \-a , " \-\-algorithm lzo" | lz4 | lz4hc | deflate
 Set the compression algorithm to be used for compressing data in the zram device.
 .TP
 .BR \-f , " \-\-find"
diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c
index fb64150d6..9117ddce3 100644
--- a/sys-utils/zramctl.c
+++ b/sys-utils/zramctl.c
@@ -424,13 +424,16 @@ static void fill_table_row(struct libscols_table *tb, struct zram *z)
 			char *alg = sysfs_strdup(sysfs, "comp_algorithm");
 			if (!alg)
 				break;
-			if (strstr(alg, "[lzo]") == NULL) {
-				if (strstr(alg, "[lz4]") == NULL)
-					;
-				else
-					str = xstrdup("lz4");
-			} else
+
+			if (strstr(alg, "[lzo]") != NULL)
 				str = xstrdup("lzo");
+			else if (strstr(alg, "[lz4]") != NULL)
+				str = xstrdup("lz4");
+			else if (strstr(alg, "[lz4hc]") != NULL)
+				str = xstrdup("lz4hc");
+			else if (strstr(alg, "[deflate]") != NULL)
+				str = xstrdup("deflate");
+
 			free(alg);
 			break;
 		}
@@ -539,7 +542,7 @@ static void __attribute__((__noreturn__)) usage(void)
 	fputs(_("Set up and control zram devices.\n"), out);
 
 	fputs(USAGE_OPTIONS, out);
-	fputs(_(" -a, --algorithm lzo|lz4   compression algorithm to use\n"), out);
+	fputs(_(" -a, --algorithm lzo|lz4|lz4hc|deflate   compression algorithm to use\n"), out);
 	fputs(_(" -b, --bytes               print sizes in bytes rather than in human readable format\n"), out);
 	fputs(_(" -f, --find                find a free device\n"), out);
 	fputs(_(" -n, --noheadings          don't print headings\n"), out);
@@ -611,7 +614,8 @@ int main(int argc, char **argv)
 
 		switch (c) {
 		case 'a':
-			if (strcmp(optarg,"lzo") && strcmp(optarg,"lz4"))
+			if (strcmp(optarg,"lzo") && strcmp(optarg,"lz4")
+					&& strcmp(optarg,"lz4hc") && strcmp(optarg, "deflate"))
 				errx(EXIT_FAILURE, _("unsupported algorithm: %s"),
 					     optarg);
 			algorithm = optarg;

             reply	other threads:[~2018-01-22 20:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22 20:45 Libor Bukata [this message]
2018-01-23  8:08 ` Patch to add support for lz4hc and deflate optimization algorithms in zramctl Timofey Titovets
2018-01-23 13:21   ` Timofey Titovets
2018-01-23 17:57     ` Libor Bukata
2018-01-23 18:33       ` Timofey Titovets
2018-01-24 13:38       ` Karel Zak
2018-01-25  4:27 ` Mike Frysinger

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=90fb3b4a-38b8-17fc-f1b6-03e8c23eb808@gmail.com \
    --to=lbukata@gmail.com \
    --cc=Nefelim4ag@gmail.com \
    --cc=kzak@redhat.com \
    --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;
as well as URLs for NNTP newsgroup(s).