diff options
author | trasz <trasz@FreeBSD.org> | 2015-08-03 16:27:36 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2015-08-03 16:27:36 +0000 |
commit | d8303f2c351fc5c1bb4b9717ed9370709a503030 (patch) | |
tree | f8868a0d6e5250ba76ce4fa1e0a8e21866c99bc7 /sys/boot | |
parent | bf7c25adeb83528956eddf557b8dfc7ce7352ef3 (diff) | |
download | FreeBSD-src-d8303f2c351fc5c1bb4b9717ed9370709a503030.zip FreeBSD-src-d8303f2c351fc5c1bb4b9717ed9370709a503030.tar.gz |
Fix a problem which made loader(8) load non-kld files twice.
For example, without this patch, the following three lines
in /boot/loader.conf would result in /boot/root.img being preloaded
twice, and two md(4) devices - md0 and md1 - being created.
initmd_load="YES"
initmd_type="md_image"
initmd_name="/boot/root.img"
Reviewed by: marcel@
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3204
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/common/module.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/boot/common/module.c b/sys/boot/common/module.c index b48b493..163814b 100644 --- a/sys/boot/common/module.c +++ b/sys/boot/common/module.c @@ -102,6 +102,7 @@ COMMAND_SET(load, "load", "load a kernel or module", command_load); static int command_load(int argc, char *argv[]) { + struct preloaded_file *fp; char *typestr; int dofile, dokld, ch, error; @@ -139,6 +140,13 @@ command_load(int argc, char *argv[]) command_errmsg = "invalid load type"; return(CMD_ERROR); } + + fp = file_findfile(argv[1], typestr); + if (fp) { + sprintf(command_errbuf, "warning: file '%s' already loaded", argv[1]); + return (CMD_ERROR); + } + return (file_loadraw(argv[1], typestr, 1) ? CMD_OK : CMD_ERROR); } /* |