1 |
vapier 12/05/01 04:17:37 |
2 |
|
3 |
Modified: ginit.c |
4 |
Log: |
5 |
Use mountpoint rather than reading /proc/mounts to avoid needing to mount /proc at all as pointed out by Maxim Kammerer. |
6 |
|
7 |
(Portage version: 2.2.0_alpha100/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.2 sys-apps/busybox/files/ginit.c |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/busybox/files/ginit.c?rev=1.2&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/busybox/files/ginit.c?rev=1.2&content-type=text/plain |
14 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/busybox/files/ginit.c?r1=1.1&r2=1.2 |
15 |
|
16 |
Index: ginit.c |
17 |
=================================================================== |
18 |
RCS file: /var/cvsroot/gentoo-x86/sys-apps/busybox/files/ginit.c,v |
19 |
retrieving revision 1.1 |
20 |
retrieving revision 1.2 |
21 |
diff -u -r1.1 -r1.2 |
22 |
--- ginit.c 30 Apr 2012 01:59:09 -0000 1.1 |
23 |
+++ ginit.c 1 May 2012 04:17:37 -0000 1.2 |
24 |
@@ -13,6 +13,10 @@ |
25 |
//config:config GINIT |
26 |
//config: bool "ginit" |
27 |
//config: default y |
28 |
+//config: select MKDIR |
29 |
+//config: select MDEV |
30 |
+//config: select MOUNT |
31 |
+//config: select MOUNTPOINT |
32 |
//config: help |
33 |
//config: sep-/usr bootstrapper |
34 |
|
35 |
@@ -60,7 +64,7 @@ |
36 |
return spawn_and_wait(argv+1); |
37 |
} |
38 |
|
39 |
-#define _spawn_and_wait(argv...) \ |
40 |
+#define saw(argv...) \ |
41 |
({ \ |
42 |
static const char *args[] = { argv, NULL }; \ |
43 |
/* These casts are fine -- see process_args for mem setup */ \ |
44 |
@@ -68,53 +72,35 @@ |
45 |
spawn_and_wait((void *)args); \ |
46 |
}) |
47 |
|
48 |
- /* We need /proc in order to see what's already been mounted */ |
49 |
- if (access("/proc/mounts", F_OK) != 0) { |
50 |
- if (_spawn_and_wait("mount", "-n", "/proc")) |
51 |
- _spawn_and_wait("mount", "-n", "-t", "proc", "proc", "/proc"); |
52 |
- } |
53 |
- |
54 |
- /* Look up all the existing mount points */ |
55 |
- ismnted_dev = ismnted_sys = ismnted_usr = false; |
56 |
- mntlist = setmntent("/proc/mounts", "re"); |
57 |
- if (mntlist) { |
58 |
- while ((mntent = getmntent(mntlist))) { |
59 |
- if (!strcmp(mntent->mnt_dir, "/dev")) |
60 |
- ismnted_dev = true; |
61 |
- else if (!strcmp(mntent->mnt_dir, "/sys")) |
62 |
- ismnted_sys = true; |
63 |
- else if (!strcmp(mntent->mnt_dir, "/usr")) |
64 |
- ismnted_usr = true; |
65 |
- } |
66 |
- endmntent(mntlist); |
67 |
- } |
68 |
- |
69 |
/* First setup basic /dev */ |
70 |
- if (!ismnted_dev) { |
71 |
- if (_spawn_and_wait("mount", "-n", "/dev")) |
72 |
- if (_spawn_and_wait("mount", "-n", "-t", "devtmpfs", "devtmpfs", "/dev")) |
73 |
- _spawn_and_wait("mount", "-n", "-t", "tmpfs", "dev", "/dev"); |
74 |
+ if (saw("mountpoint", "-q", "/dev") != 0) { |
75 |
+ /* Try /etc/fstab */ |
76 |
+ if (saw("mount", "-n", "/dev")) |
77 |
+ /* Then devtmpfs */ |
78 |
+ if (saw("mount", "-n", "-t", "devtmpfs", "devtmpfs", "/dev")) |
79 |
+ /* Finally normal tmpfs */ |
80 |
+ saw("mount", "-n", "-t", "tmpfs", "dev", "/dev"); |
81 |
} else { |
82 |
eprintf("%s appears to be mounted; skipping its setup\n", "/dev"); |
83 |
} |
84 |
|
85 |
/* If /dev is empty (e.g. tmpfs), run mdev to seed things */ |
86 |
if (access("/dev/console", F_OK) != 0) { |
87 |
- if (!ismnted_sys) { |
88 |
- if (_spawn_and_wait("mount", "-n", "/sys")) |
89 |
- _spawn_and_wait("mount", "-n", "-t", "sysfs", "sysfs", "/sys"); |
90 |
+ if (saw("mountpoint", "-q", "/sys") != 0) { |
91 |
+ if (saw("mount", "-n", "/sys")) |
92 |
+ saw("mount", "-n", "-t", "sysfs", "sysfs", "/sys"); |
93 |
} else { |
94 |
eprintf("%s appears to be mounted; skipping its setup\n", "/sys"); |
95 |
} |
96 |
- _spawn_and_wait("mdev", "-s"); |
97 |
+ saw("mdev", "-s"); |
98 |
} |
99 |
|
100 |
/* Then seed the stuff we care about */ |
101 |
- _spawn_and_wait("mkdir", "-p", "/dev/pts", "/dev/shm"); |
102 |
+ saw("mkdir", "-p", "/dev/pts", "/dev/shm"); |
103 |
|
104 |
/* Then mount /usr */ |
105 |
- if (!ismnted_usr) { |
106 |
- _spawn_and_wait("mount", "-n", "/usr", "-o", "ro"); |
107 |
+ if (saw("mountpoint", "-q", "/usr") != 0) { |
108 |
+ saw("mount", "-n", "/usr", "-o", "ro"); |
109 |
} else { |
110 |
eprintf("%s appears to be mounted; skipping its setup\n", "/usr"); |
111 |
} |