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 | 842
Set the compression algorithm to be used for compressing data in the zram device.
.TP
.BR \-f , " \-\-find"
case COL_ALGORITHM:
{
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
- str = xstrdup("lzo");
- free(alg);
+
+ if (alg != NULL) {
+
+ char* left_br = strrchr(alg, '[');
+ char* right_br = strrchr(alg, ']');
+
+ if (left_br != NULL && right_br != NULL
+ && right_br-left_br > 1) {
+ str = xmalloc(right_br-left_br);
+ strncpy(str, left_br+1, right_br-left_br-1);
+ str[right_br-left_br-1] = '\0';
+ }
+
+ free(alg);
+ }
break;
}
case COL_MOUNTPOINT:
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|842 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);
switch (c) {
case 'a':
- if (strcmp(optarg,"lzo") && strcmp(optarg,"lz4"))
- errx(EXIT_FAILURE, _("unsupported algorithm: %s"),
- optarg);
algorithm = optarg;
break;
case 'b':