diff options
| author | John Baldwin <jhb@FreeBSD.org> | 2008-12-05 13:40:25 +0000 |
|---|---|---|
| committer | John Baldwin <jhb@FreeBSD.org> | 2008-12-05 13:40:25 +0000 |
| commit | b4824b48b4829bfcf7fe3f57ea01e854ce0c9ab4 (patch) | |
| tree | a8522c6b0e4d16f7f55489f7822e5cbf7405ddf4 /sys/kern/kern_linker.c | |
| parent | 482b7172da61346880df580e23d3af7860281366 (diff) | |
Notes
Diffstat (limited to 'sys/kern/kern_linker.c')
| -rw-r--r-- | sys/kern/kern_linker.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index e232cdc6ddcf..f657efa9b44f 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -587,7 +587,30 @@ linker_file_unload(linker_file_t file, int flags) " informing modules\n")); /* - * Inform any modules associated with this file. + * Quiesce all the modules to give them a chance to veto the unload. + */ + MOD_SLOCK; + for (mod = TAILQ_FIRST(&file->modules); mod; + mod = module_getfnext(mod)) { + + error = module_quiesce(mod); + if (error != 0 && flags != LINKER_UNLOAD_FORCE) { + KLD_DPF(FILE, ("linker_file_unload: module %s" + " vetoed unload\n", module_getname(mod))); + /* + * XXX: Do we need to tell all the quiesced modules + * that they can resume work now via a new module + * event? + */ + MOD_SUNLOCK; + return (error); + } + } + MOD_SUNLOCK; + + /* + * Inform any modules associated with this file that they are + * being be unloaded. */ MOD_XLOCK; for (mod = TAILQ_FIRST(&file->modules); mod; mod = next) { @@ -597,9 +620,9 @@ linker_file_unload(linker_file_t file, int flags) /* * Give the module a chance to veto the unload. */ - if ((error = module_unload(mod, flags)) != 0) { - KLD_DPF(FILE, ("linker_file_unload: module %p" - " vetoes unload\n", mod)); + if ((error = module_unload(mod)) != 0) { + KLD_DPF(FILE, ("linker_file_unload: module %s" + " failed unload\n", mod)); return (error); } MOD_XLOCK; |
