pastebin - collaborative debugging tool
eckelmann.kpaste.net RSS


Prototype patch mkfs.ubifs so it does not compress specific file types with high entropy
Posted by Anonymous on Mon 29th Jul 2019 16:33
raw | new post

  1. diff -r -u ./platform-ecu01/build-target/mtd-utils-1.5.0/mkfs.ubifs/mkfs.ubifs.c ./platform-ecu01/build-host/mtd-utils-1.5.0/mkfs.ubifs/mkfs.ubifs.c
  2. --- mtd-utils-1.5.0/mkfs.ubifs/mkfs.ubifs.c 2012-05-07 09:19:39.000000000 +0200
  3. +++ mtd-utils-1.5.0/mkfs.ubifs/mkfs.ubifs.c 2019-07-29 16:17:34.482830999 +0200
  4. @@ -25,6 +25,7 @@
  5.  #include "mkfs.ubifs.h"
  6.  #include <crc32.h>
  7.  #include "common.h"
  8. +#include <stdbool.h>
  9.  
  10.  /* Size (prime number) of hash table for link counting */
  11.  #define HASH_TABLE_SIZE 10099
  12. @@ -1042,8 +1043,10 @@
  13.         union ubifs_key key;
  14.         int len, use_flags = 0;
  15.  
  16. +#if 0
  17.         if (c->default_compr != UBIFS_COMPR_NONE)
  18.                 use_flags |= UBIFS_COMPR_FL;
  19. +#endif
  20.         if (flags & FS_COMPR_FL)
  21.                 use_flags |= UBIFS_COMPR_FL;
  22.         if (flags & FS_SYNC_FL)
  23. @@ -1276,6 +1279,24 @@
  24.         unsigned int block_no = 0;
  25.         size_t out_len;
  26.  
  27. +#if 1
  28. +       bool no_compression = false;
  29. +       if (strstr(path_name, ".gz") ||
  30. +               strstr(path_name, "/lib/lib") ||
  31. +               strstr(path_name, "/bin/")
  32. +               )
  33. +       {
  34. +               no_compression = true;
  35. +       }
  36. +      
  37. +       if (no_compression)
  38. +       {
  39. +               (void)fprintf(stderr, "## Skipping compression for file '%s'\n", path_name);
  40. +               use_compr = UBIFS_COMPR_NONE;
  41. +               flags &= ~FS_COMPR_FL;
  42. +       }
  43. +#endif
  44. +
  45.         fd = open(path_name, O_RDONLY | O_LARGEFILE);
  46.         if (fd == -1)
  47.                 return sys_err_msg("failed to open file '%s'", path_name);
  48. @@ -1301,6 +1322,7 @@
  49.                         block_no += 1;
  50.                         continue;
  51.                 }
  52. +
  53.                 /* Make data node */
  54.                 memset(dn, 0, UBIFS_DATA_NODE_SZ);
  55.                 data_key_init(&key, inum, block_no++);
  56. @@ -1308,13 +1330,27 @@
  57.                 key_write(&key, &dn->key);
  58.                 dn->size = cpu_to_le32(bytes_read);
  59.                 out_len = NODE_BUFFER_SIZE - UBIFS_DATA_NODE_SZ;
  60. -               if (c->default_compr == UBIFS_COMPR_NONE &&
  61. -                   (flags & FS_COMPR_FL))
  62. -                       use_compr = UBIFS_COMPR_LZO;
  63. +#if 1
  64. +               if (no_compression) {
  65. +                       use_compr = UBIFS_COMPR_NONE;
  66. +               }
  67.                 else
  68. -                       use_compr = c->default_compr;
  69. +               {
  70. +#endif
  71. +                       if (c->default_compr == UBIFS_COMPR_NONE &&
  72. +                         (flags & FS_COMPR_FL))
  73. +                               use_compr = UBIFS_COMPR_LZO;
  74. +                       else
  75. +                               use_compr = c->default_compr;
  76. +#if 1
  77. +               }
  78. +#endif
  79.                 compr_type = compress_data(buf, bytes_read, &dn->data,
  80.                                            &out_len, use_compr);
  81. +#if 1
  82. +               if (compr_type != MKFS_UBIFS_COMPR_NONE)
  83. +                       flags |= FS_COMPR_FL;
  84. +#endif
  85.                 dn->compr_type = cpu_to_le16(compr_type);
  86.                 dn_len = UBIFS_DATA_NODE_SZ + out_len;
  87.                 /* Add data node to file system */

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at