diff options
author | jhb <jhb@FreeBSD.org> | 2006-06-13 21:36:23 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2006-06-13 21:36:23 +0000 |
commit | 9af5dd68e4cafc61cd39c93a9cbb404beec42308 (patch) | |
tree | 6bdda3a80fe25172e30b3b25fc2a0ae45191cc84 /sys/kern/vfs_init.c | |
parent | 00130e4f0c49136fca94a71afa4a22642743681e (diff) | |
download | FreeBSD-src-9af5dd68e4cafc61cd39c93a9cbb404beec42308.zip FreeBSD-src-9af5dd68e4cafc61cd39c93a9cbb404beec42308.tar.gz |
Use kern_kldload() and kern_kldunload() to load and unload modules when
we intend for the user to be able to unload them later via kldunload(2)
instead of calling linker_load_module() and then directly adjusting the
ref count on the linker file structure. This makes the resulting
consumer code simpler and cleaner and better hides the linker internals
making it possible to sanely lock the linker.
Diffstat (limited to 'sys/kern/vfs_init.c')
-rw-r--r-- | sys/kern/vfs_init.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c index b890ffe..b279e89 100644 --- a/sys/kern/vfs_init.c +++ b/sys/kern/vfs_init.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include <sys/linker.h> #include <sys/mount.h> #include <sys/proc.h> +#include <sys/syscallsubr.h> #include <sys/sysctl.h> #include <sys/vnode.h> #include <sys/malloc.h> @@ -108,7 +109,7 @@ struct vfsconf * vfs_byname_kld(const char *fstype, struct thread *td, int *error) { struct vfsconf *vfsp; - linker_file_t lf; + int fileid; vfsp = vfs_byname(fstype); if (vfsp != NULL) @@ -121,17 +122,14 @@ vfs_byname_kld(const char *fstype, struct thread *td, int *error) *error = securelevel_gt(td->td_ucred, 0); if (*error) return (NULL); - *error = linker_load_module(NULL, fstype, NULL, NULL, &lf); - if (lf == NULL) - *error = ENODEV; + *error = kern_kldload(td, fstype, &fileid); if (*error) return (NULL); - lf->userrefs++; + /* Look up again to see if the VFS was loaded. */ vfsp = vfs_byname(fstype); if (vfsp == NULL) { - lf->userrefs--; - linker_file_unload(lf, LINKER_UNLOAD_FORCE); + (void)kern_kldunload(td, fileid, LINKER_UNLOAD_FORCE); *error = ENODEV; return (NULL); } |