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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. From: Daniel Golle <[email protected]>
  2. Subject: try auto-mounting ubi0:rootfs in init/do_mounts.c
  3. Signed-off-by: Daniel Golle <[email protected]>
  4. ---
  5. init/do_mounts.c | 26 +++++++++++++++++++++++++-
  6. 1 file changed, 25 insertions(+), 1 deletion(-)
  7. --- a/init/do_mounts.c
  8. +++ b/init/do_mounts.c
  9. @@ -446,7 +446,30 @@ retry:
  10. out:
  11. put_page(page);
  12. }
  13. -
  14. +
  15. +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
  16. +static int __init mount_ubi_rootfs(void)
  17. +{
  18. + int flags = MS_SILENT;
  19. + int err, tried = 0;
  20. +
  21. + while (tried < 2) {
  22. + err = do_mount_root("ubi0:rootfs", "ubifs", flags, \
  23. + root_mount_data);
  24. + switch (err) {
  25. + case -EACCES:
  26. + flags |= MS_RDONLY;
  27. + tried++;
  28. + break;
  29. + default:
  30. + return err;
  31. + }
  32. + }
  33. +
  34. + return -EINVAL;
  35. +}
  36. +#endif
  37. +
  38. #ifdef CONFIG_ROOT_NFS
  39. #define NFSROOT_TIMEOUT_MIN 5
  40. @@ -579,6 +602,10 @@ void __init mount_root(void)
  41. return;
  42. }
  43. #endif
  44. +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
  45. + if (!mount_ubi_rootfs())
  46. + return;
  47. +#endif
  48. if (ROOT_DEV == 0 && root_device_name && root_fs_names) {
  49. if (mount_nodev_root() == 0)
  50. return;