Re: Patch to add support for lz4hc and deflate optimization algorithms in zramctl.

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

 



On Tue, Jan 23, 2018 at 06:57:06PM +0100, Libor Bukata wrote:
> Thank you for your comments. I added the support for 842 compression
> algorithm.

@@ -424,13 +424,18 @@ 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");
+			else if (strstr(alg, "[842]") != NULL)
+				str = xstrdup("842");
+

The question is if we really need to care about the algorithm string
at all. I think it would be better to accept arbitrary string from
sysfs and just remove "[" and "]" from the string only.

 		switch (c) {
 		case 'a':
-			if (strcmp(optarg,"lzo") && strcmp(optarg,"lz4"))
+			if (strcmp(optarg,"lzo") && strcmp(optarg,"lz4") && strcmp(optarg,"lz4hc")
+					&& strcmp(optarg,"deflate") && strcmp(optarg,"842"))
 				errx(EXIT_FAILURE, _("unsupported algorithm: %s"),

The same situation. I guess we can accept arbitrary string here and
assume that kernel is smart enough to reject requests to use wrong
algorithm name.

    Karel

-- 
2.13.6



-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux