492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From eea9e1785e4c05c2a3444506aabafa0ae958538f Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <daniel@makrotopia.org>
  3. Date: Sat, 17 May 2014 03:35:02 +0200
  4. Subject: [PATCH 4/5] try auto-mounting ubi0:rootfs in init/do_mounts.c
  5. To: openwrt-devel@lists.openwrt.org
  6. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
  7. ---
  8. init/do_mounts.c | 26 +++++++++++++++++++++++++-
  9. 1 file changed, 25 insertions(+), 1 deletion(-)
  10. --- a/init/do_mounts.c
  11. +++ b/init/do_mounts.c
  12. @@ -438,7 +438,28 @@ retry:
  13. out:
  14. put_page(page);
  15. }
  16. -
  17. +
  18. +static int __init mount_ubi_rootfs(void)
  19. +{
  20. + int flags = MS_SILENT;
  21. + int err, tried = 0;
  22. +
  23. + while (tried < 2) {
  24. + err = do_mount_root("ubi0:rootfs", "ubifs", flags, \
  25. + root_mount_data);
  26. + switch (err) {
  27. + case -EACCES:
  28. + flags |= MS_RDONLY;
  29. + tried++;
  30. + break;
  31. + default:
  32. + return err;
  33. + }
  34. + }
  35. +
  36. + return -EINVAL;
  37. +}
  38. +
  39. #ifdef CONFIG_ROOT_NFS
  40. #define NFSROOT_TIMEOUT_MIN 5
  41. @@ -532,6 +553,10 @@ void __init mount_root(void)
  42. change_floppy("root floppy");
  43. }
  44. #endif
  45. +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
  46. + if (!mount_ubi_rootfs())
  47. + return;
  48. +#endif
  49. #ifdef CONFIG_BLOCK
  50. {
  51. int err = create_dev("/dev/root", ROOT_DEV);