f95ec46f14eb5b046104981e5e207d618d4a6b9f
[openwrt/staging/stintel.git] / target / linux / generic / pending-6.6 / 492-try-auto-mounting-ubi0-rootfs-in-init-do_mounts.c.patch
1 From: Daniel Golle <daniel@makrotopia.org>
2 Subject: try auto-mounting ubi0:rootfs in init/do_mounts.c
3
4 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
5 ---
6 init/do_mounts.c | 26 +++++++++++++++++++++++++-
7 1 file changed, 25 insertions(+), 1 deletion(-)
8
9 --- a/init/do_mounts.c
10 +++ b/init/do_mounts.c
11 @@ -446,7 +446,30 @@ retry:
12 out:
13 put_page(page);
14 }
15 -
16 +
17 +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
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 + break;
31 + default:
32 + return err;
33 + }
34 + }
35 +
36 + return -EINVAL;
37 +}
38 +#endif
39 +
40 #ifdef CONFIG_ROOT_NFS
41
42 #define NFSROOT_TIMEOUT_MIN 5
43 @@ -579,6 +602,10 @@ void __init mount_root(void)
44 return;
45 }
46 #endif
47 +#ifdef CONFIG_MTD_ROOTFS_ROOT_DEV
48 + if (!mount_ubi_rootfs())
49 + return;
50 +#endif
51 if (ROOT_DEV == 0 && root_device_name && root_fs_names) {
52 if (mount_nodev_root() == 0)
53 return;