553-ubifs-Add-option-to-create-UBI-FS-version-4-on-empty.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From 93c33e6a7f3b0aef99d02252e6232a3d8b80f2d5 Mon Sep 17 00:00:00 2001
  2. From: Hauke Mehrtens <hauke@hauke-m.de>
  3. Date: Sun, 21 Jan 2018 15:47:50 +0100
  4. Subject: ubifs: Add option to create UBI FS version 4 on empty UBI volume
  5. Instead of creating an ubifs file system with format version 5 by
  6. default on empty UBI volumes add a compile option to create an older ubi
  7. with file system format version 4 instated. This allows it to be mount
  8. as a volume on kernel versions < 4.10, which does not support format
  9. version 5.
  10. We saw that some people can not access their older data when they
  11. downgraded from kernel 4.14 to kernel 4.9 to prevent this this option
  12. would help.
  13. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
  14. ---
  15. fs/ubifs/Kconfig | 13 +++++++++++++
  16. fs/ubifs/sb.c | 6 ++++++
  17. 2 files changed, 19 insertions(+)
  18. --- a/fs/ubifs/Kconfig
  19. +++ b/fs/ubifs/Kconfig
  20. @@ -74,3 +74,16 @@ config UBIFS_FS_SECURITY
  21. the extended attribute support in advance.
  22. If you are not using a security module, say N.
  23. +
  24. +config UBIFS_FS_FORMAT4
  25. + bool "Use file system format version 4 for new file systems"
  26. + depends on UBIFS_FS
  27. + help
  28. + Instead of creating new file systems with the new ubifs file
  29. + system version 5, use the old format version 4 for implicitly
  30. + by the driver created file systems on an empty UBI volume. This
  31. + makes it possible to mount these file systems also with kernel
  32. + versions before 4.10. The driver will still support file system
  33. + format version 5 for ubifs file systems created with version 5.
  34. +
  35. + If you are unsure, say N.
  36. --- a/fs/ubifs/sb.c
  37. +++ b/fs/ubifs/sb.c
  38. @@ -176,7 +176,9 @@ static int create_default_filesystem(str
  39. tmp64 = (long long)max_buds * c->leb_size;
  40. if (big_lpt)
  41. sup_flags |= UBIFS_FLG_BIGLPT;
  42. +#ifndef CONFIG_UBIFS_FS_FORMAT4
  43. sup_flags |= UBIFS_FLG_DOUBLE_HASH;
  44. +#endif
  45. sup->ch.node_type = UBIFS_SB_NODE;
  46. sup->key_hash = UBIFS_KEY_HASH_R5;
  47. @@ -192,7 +194,11 @@ static int create_default_filesystem(str
  48. sup->jhead_cnt = cpu_to_le32(DEFAULT_JHEADS_CNT);
  49. sup->fanout = cpu_to_le32(DEFAULT_FANOUT);
  50. sup->lsave_cnt = cpu_to_le32(c->lsave_cnt);
  51. +#ifdef CONFIG_UBIFS_FS_FORMAT4
  52. + sup->fmt_version = cpu_to_le32(4);
  53. +#else
  54. sup->fmt_version = cpu_to_le32(UBIFS_FORMAT_VERSION);
  55. +#endif
  56. sup->time_gran = cpu_to_le32(DEFAULT_TIME_GRAN);
  57. if (c->mount_opts.override_compr)
  58. sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);