diff options
author | bde <bde@FreeBSD.org> | 1997-03-03 12:58:20 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1997-03-03 12:58:20 +0000 |
commit | 5fc94677bda468bbe12b8bcaf035aa45dd51e261 (patch) | |
tree | a69b460335add94b5a7913df88cc0f5d8d811f20 /sys | |
parent | 2d87f1b6fadd5882c185625f0f295f6a1a5fb320 (diff) | |
download | FreeBSD-src-5fc94677bda468bbe12b8bcaf035aa45dd51e261.zip FreeBSD-src-5fc94677bda468bbe12b8bcaf035aa45dd51e261.tar.gz |
Merged Lite2's vfs_sysctl(). It doesn't fit very well into FreeBSD's
(phk's) sysctl framework, and I needed special code to disambiguate
the VFS_GENERIC node from the VFS_VFSCONF leaf, so I only converted
the leaves to the FreeBSD framework. The error handling isn't quite
right. CSRGS's sysctls seem to return ENOTDIR too much and FreeBSD's
sysctls don't agree with the man page.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_mib.c | 5 | ||||
-rw-r--r-- | sys/kern/vfs_export.c | 71 | ||||
-rw-r--r-- | sys/kern/vfs_subr.c | 71 |
3 files changed, 101 insertions, 46 deletions
diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c index 65e975f..c19a269 100644 --- a/sys/kern/kern_mib.c +++ b/sys/kern/kern_mib.c @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94 - * $Id$ + * $Id: kern_mib.c,v 1.6 1997/02/22 09:39:07 peter Exp $ */ #include <sys/param.h> @@ -53,7 +53,8 @@ SYSCTL_NODE(, CTL_KERN, kern, CTLFLAG_RW, 0, "High kernel, proc, limits &c"); SYSCTL_NODE(, CTL_VM, vm, CTLFLAG_RW, 0, "Virtual memory"); -SYSCTL_NODE(, CTL_VFS, vfs, CTLFLAG_RW, 0, +extern int vfs_sysctl __P(SYSCTL_HANDLER_ARGS); +SYSCTL_NODE(, CTL_VFS, vfs, CTLFLAG_RD, vfs_sysctl, "File system"); SYSCTL_NODE(, CTL_NET, net, CTLFLAG_RW, 0, "Network, (see socket.h)"); diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c index 03cb4d1..0f65e66 100644 --- a/sys/kern/vfs_export.c +++ b/sys/kern/vfs_export.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 - * $Id: vfs_subr.c,v 1.76 1997/03/02 11:06:22 bde Exp $ + * $Id: vfs_subr.c,v 1.77 1997/03/02 17:53:37 bde Exp $ */ /* @@ -1644,26 +1644,58 @@ printlockedvnodes() } #endif -#ifdef notyet -static int -sysctl_vfs_conf SYSCTL_HANDLER_ARGS +/* + * Top level filesystem related information gathering. + */ +extern int vfs_sysctl __P(SYSCTL_HANDLER_ARGS); +static int sysctl_ovfs_conf __P(SYSCTL_HANDLER_ARGS); + +int +vfs_sysctl SYSCTL_HANDLER_ARGS { - int error; + int *name = (int *)arg1; + u_int namelen = arg2; struct vfsconf *vfsp; - if (req->newptr) - return EINVAL; - for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) { - error = SYSCTL_OUT(req, vfsp, sizeof *vfsp); - if (error) - return error; - } - return 0; -} +#ifndef NO_COMPAT_PRELITE2 + /* Resolve ambiguity between VFS_VFSCONF and VFS_GENERIC. */ + if (namelen == 1 && name[0] == VFS_VFSCONF) + return (sysctl_ovfs_conf(oidp, arg1, arg2, req)); +#endif -SYSCTL_PROC(_vfs, VFS_VFSCONF, vfsconf, CTLTYPE_OPAQUE|CTLFLAG_RD, - 0, 0, sysctl_vfs_conf, "S,vfsconf", ""); + /* all sysctl names at this level are at least name and field */ + if (namelen < 2) + return (ENOTDIR); /* overloaded */ + if (name[0] != VFS_GENERIC) { + for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) + if (vfsp->vfc_typenum == name[0]) + break; + if (vfsp == NULL) + return (EOPNOTSUPP); +#ifdef notyet + return ((*vfsp->vfc_vfsops->vfs_sysctl)(&name[1], namelen - 1, + oldp, oldlenp, newp, newlen, p)); +#else + return (EOPNOTSUPP); #endif + } + switch (name[1]) { + case VFS_MAXTYPENUM: + if (namelen != 2) + return (ENOTDIR); + return (SYSCTL_OUT(req, &maxvfsconf, sizeof(int))); + case VFS_CONF: + if (namelen != 3) + return (ENOTDIR); /* overloaded */ + for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) + if (vfsp->vfc_typenum == name[2]) + break; + if (vfsp == NULL) + return (EOPNOTSUPP); + return (SYSCTL_OUT(req, vfsp, sizeof *vfsp)); + } + return (EOPNOTSUPP); +} #ifndef NO_COMPAT_PRELITE2 @@ -1672,11 +1704,9 @@ sysctl_ovfs_conf SYSCTL_HANDLER_ARGS { int error; struct vfsconf *vfsp; + struct ovfsconf ovfs; - if (req->newptr) - return EINVAL; for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) { - struct ovfsconf ovfs; ovfs.vfc_vfsops = vfsp->vfc_vfsops; /* XXX used as flag */ strcpy(ovfs.vfc_name, vfsp->vfc_name); ovfs.vfc_index = vfsp->vfc_typenum; @@ -1689,9 +1719,6 @@ sysctl_ovfs_conf SYSCTL_HANDLER_ARGS return 0; } -SYSCTL_PROC(_vfs, VFS_VFSCONF, ovfsconf, CTLTYPE_OPAQUE|CTLFLAG_RD, - 0, 0, sysctl_ovfs_conf, "S,ovfsconf", ""); - #endif /* !NO_COMPAT_PRELITE2 */ int kinfo_vdebug = 1; diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 03cb4d1..0f65e66 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 - * $Id: vfs_subr.c,v 1.76 1997/03/02 11:06:22 bde Exp $ + * $Id: vfs_subr.c,v 1.77 1997/03/02 17:53:37 bde Exp $ */ /* @@ -1644,26 +1644,58 @@ printlockedvnodes() } #endif -#ifdef notyet -static int -sysctl_vfs_conf SYSCTL_HANDLER_ARGS +/* + * Top level filesystem related information gathering. + */ +extern int vfs_sysctl __P(SYSCTL_HANDLER_ARGS); +static int sysctl_ovfs_conf __P(SYSCTL_HANDLER_ARGS); + +int +vfs_sysctl SYSCTL_HANDLER_ARGS { - int error; + int *name = (int *)arg1; + u_int namelen = arg2; struct vfsconf *vfsp; - if (req->newptr) - return EINVAL; - for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) { - error = SYSCTL_OUT(req, vfsp, sizeof *vfsp); - if (error) - return error; - } - return 0; -} +#ifndef NO_COMPAT_PRELITE2 + /* Resolve ambiguity between VFS_VFSCONF and VFS_GENERIC. */ + if (namelen == 1 && name[0] == VFS_VFSCONF) + return (sysctl_ovfs_conf(oidp, arg1, arg2, req)); +#endif -SYSCTL_PROC(_vfs, VFS_VFSCONF, vfsconf, CTLTYPE_OPAQUE|CTLFLAG_RD, - 0, 0, sysctl_vfs_conf, "S,vfsconf", ""); + /* all sysctl names at this level are at least name and field */ + if (namelen < 2) + return (ENOTDIR); /* overloaded */ + if (name[0] != VFS_GENERIC) { + for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) + if (vfsp->vfc_typenum == name[0]) + break; + if (vfsp == NULL) + return (EOPNOTSUPP); +#ifdef notyet + return ((*vfsp->vfc_vfsops->vfs_sysctl)(&name[1], namelen - 1, + oldp, oldlenp, newp, newlen, p)); +#else + return (EOPNOTSUPP); #endif + } + switch (name[1]) { + case VFS_MAXTYPENUM: + if (namelen != 2) + return (ENOTDIR); + return (SYSCTL_OUT(req, &maxvfsconf, sizeof(int))); + case VFS_CONF: + if (namelen != 3) + return (ENOTDIR); /* overloaded */ + for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) + if (vfsp->vfc_typenum == name[2]) + break; + if (vfsp == NULL) + return (EOPNOTSUPP); + return (SYSCTL_OUT(req, vfsp, sizeof *vfsp)); + } + return (EOPNOTSUPP); +} #ifndef NO_COMPAT_PRELITE2 @@ -1672,11 +1704,9 @@ sysctl_ovfs_conf SYSCTL_HANDLER_ARGS { int error; struct vfsconf *vfsp; + struct ovfsconf ovfs; - if (req->newptr) - return EINVAL; for (vfsp = vfsconf; vfsp; vfsp = vfsp->vfc_next) { - struct ovfsconf ovfs; ovfs.vfc_vfsops = vfsp->vfc_vfsops; /* XXX used as flag */ strcpy(ovfs.vfc_name, vfsp->vfc_name); ovfs.vfc_index = vfsp->vfc_typenum; @@ -1689,9 +1719,6 @@ sysctl_ovfs_conf SYSCTL_HANDLER_ARGS return 0; } -SYSCTL_PROC(_vfs, VFS_VFSCONF, ovfsconf, CTLTYPE_OPAQUE|CTLFLAG_RD, - 0, 0, sysctl_ovfs_conf, "S,ovfsconf", ""); - #endif /* !NO_COMPAT_PRELITE2 */ int kinfo_vdebug = 1; |