summaryrefslogtreecommitdiff
path: root/serverboot
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-10-28 20:51:36 +0000
committerRoland McGrath <roland@gnu.org>1999-10-28 20:51:36 +0000
commitf2d5c57fd1204abeba9743159fd9aa9a0baa8069 (patch)
tree8a186e2ec82290568ae348a5a7c8f8fc1067ba08 /serverboot
parent54798bc817bdce192b874db8541bb73c6fb7a2ad (diff)
1999-10-28 Roland McGrath <roland@baalperazim.frob.com>
* file_io.h: Include <errno.h>. (FS_* macros): Define these to equivalent errno codes. * def_pager_setup.c (add_paging_file): Put strerror of result code in error messages. * bootstrap.c (parse_script): Likewise. * load.c (boot_script_exec_cmd): Include NAMEBUF in error messages, and use strerror to format result code. * panic.c (panic): Use program_invocation_name in message.
Diffstat (limited to 'serverboot')
-rw-r--r--serverboot/bootstrap.c35
-rw-r--r--serverboot/def_pager_setup.c5
-rw-r--r--serverboot/file_io.h21
-rw-r--r--serverboot/load.c18
-rw-r--r--serverboot/panic.c15
5 files changed, 67 insertions, 27 deletions
diff --git a/serverboot/bootstrap.c b/serverboot/bootstrap.c
index f6d6050a..41fe7591 100644
--- a/serverboot/bootstrap.c
+++ b/serverboot/bootstrap.c
@@ -29,6 +29,7 @@
#include <mach.h>
#include <mach/message.h>
+#include <sys/reboot.h>
#include <file_io.h>
@@ -112,8 +113,12 @@ boot_panic (kern_return_t err)
void
safe_gets (char *str, int maxlen)
{
- char *c;
- c = strchr (fgets (str, maxlen, stdin), '\n');
+ char *c = fgets (str, maxlen, stdin);
+ if (c == 0) {
+ perror ("fgets");
+ panic ("cannot read from console");
+ }
+ c = strchr (c, '\n');
if (c)
*c = '\0';
printf ("\r\n");
@@ -122,7 +127,14 @@ safe_gets (char *str, int maxlen)
printf_init (device_t master)
{
mach_port_t cons;
- device_open (master, D_READ|D_WRITE, "console", &cons);
+ kern_return_t rc;
+ rc = device_open (master, D_READ|D_WRITE, "console", &cons);
+ if (rc)
+ while (1) {
+ volatile int x = 0;
+ (void) host_reboot(bootstrap_master_host_port, RB_DEBUGGER);
+ x = x / x;
+ }
stdin = mach_open_devstream (cons, "r");
stdout = stderr = mach_open_devstream (cons, "w");
mach_port_deallocate (mach_task_self (), cons);
@@ -224,22 +236,22 @@ main(argc, argv)
&bootstrap_master_device_port);
}
-
-
-
printf_init(bootstrap_master_device_port);
#ifdef pleasenoXXX
panic_init(bootstrap_master_host_port);
#endif
+ printf ("serverboot flags %s root=%s\n", flag_string, root_name);
+
+
/*
- * If the '-a' (ask) switch was specified, or if no
+ * If the '-a' (ask) switch was specified, or if no
* root device was specificed, ask for the root device.
*/
if (!root_name || root_name [0] == '\0' || index(flag_string, 'a')) {
- static char new_root[16];
-
+ static char new_root[MAXPATHLEN/2];
+
printf("root device? [%s] ", root_name);
safe_gets(new_root, sizeof(new_root));
@@ -431,8 +443,9 @@ parse_script (struct file *f)
int n = 0;
buf = malloc (f->f_size + 1); /* add one for null terminator we will write */
- if (read_file (f, 0, buf, f->f_size, 0))
- panic ("bootstrap: error reading boot script file");
+ err = read_file (f, 0, buf, f->f_size, 0);
+ if (err)
+ panic ("bootstrap: error reading boot script file: %s", strerror (err));
line = p = buf;
while (1)
diff --git a/serverboot/def_pager_setup.c b/serverboot/def_pager_setup.c
index 194f0355..8834a379 100644
--- a/serverboot/def_pager_setup.c
+++ b/serverboot/def_pager_setup.c
@@ -58,11 +58,12 @@ add_paging_file(master_device_port, file_name, linux_signature)
result = open_file_direct(pfile.f_dev, fdp, isa_file);
if (result)
- panic("Can't open paging file %s\n", file_name);
+ panic("Can't open paging file %s: %s\n",
+ file_name, strerror (result));
result = add_file_direct(fdp, &pfile);
if (result)
- panic("Can't read disk addresses: %d\n", result);
+ panic("Can't read disk addresses: %s\n", strerror (result));
close_file(&pfile);
diff --git a/serverboot/file_io.h b/serverboot/file_io.h
index 5706ce5b..8a1a6e34 100644
--- a/serverboot/file_io.h
+++ b/serverboot/file_io.h
@@ -162,13 +162,30 @@ extern int page_write_file_direct();
* Error codes for file system errors.
*/
+#include <errno.h>
+
+/* Just use the damn Hurd error numbers. This is old CMU/Utah code from
+ the days of personality-independent Mach where it made sense for this to
+ be a standalone universe. In the Hurd, we compile serverboot against
+ the regular C library anyway. */
+
+#define FS_NOT_DIRECTORY ENOTDIR
+#define FS_NO_ENTRY ENOENT
+#define FS_NAME_TOO_LONG ENAMETOOLONG
+#define FS_SYMLINK_LOOP ELOOP
+#define FS_INVALID_FS EFTYPE /* ? */
+#define FS_NOT_IN_FILE EINVAL
+#define FS_INVALID_PARAMETER EINVAL
+
+#if 0
#define FS_NOT_DIRECTORY 5000 /* not a directory */
#define FS_NO_ENTRY 5001 /* name not found */
#define FS_NAME_TOO_LONG 5002 /* name too long */
#define FS_SYMLINK_LOOP 5003 /* symbolic link loop */
#define FS_INVALID_FS 5004 /* bad file system */
#define FS_NOT_IN_FILE 5005 /* offset not in file */
-#define FS_INVALID_PARAMETER 5006 /* bad parameter to
- a routine */
+#define FS_INVALID_PARAMETER 5006 /* bad parameter to routine */
+#endif
+
#endif /* _FILE_IO_H_ */
diff --git a/serverboot/load.c b/serverboot/load.c
index 3898eac6..a4f48ba3 100644
--- a/serverboot/load.c
+++ b/serverboot/load.c
@@ -273,7 +273,7 @@ boot_script_exec_cmd (task_t user_task,
result = open_file(bootstrap_master_device_port, namebuf, &file);
if (result != 0) {
- panic("openi %d", result);
+ panic ("%s: %s", namebuf, strerror (result));
}
env_len = 0;
@@ -308,6 +308,7 @@ boot_script_exec_cmd (task_t user_task,
st.user_task = user_task;
st.aout_symtab_size = 0;
st.aout_strtab_size = 0;
+printf("serverboot loading %s\n", file_name);
result = exec_load(prog_read, prog_read_exec, &st, &info);
#ifdef GZIP
if (result)
@@ -360,7 +361,7 @@ boot_script_exec_cmd (task_t user_task,
}
#endif BZIP2
if (result)
- panic("(serverboot) exec_load %s: error %d", namebuf, result);
+ panic ("cannot load %s: %s", namebuf, strerror (result));
#if 0
printf("(serverboot): loaded %s; entrypoint %08x\n", namebuf, info.entry);
#endif
@@ -370,9 +371,11 @@ boot_script_exec_cmd (task_t user_task,
*/
result = thread_create (user_task, &user_thread);
if (result)
- panic ("can't create user thread for %s: %x", namebuf, result);
+ panic ("can't create user thread for %s: %s", namebuf,
+ strerror (result));
arg_pos = set_regs(user_task, user_thread, &info, arg_len);
+printf("set up user thread\n");
/*
* Read symbols from the executable file.
*/
@@ -451,15 +454,19 @@ boot_script_exec_cmd (task_t user_task,
/*
* Then the strings and string pointers for each argument
*/
- for (i = 0; i < arg_count; i++)
+ for (i = 0; i < arg_count; i++) {
+ printf("\targv[%d] = %s\n", i, argv[i]);
*k_ap++ = argv[i] - argstrings + u_cp;
+ }
*k_ap++ = (char *)0;
bcopy (argstrings, k_cp, argslen);
k_cp += argslen;
u_cp += argslen;
- for (i = 0; i < envc; i++)
+ for (i = 0; i < envc; i++) {
+ printf("\tenviron[%d] = %s\n", i, environ[i]);
*k_ap++ = environ[i] - environ[0] + u_cp;
+ }
*k_ap = (char *)0;
bcopy (environ[0], k_cp, env_len);
@@ -481,6 +488,7 @@ boot_script_exec_cmd (task_t user_task,
*/
close_file(&file);
+printf ("resume user thread...\n");
/* Resume the thread. */
thread_resume (user_thread);
mach_port_deallocate (mach_task_self (), user_thread);
diff --git a/serverboot/panic.c b/serverboot/panic.c
index 80197500..87428429 100644
--- a/serverboot/panic.c
+++ b/serverboot/panic.c
@@ -1,25 +1,25 @@
-/*
+/*
* Mach Operating System
* Copyright (c) 1991,1990,1989 Carnegie Mellon University
* All Rights Reserved.
- *
+ *
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
- *
+ *
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
+ *
* Carnegie Mellon requests users of this software to return to
- *
+ *
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
- *
+ *
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
@@ -27,6 +27,7 @@
#include <mach/port.h>
#include <varargs.h>
#include <stdio.h>
+#include <errno.h>
static mach_port_t master_host_port;
@@ -44,7 +45,7 @@ panic(s, va_alist)
va_list listp;
clearerr (stdout);
- printf("bootstrap/default-pager panic: ");
+ printf("%s: panic: ", program_invocation_name);
va_start(listp);
vprintf(s, listp);
va_end(listp);