From: Lucas C. V. R. <lu...@go...> - 2008-07-31 13:18:42
|
On Thu, Jul 31, 2008 at 5:37 AM, Geert Uytterhoeven <Gee...@so...> wrote: > On Tue, 8 Jul 2008, Lucas C. Villa Real wrote: >> This patch allows one to specify which compression level to use when >> creating a squashfs image with mksquashfs. When no option is given the >> default compression level is used, so the default behaviour is kept. >> This feature has shown to be very useful while I was working in a >> platform with limited resources, so I believe others might find it >> useful as well. > > [ converted attachment to inline for easier commenting ] > >> Adds -compressionLevel option to mksquashfs. >> >> Signed-off-by: Lucas C. Villa Real <lu...@go...> >> >> --- squashfs-tools/mksquashfs.c.orig 2008-07-04 12:41:58.000000000 -0300 >> +++ squashfs-tools/mksquashfs.c 2008-07-08 12:19:23.000000000 -0300 >> @@ -3398,6 +3398,17 @@ int main(int argc, char *argv[]) >> exit(1); >> } >> } >> + } else if(strcmp(argv[i], "-compressionLevel") == 0) { >> + if(++i == argc) { >> + ERROR("%s: -compressionLevel requires a parameter\n", argv[0]); >> + exit(1); >> + } >> + cLevel = atoi(argv[i]); >> + if (cLevel != -1 && cLevel != 0 && cLevel != 1 && cLevel != 9) { >> + ERROR("%s: -compressionLevel out of range\n", argv[0]); >> + exit(1); >> + } >> + printf("using compression level %d\n", cLevel); >> } else if(strcmp(argv[i], "-noI") == 0 || >> strcmp(argv[i], "-noInodeCompression") == 0) >> noI = TRUE; >> @@ -3480,6 +3491,8 @@ printOptions: >> ERROR("-nopad\t\t\tdo not pad filesystem to a multiple of 4K\n"); >> ERROR("-check_data\t\tadd checkdata for greater filesystem checks\n"); >> ERROR("-root-owned\t\talternative name for -all-root\n"); >> + ERROR("-compressionLevel\tzlib compression level. Valid values are -1(default),\n"); >> + ERROR("\t\t\t0(no compression), 1(best speed) and 9(best compression)\n"); >> ERROR("-noInodeCompression\talternative name for -noI\n"); >> ERROR("-noDataCompression\talternative name for -noD\n"); >> ERROR("-noFragmentCompression\talternative name for -noF\n"); > > Just wondering, why do you limit the possible values of cLevel? Ooops, my bad! I probably just took the definitions from zlib.h and blindly limited the code to use those values. Please consider the attached patch instead. Thanks for the review! Regards, Lucas |