75a0bc02cac1774d78d7b98dc98a2ecbffe6c449
[openwrt.git] / target / linux / generic / patches-3.14 / 492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch
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
7 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
8 ---
9  init/do_mounts.c | 26 +++++++++++++++++++++++++-
10  1 file changed, 25 insertions(+), 1 deletion(-)
11
12 diff --git a/init/do_mounts.c b/init/do_mounts.c
13 index 82f2288..faba9c6 100644
14 --- a/init/do_mounts.c
15 +++ b/init/do_mounts.c
16 @@ -432,7 +432,27 @@ retry:
17  out:
18         put_page(page);
19  }
20
21 +
22 +static int __init mount_ubi_rootfs(void)
23 +{
24 +       int flags = MS_SILENT;
25 +       int err, tried = 0;
26 +
27 +       while (tried < 2) {
28 +               err = do_mount_root("ubi0:rootfs", "ubifs", flags, \
29 +                                       root_mount_data);
30 +               switch (err) {
31 +                       case -EACCES:
32 +                               flags |= MS_RDONLY;
33 +                               tried++;
34 +                       default:
35 +                               return err;
36 +               }
37 +       }
38 +
39 +       return -EINVAL;
40 +}
41 +
42  #ifdef CONFIG_ROOT_NFS
43  
44  #define NFSROOT_TIMEOUT_MIN    5
45 @@ -526,6 +546,10 @@ void __init mount_root(void)
46                         change_floppy("root floppy");
47         }
48  #endif
49 +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
50 +       if (!mount_ubi_rootfs())
51 +               return;
52 +#endif
53  #ifdef CONFIG_BLOCK
54         create_dev("/dev/root", ROOT_DEV);
55         mount_block_root("/dev/root", root_mountflags);
56 -- 
57 1.9.2
58