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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. @@ -433,7 +433,27 @@ 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. + default:
  31. + return err;
  32. + }
  33. + }
  34. +
  35. + return -EINVAL;
  36. +}
  37. +
  38. #ifdef CONFIG_ROOT_NFS
  39. #define NFSROOT_TIMEOUT_MIN 5
  40. @@ -527,6 +547,10 @@ void __init mount_root(void)
  41. change_floppy("root floppy");
  42. }
  43. #endif
  44. +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
  45. + if (!mount_ubi_rootfs())
  46. + return;
  47. +#endif
  48. #ifdef CONFIG_BLOCK
  49. create_dev("/dev/root", ROOT_DEV);
  50. mount_block_root("/dev/root", root_mountflags);