1
0
This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
ZyXEL_PMG5617GA/tools/mtd-utils/patches/137-mkfs.jffs2-new-option-donotcompress.patch
2022-11-27 10:16:14 +00:00

101 lines
2.6 KiB
Diff

Index: mtd-utils-1.4.5/mkfs.jffs2.c
===================================================================
--- mtd-utils-1.4.5.orig/mkfs.jffs2.c 2013-10-22 14:24:10.743123864 +0800
+++ mtd-utils-1.4.5/mkfs.jffs2.c 2013-10-25 11:40:54.016495058 +0800
@@ -745,6 +745,31 @@
padword();
}
+static int do_not_compress(char *name)
+{
+ int ret = 0;
+ if( donotcompress_filelist[0] != '\0' )
+ {
+ char filename[256];
+ FILE *fp = xfopen(donotcompress_filelist, "r");
+
+ while( fgets(filename, sizeof(filename), fp) )
+ {
+ filename[strlen(filename) - 1] = '\0';
+ if( !strcmp(name, filename) )
+ {
+ printf("not compressing file, %s\n", name);
+ ret = 1;
+ break;
+ }
+ }
+
+ fclose(fp);
+ }
+
+ return( ret );
+}
+
static unsigned int write_regular_file(struct filesystem_entry *e)
{
int fd, len;
@@ -790,6 +815,9 @@
ri.mtime = cpu_to_je32(statbuf->st_mtime);
ri.isize = cpu_to_je32(statbuf->st_size);
+ if( do_not_compress(e->fullname) )
+ jffs2_set_compression_mode_name("none");
+
while ((len = read(fd, buf, page_size))) {
unsigned char *tbuf = buf;
@@ -867,6 +895,9 @@
}
free(buf);
close(fd);
+
+ jffs2_set_compression_mode_name(default_compression_name);
+
return totcomp;
}
@@ -1447,7 +1478,8 @@
" -h, --help Display this help text\n"
" -v, --verbose Verbose operation\n"
" -V, --version Display version information\n"
-" -i, --incremental=FILE Parse FILE and generate appendage output for it\n\n";
+" -i, --incremental=FILE Parse FILE and generate appendage output for it\n"
+" -N, --donotcompress-filelist=FILE Do not compress files in FILE\n\n";
static const char revtext[] = "1.60";
@@ -1600,7 +1632,7 @@
jffs2_compressors_init();
while ((opt = getopt_long(argc, argv,
- "D:d:r:s:o:qUPfh?vVe:lbp::nc:m:x:X:Lty:i:", long_options, &c)) >= 0)
+ "D:d:r:s:o:qUPfh?vVe:lbp::nc:m:x:X:Lty:i:N:", long_options, &c)) >= 0)
{
switch (opt) {
case 'D':
@@ -1778,6 +1810,10 @@
| (1 << JFFS2_XPREFIX_ACL_DEFAULT);
break;
#endif
+ case 'N':
+ strcpy(donotcompress_filelist, optarg);
+ break;
+
}
}
if (warn_page_size) {
Index: mtd-utils-1.4.5/mkfs.jffs2.c
===================================================================
--- mtd-utils-1.4.5.orig/mkfs.jffs2.c 2013-10-25 11:42:48.112492118 +0800
+++ mtd-utils-1.4.5/mkfs.jffs2.c 2013-10-25 11:44:47.840488939 +0800
@@ -120,6 +120,9 @@
static int fake_times = 0;
int target_endian = __BYTE_ORDER;
+static char default_compression_name[16] = "priority";
+static char donotcompress_filelist[256] = "";
+
uint32_t find_hardlink(struct filesystem_entry *e)
{
struct filesystem_entry *f;