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

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