From ca0a6da1a233b2e8880d55083793fcecff79cf4f Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Wed, 6 Aug 2014 00:06:25 +0000 Subject: [PATCH] Rename command_unload() to unload() and re-implement command_unload() in terms of unload() This allows unloading all files by the loader itself. Obtained from: Juniper Networks, Inc. --- sys/boot/common/bootstrap.h | 1 + sys/boot/common/module.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sys/boot/common/bootstrap.h b/sys/boot/common/bootstrap.h index 3d76540826ef..eec1b3bd9b29 100644 --- a/sys/boot/common/bootstrap.h +++ b/sys/boot/common/bootstrap.h @@ -229,6 +229,7 @@ extern struct preloaded_file *preloaded_files; int mod_load(char *name, struct mod_depend *verinfo, int argc, char *argv[]); int mod_loadkld(const char *name, int argc, char *argv[]); +void unload(void); struct preloaded_file *file_alloc(void); struct preloaded_file *file_findfile(char *name, char *type); diff --git a/sys/boot/common/module.c b/sys/boot/common/module.c index dd14c762554a..e1170bbd6fe6 100644 --- a/sys/boot/common/module.c +++ b/sys/boot/common/module.c @@ -192,13 +192,11 @@ command_load_geli(int argc, char *argv[]) return(file_loadraw(argv[2], typestr) ? CMD_OK : CMD_ERROR); } -COMMAND_SET(unload, "unload", "unload all modules", command_unload); - -static int -command_unload(int argc, char *argv[]) +void +unload(void) { - struct preloaded_file *fp; - + struct preloaded_file *fp; + while (preloaded_files != NULL) { fp = preloaded_files; preloaded_files = preloaded_files->f_next; @@ -206,6 +204,14 @@ command_unload(int argc, char *argv[]) } loadaddr = 0; unsetenv("kernelname"); +} + +COMMAND_SET(unload, "unload", "unload all modules", command_unload); + +static int +command_unload(int argc, char *argv[]) +{ + unload(); return(CMD_OK); }