summaryrefslogtreecommitdiffstats
path: root/sys/boot
diff options
context:
space:
mode:
authorsmh <smh@FreeBSD.org>2016-01-28 12:23:25 +0000
committersmh <smh@FreeBSD.org>2016-01-28 12:23:25 +0000
commita3f6e8577156792c9839bea3861eedf076da78b2 (patch)
treeb3c0c3f68298e9ad203a0996bbc1d4871c188dbd /sys/boot
parent74468e18e88bab67e6156ce77460505c1ebf4df0 (diff)
downloadFreeBSD-src-a3f6e8577156792c9839bea3861eedf076da78b2.zip
FreeBSD-src-a3f6e8577156792c9839bea3861eedf076da78b2.tar.gz
MFC r293835:
Improve non-interactive forth cmd error reporting Sponsored by: Multiplay
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/common/bootstrap.h5
-rw-r--r--sys/boot/common/interp_forth.c12
-rw-r--r--sys/boot/common/module.c31
3 files changed, 37 insertions, 11 deletions
diff --git a/sys/boot/common/bootstrap.h b/sys/boot/common/bootstrap.h
index ef08799..8804f01 100644
--- a/sys/boot/common/bootstrap.h
+++ b/sys/boot/common/bootstrap.h
@@ -56,7 +56,10 @@ typedef int (bootblk_cmd_t)(int argc, char *argv[]);
extern char *command_errmsg;
extern char command_errbuf[]; /* XXX blah, length */
#define CMD_OK 0
-#define CMD_ERROR 1
+#define CMD_WARN 1
+#define CMD_ERROR 2
+#define CMD_CRIT 3
+#define CMD_FATAL 4
/* interp.c */
void interact(void);
diff --git a/sys/boot/common/interp_forth.c b/sys/boot/common/interp_forth.c
index 1c37e2b..d5d1a55f 100644
--- a/sys/boot/common/interp_forth.c
+++ b/sys/boot/common/interp_forth.c
@@ -138,13 +138,23 @@ bf_command(FICL_VM *vm)
} else {
result=BF_PARSE;
}
+
+ switch (result) {
+ case CMD_CRIT:
+ printf("%s\n", command_errmsg);
+ break;
+ case CMD_FATAL:
+ panic("%s\n", command_errmsg);
+ }
+
free(line);
/*
* If there was error during nested ficlExec(), we may no longer have
* valid environment to return. Throw all exceptions from here.
*/
- if (result != 0)
+ if (result != CMD_OK)
vmThrow(vm, result);
+
/* This is going to be thrown!!! */
stackPushINT(vm->pStack,result);
}
diff --git a/sys/boot/common/module.c b/sys/boot/common/module.c
index 0fc970a..52406ef 100644
--- a/sys/boot/common/module.c
+++ b/sys/boot/common/module.c
@@ -111,7 +111,7 @@ command_load(int argc, char *argv[])
typestr = NULL;
if (argc == 1) {
command_errmsg = "no filename specified";
- return(CMD_ERROR);
+ return (CMD_CRIT);
}
while ((ch = getopt(argc, argv, "kt:")) != -1) {
switch(ch) {
@@ -125,7 +125,7 @@ command_load(int argc, char *argv[])
case '?':
default:
/* getopt has already reported an error */
- return(CMD_OK);
+ return (CMD_OK);
}
}
argv += (optind - 1);
@@ -137,33 +137,46 @@ command_load(int argc, char *argv[])
if (dofile) {
if ((argc != 2) || (typestr == NULL) || (*typestr == 0)) {
command_errmsg = "invalid load type";
- return(CMD_ERROR);
+ return (CMD_CRIT);
}
fp = file_findfile(argv[1], typestr);
if (fp) {
sprintf(command_errbuf, "warning: file '%s' already loaded", argv[1]);
- return (CMD_ERROR);
+ return (CMD_WARN);
}
- return (file_loadraw(argv[1], typestr, 1) ? CMD_OK : CMD_ERROR);
+ if (file_loadraw(argv[1], typestr, 1) != NULL)
+ return (CMD_OK);
+
+ /* Failing to load mfs_root is never going to end well! */
+ if (strcmp("mfs_root", typestr) == 0)
+ return (CMD_FATAL);
+
+ return (CMD_ERROR);
}
/*
* Do we have explicit KLD load ?
*/
if (dokld || file_havepath(argv[1])) {
error = mod_loadkld(argv[1], argc - 2, argv + 2);
- if (error == EEXIST)
+ if (error == EEXIST) {
sprintf(command_errbuf, "warning: KLD '%s' already loaded", argv[1]);
- return (error == 0 ? CMD_OK : CMD_ERROR);
+ return (CMD_WARN);
+ }
+
+ return (error == 0 ? CMD_OK : CMD_CRIT);
}
/*
* Looks like a request for a module.
*/
error = mod_load(argv[1], NULL, argc - 2, argv + 2);
- if (error == EEXIST)
+ if (error == EEXIST) {
sprintf(command_errbuf, "warning: module '%s' already loaded", argv[1]);
- return (error == 0 ? CMD_OK : CMD_ERROR);
+ return (CMD_WARN);
+ }
+
+ return (error == 0 ? CMD_OK : CMD_CRIT);
}
COMMAND_SET(load_geli, "load_geli", "load a geli key", command_load_geli);
OpenPOWER on IntegriCloud