wok-next view linux/stuff/linux-subroot.u @ rev 14759

linux: add boot subroot support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jun 19 11:43:07 2013 +0200 (2013-06-19)
parents
children 4d48f8048d15
line source
1 Allow to boot on any directories in a filesystem
2 --- linux-3.2.40/Documentation/kernel-parameters.txt
3 +++ linux-3.2.40/Documentation/kernel-parameters.txt
4 @@ -2304,8 +2304,9 @@
6 ro [KNL] Mount root device read-only on boot
8 - root= [KNL] Root filesystem
9 + root= [KNL] Root filesystem and root directory
10 See name_to_dev_t comment in init/do_mounts.c.
11 + Format: <root_filesystem>[:root_directory]
13 rootdelay= [KNL] Delay (in seconds) to pause before attempting to
14 mount the root filesystem
15 --- linux-3.2.40/init/do_mounts.c
16 +++ linux-3.2.40/init/do_mounts.c
17 @@ -28,6 +28,7 @@
18 int root_mountflags = MS_RDONLY | MS_SILENT;
19 static char * __initdata root_device_name;
20 static char __initdata saved_root_name[64];
21 +static char __initdata saved_root_directory[256];
22 static int root_wait;
24 dev_t ROOT_DEV;
25 @@ -255,7 +256,20 @@
27 static int __init root_dev_setup(char *line)
28 {
29 + char *s;
30 +
31 + strcpy(saved_root_directory, ".");
32 strlcpy(saved_root_name, line, sizeof(saved_root_name));
33 + s = strchr(saved_root_name, ':');
34 + if (s) {
35 + *s = '\0';
36 + s = strchr(line, ':');
37 + for (s++; *s == '/'; s++);
38 + if (*s) {
39 + strlcpy(saved_root_directory, s,
40 + sizeof(saved_root_directory));
41 + }
42 + }
43 return 1;
44 }
46 @@ -554,5 +568,5 @@
47 out:
48 devtmpfs_mount("dev");
49 sys_mount(".", "/", NULL, MS_MOVE, NULL);
50 - sys_chroot((const char __user __force *)".");
51 + sys_chroot((const char __user __force *)saved_root_directory);
52 }