541-ubifs-xz-decompression-support.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. --- a/fs/ubifs/Kconfig
  2. +++ b/fs/ubifs/Kconfig
  3. @@ -5,8 +5,10 @@ config UBIFS_FS
  4. select CRYPTO if UBIFS_FS_ADVANCED_COMPR
  5. select CRYPTO if UBIFS_FS_LZO
  6. select CRYPTO if UBIFS_FS_ZLIB
  7. + select CRYPTO if UBIFS_FS_XZ
  8. select CRYPTO_LZO if UBIFS_FS_LZO
  9. select CRYPTO_DEFLATE if UBIFS_FS_ZLIB
  10. + select CRYPTO_XZ if UBIFS_FS_XZ
  11. depends on MTD_UBI
  12. help
  13. UBIFS is a file system for flash devices which works on top of UBI.
  14. @@ -42,6 +44,14 @@ config UBIFS_FS_ZLIB
  15. help
  16. Zlib compresses better than LZO but it is slower. Say 'Y' if unsure.
  17. +config UBIFS_FS_XZ
  18. + bool "XZ decompression support" if UBIFS_FS_ADVANCED_COMPR
  19. + depends on UBIFS_FS
  20. + default y
  21. + help
  22. + XZ compresses better the ZLIB but it is slower.
  23. + Say 'Y' if unsure.
  24. +
  25. # Debugging-related stuff
  26. config UBIFS_FS_DEBUG
  27. bool "Enable debugging support"
  28. --- a/fs/ubifs/compress.c
  29. +++ b/fs/ubifs/compress.c
  30. @@ -71,6 +71,24 @@ static struct ubifs_compressor zlib_comp
  31. };
  32. #endif
  33. +#ifdef CONFIG_UBIFS_FS_XZ
  34. +static DEFINE_MUTEX(xz_enc_mutex);
  35. +static DEFINE_MUTEX(xz_dec_mutex);
  36. +
  37. +static struct ubifs_compressor xz_compr = {
  38. + .compr_type = UBIFS_COMPR_XZ,
  39. + .comp_mutex = &xz_enc_mutex,
  40. + .decomp_mutex = &xz_dec_mutex,
  41. + .name = "xz",
  42. + .capi_name = "xz",
  43. +};
  44. +#else
  45. +static struct ubifs_compressor xz_compr = {
  46. + .compr_type = UBIFS_COMPR_XZ,
  47. + .name = "xz",
  48. +};
  49. +#endif
  50. +
  51. /* All UBIFS compressors */
  52. struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT];
  53. @@ -233,9 +251,15 @@ int __init ubifs_compressors_init(void)
  54. if (err)
  55. goto out_lzo;
  56. + err = compr_init(&xz_compr);
  57. + if (err)
  58. + goto out_zlib;
  59. +
  60. ubifs_compressors[UBIFS_COMPR_NONE] = &none_compr;
  61. return 0;
  62. +out_zlib:
  63. + compr_exit(&zlib_compr);
  64. out_lzo:
  65. compr_exit(&lzo_compr);
  66. return err;
  67. @@ -248,4 +272,5 @@ void ubifs_compressors_exit(void)
  68. {
  69. compr_exit(&lzo_compr);
  70. compr_exit(&zlib_compr);
  71. + compr_exit(&xz_compr);
  72. }
  73. --- a/fs/ubifs/ubifs-media.h
  74. +++ b/fs/ubifs/ubifs-media.h
  75. @@ -332,12 +332,14 @@ enum {
  76. * UBIFS_COMPR_NONE: no compression
  77. * UBIFS_COMPR_LZO: LZO compression
  78. * UBIFS_COMPR_ZLIB: ZLIB compression
  79. + * UBIFS_COMPR_XZ: XZ compression
  80. * UBIFS_COMPR_TYPES_CNT: count of supported compression types
  81. */
  82. enum {
  83. UBIFS_COMPR_NONE,
  84. UBIFS_COMPR_LZO,
  85. UBIFS_COMPR_ZLIB,
  86. + UBIFS_COMPR_XZ,
  87. UBIFS_COMPR_TYPES_CNT,
  88. };