1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
From 1c0dc88f5411451ba1acd7e41a5d362fdd947586 Mon Sep 17 00:00:00 2001
From: Justus Winter <justus@gnupg.org>
Date: Tue, 26 Apr 2016 18:01:41 +0200
Subject: [PATCH hurd 3/5] startup: add verbose parameter
* startup/startup.c: Add verbose parameter and inform about progress
through the bootstrap procedure if it is given.
---
startup/startup.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 65 insertions(+), 8 deletions(-)
diff --git a/startup/startup.c b/startup/startup.c
index 97a1bab..f3e3534 100644
--- a/startup/startup.c
+++ b/startup/startup.c
@@ -65,6 +65,8 @@
/* host_reboot flags for when we crash. */
static int crash_flags = RB_AUTOBOOT;
+static int verbose = 0;
+
#define BOOT(flags) ((flags & RB_HALT) ? "halt" : "reboot")
@@ -79,6 +81,7 @@ options[] =
{"crash-debug", 'H', 0, 0, "On system crash, go to kernel debugger"},
{"debug", 'd', 0, 0 },
{"fake-boot", 'f', 0, 0, "This hurd hasn't been booted on the raw machine"},
+ {"verbose", 'v', 0, 0, "be verbose"},
{0, 'x', 0, OPTION_HIDDEN},
{0}
};
@@ -401,10 +404,8 @@ run (const char *server, mach_port_t *ports, task_t *task)
crash_system ();
}
-#if 0
- printf ("started %s\n", prog);
- fflush (stdout);
-#endif
+ if (verbose)
+ fprintf (stderr, "started %s\n", prog);
/* Dead-name notification on the task port will tell us when it dies,
so we can crash if we don't make it to a fully bootstrapped Hurd. */
@@ -539,6 +540,9 @@ demuxer (mach_msg_header_t *inp,
{
mig_routine_t routine;
+ if (verbose > 1)
+ error (0, 0, "%d", inp->msgh_id);
+
mig_reply_setup (inp, outp);
if ((routine = notify_server_routine (inp)) ||
@@ -549,6 +553,9 @@ demuxer (mach_msg_header_t *inp,
(routine = startup_server_routine (inp)))
{
(*routine) (inp, outp);
+
+ if (verbose > 1)
+ error (0, ((mig_reply_header_t *) outp)->RetCode, "%d", inp->msgh_id);
return TRUE;
}
else
@@ -592,6 +599,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
case 'n': bootstrap_args |= RB_INITNAME; break;
case 'f': fakeboot = 1; break;
case 'H': crash_flags = RB_DEBUGGER; break;
+ case 'v': verbose++; break;
case 'x': /* NOP */ break;
default: return ARGP_ERR_UNKNOWN;
}
@@ -705,6 +713,9 @@ launch_core_servers (void)
mach_port_t authproc, fsproc, procproc;
error_t err;
+ if (verbose)
+ fprintf (stderr, "Launching core servers\n");
+
/* Reply to the proc and auth servers. */
err = startup_procinit_reply (procreply, procreplytype, 0,
mach_task_self (), authserver,
@@ -717,6 +728,9 @@ launch_core_servers (void)
device_master = 0;
}
+ if (verbose)
+ fprintf (stderr, "proc launched\n");
+
/* Mark us as important. */
err = proc_mark_important (procserver);
assert_perror (err);
@@ -741,12 +755,18 @@ launch_core_servers (void)
/* Good luck. Who knows, maybe it's an old installation. */
error (0, err, "Failed to bind to " _SERVERS_STARTUP);
+ if (verbose)
+ fprintf (stderr, "Installed on /servers/startup\n");
+
err = startup_authinit_reply (authreply, authreplytype, 0, authproc,
MACH_MSG_TYPE_COPY_SEND);
assert_perror (err);
err = mach_port_deallocate (mach_task_self (), authproc);
assert_perror (err);
+ if (verbose)
+ fprintf (stderr, "auth launched\n");
+
/* Give the library our auth and proc server ports. */
_hurd_port_set (&_hurd_ports[INIT_PORT_AUTH], authserver);
_hurd_port_set (&_hurd_ports[INIT_PORT_PROC], procserver);
@@ -785,10 +805,6 @@ launch_core_servers (void)
err = proc_mark_exec (fsproc);
assert_perror (err);
-#if 0
- printf ("Init has completed.\n");
- fflush (stdout);
-#endif
printf (".\n");
fflush (stdout);
@@ -803,11 +819,17 @@ launch_core_servers (void)
if (old != MACH_PORT_NULL)
mach_port_deallocate (mach_task_self (), old);
+ if (verbose)
+ fprintf (stderr, "Message port registered\n");
+
/* Give the bootstrap FS its proc and auth ports. */
err = fsys_init (bootport, fsproc, MACH_MSG_TYPE_COPY_SEND, authserver);
mach_port_deallocate (mach_task_self (), fsproc);
if (err)
error (0, err, "fsys_init"); /* Not necessarily fatal. */
+
+ if (verbose)
+ fprintf (stderr, "Fixed up bootstrap filesystem\n");
}
/* Set up the initial value of the standard exec data. */
@@ -874,6 +896,9 @@ frob_kernel_process (void)
task_t task;
process_t proc, kbs;
+ if (verbose)
+ fprintf (stderr, "Frobbing kernel process\n");
+
err = proc_pid2task (procserver, HURD_PID_KERNEL, &task);
if (err)
{
@@ -1094,6 +1119,9 @@ start_child (const char *prog, char **progargs)
}
assert_perror (err);
+ if (verbose)
+ fprintf (stderr, "Going to execute '%s'\n", args);
+
file = file_name_lookup (args, O_EXEC, 0);
if (file == MACH_PORT_NULL)
{
@@ -1180,6 +1208,9 @@ void
launch_system (void)
{
launch_something (0);
+
+ if (verbose)
+ fprintf (stderr, "Init has completed\n");
}
/** RPC servers **/
@@ -1200,6 +1231,9 @@ S_startup_procinit (startup_t server,
/* Only one proc server. */
return EPERM;
+ if (verbose)
+ fprintf (stderr, "Received startup message from proc\n");
+
procserver = proc;
procreply = reply;
@@ -1226,6 +1260,9 @@ S_startup_authinit (startup_t server,
/* Only one auth server. */
return EPERM;
+ if (verbose)
+ fprintf (stderr, "Received startup message from auth\n");
+
authserver = auth;
/* Save the reply port until we get startup_procinit. */
@@ -1258,6 +1295,10 @@ S_startup_essential_task (mach_port_t server,
if (credential != host_priv)
return EPERM;
+ if (verbose)
+ fprintf (stderr, "Received startup essential message from '%s'\n",
+ name);
+
fail = record_essential_task (name, task);
if (fail)
return fail;
@@ -1276,8 +1317,13 @@ S_startup_essential_task (mach_port_t server,
else if (!strcmp (name, "proc"))
procinit = 1;
+ if (verbose)
+ fprintf (stderr, " still waiting for:");
+
if (authinit && execinit && procinit)
{
+ if (verbose)
+ fprintf (stderr, " none!\n");
/* Reply to this RPC, after that everything
is ready for real startup to begin. */
startup_essential_task_reply (reply, replytype, 0);
@@ -1291,6 +1337,17 @@ S_startup_essential_task (mach_port_t server,
return MIG_NO_REPLY;
}
+
+ if (verbose)
+ {
+ if (! authinit)
+ fprintf (stderr, " auth");
+ if (! execinit)
+ fprintf (stderr, " exec");
+ if (! procinit)
+ fprintf (stderr, " proc");
+ fprintf (stderr, "\n");
+ }
}
return 0;
--
2.1.4
|