diff options
author | peter <peter@FreeBSD.org> | 1998-11-03 14:29:09 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1998-11-03 14:29:09 +0000 |
commit | 43589c7042343335851bafe0fd3d06e47bd64e80 (patch) | |
tree | 58d5459c0b59c50da3acb1d8317ae5673023d387 /sys/kern | |
parent | 2b6debf094bac2f5d1036c8beae2f16461481b48 (diff) | |
download | FreeBSD-src-43589c7042343335851bafe0fd3d06e47bd64e80.zip FreeBSD-src-43589c7042343335851bafe0fd3d06e47bd64e80.tar.gz |
make mount(2) automatically kldload modules if the requested filesystem
isn't present.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/vfs_extattr.c | 35 | ||||
-rw-r--r-- | sys/kern/vfs_syscalls.c | 35 |
2 files changed, 64 insertions, 6 deletions
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 43f7856..1482df6 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94 - * $Id: vfs_syscalls.c,v 1.108 1998/10/31 07:42:04 peter Exp $ + * $Id: vfs_syscalls.c,v 1.109 1998/11/03 08:01:47 peter Exp $ */ /* For 4.3 integer FS ID compatibility */ @@ -51,6 +51,7 @@ #include <sys/kernel.h> #include <sys/fcntl.h> #include <sys/file.h> +#include <sys/linker.h> #include <sys/stat.h> #include <sys/unistd.h> #include <sys/vnode.h> @@ -224,8 +225,36 @@ mount(p, uap) if (!strcmp(vfsp->vfc_name, fstypename)) break; if (vfsp == NULL) { - vput(vp); - return (ENODEV); + linker_file_t lf; + + /* Refuse to load modules if securelevel raised */ + if (securelevel > 0) { + vput(vp); + return EPERM; + } + /* Only load modules for root (very important!) */ + if (error = suser(p->p_ucred, &p->p_acflag)) { + vput(vp); + return error; + } + error = linker_load_file(fstypename, &lf); + if (error || lf == NULL) { + vput(vp); + if (lf == NULL) + error = ENODEV; + return error; + } + lf->userrefs++; + /* lookup again, see if the VFS was loaded */ + for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) + if (!strcmp(vfsp->vfc_name, fstypename)) + break; + if (vfsp == NULL) { + lf->userrefs--; + linker_file_unload(lf); + vput(vp); + return (ENODEV); + } } simple_lock(&vp->v_interlock); if ((vp->v_flag & VMOUNT) != 0 || diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 43f7856..1482df6 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94 - * $Id: vfs_syscalls.c,v 1.108 1998/10/31 07:42:04 peter Exp $ + * $Id: vfs_syscalls.c,v 1.109 1998/11/03 08:01:47 peter Exp $ */ /* For 4.3 integer FS ID compatibility */ @@ -51,6 +51,7 @@ #include <sys/kernel.h> #include <sys/fcntl.h> #include <sys/file.h> +#include <sys/linker.h> #include <sys/stat.h> #include <sys/unistd.h> #include <sys/vnode.h> @@ -224,8 +225,36 @@ mount(p, uap) if (!strcmp(vfsp->vfc_name, fstypename)) break; if (vfsp == NULL) { - vput(vp); - return (ENODEV); + linker_file_t lf; + + /* Refuse to load modules if securelevel raised */ + if (securelevel > 0) { + vput(vp); + return EPERM; + } + /* Only load modules for root (very important!) */ + if (error = suser(p->p_ucred, &p->p_acflag)) { + vput(vp); + return error; + } + error = linker_load_file(fstypename, &lf); + if (error || lf == NULL) { + vput(vp); + if (lf == NULL) + error = ENODEV; + return error; + } + lf->userrefs++; + /* lookup again, see if the VFS was loaded */ + for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) + if (!strcmp(vfsp->vfc_name, fstypename)) + break; + if (vfsp == NULL) { + lf->userrefs--; + linker_file_unload(lf); + vput(vp); + return (ENODEV); + } } simple_lock(&vp->v_interlock); if ((vp->v_flag & VMOUNT) != 0 || |