005de3fcae4a54c5dd5aada2bfba95db3af65d05
[openwrt/openwrt.git] / target / linux / generic / patches-4.1 / 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 --- a/init/do_mounts.c
13 +++ b/init/do_mounts.c
14 @@ -438,7 +438,27 @@ retry:
15 out:
16 put_page(page);
17 }
18 -
19 +
20 +static int __init mount_ubi_rootfs(void)
21 +{
22 + int flags = MS_SILENT;
23 + int err, tried = 0;
24 +
25 + while (tried < 2) {
26 + err = do_mount_root("ubi0:rootfs", "ubifs", flags, \
27 + root_mount_data);
28 + switch (err) {
29 + case -EACCES:
30 + flags |= MS_RDONLY;
31 + tried++;
32 + default:
33 + return err;
34 + }
35 + }
36 +
37 + return -EINVAL;
38 +}
39 +
40 #ifdef CONFIG_ROOT_NFS
41
42 #define NFSROOT_TIMEOUT_MIN 5
43 @@ -532,6 +552,10 @@ void __init mount_root(void)
44 change_floppy("root floppy");
45 }
46 #endif
47 +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
48 + if (!mount_ubi_rootfs())
49 + return;
50 +#endif
51 #ifdef CONFIG_BLOCK
52 create_dev("/dev/root", ROOT_DEV);
53 mount_block_root("/dev/root", root_mountflags);