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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. @@ -248,7 +248,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. @@ -385,6 +408,11 @@ static inline void mount_block_root(char
  41. void __init mount_root(char *root_device_name)
  42. {
  43. +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
  44. + if (!mount_ubi_rootfs())
  45. + return;
  46. +#endif
  47. +
  48. switch (ROOT_DEV) {
  49. case Root_NFS:
  50. mount_nfs_root();