summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_subr.c
diff options
context:
space:
mode:
authormux <mux@FreeBSD.org>2002-08-10 20:19:04 +0000
committermux <mux@FreeBSD.org>2002-08-10 20:19:04 +0000
commitf43070c32510080cd90cfad7384d00f798c8d852 (patch)
treef2655b26537a3fa42106a5f0b342f24c8d6e679d /sys/kern/vfs_subr.c
parent120b32fbcc3d50570076359500df08aac80318b6 (diff)
downloadFreeBSD-src-f43070c32510080cd90cfad7384d00f798c8d852.zip
FreeBSD-src-f43070c32510080cd90cfad7384d00f798c8d852.tar.gz
- Introduce a new struct xvfsconf, the userland version of struct vfsconf.
- Make getvfsbyname() take a struct xvfsconf *. - Convert several consumers of getvfsbyname() to use struct xvfsconf. - Correct the getvfsbyname.3 manpage. - Create a new vfs.conflist sysctl to dump all the struct xvfsconf in the kernel, and rewrite getvfsbyname() to use this instead of the weird existing API. - Convert some {set,get,end}vfsent() consumers to use the new vfs.conflist sysctl. - Convert a vfsload() call in nfsiod.c to kldload() and remove the useless vfsisloadable() and endvfsent() calls. - Add a warning printf() in vfs_sysctl() to tell people they are using an old userland. After these changes, it's possible to modify struct vfsconf without breaking the binary compatibility. Please note that these changes don't break this compatibility either. When bp will have updated mount_smbfs(8) with the patch I sent him, there will be no more consumers of the {set,get,end}vfsent(), vfsisloadable() and vfsload() API, and I will promptly delete it.
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r--sys/kern/vfs_subr.c74
1 files changed, 57 insertions, 17 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index bf71d04..095716f 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -2630,6 +2630,56 @@ DB_SHOW_COMMAND(lockedvnods, lockedvnodes)
#endif
/*
+ * Fill in a struct xvfsconf based on a struct vfsconf.
+ */
+static void
+vfsconf2x(struct vfsconf *vfsp, struct xvfsconf *xvfsp)
+{
+
+ strcpy(xvfsp->vfc_name, vfsp->vfc_name);
+ xvfsp->vfc_typenum = vfsp->vfc_typenum;
+ xvfsp->vfc_refcount = vfsp->vfc_refcount;
+ xvfsp->vfc_flags = vfsp->vfc_flags;
+ /*
+ * These are unused in userland, we keep them
+ * to not break binary compatibility.
+ */
+ xvfsp->vfc_vfsops = NULL;
+ xvfsp->vfc_next = NULL;
+}
+
+static int
+sysctl_vfs_conflist(SYSCTL_HANDLER_ARGS)
+{
+ struct vfsconf *vfsp;
+ struct xvfsconf *xvfsp;
+ int cnt, error, i;
+
+ cnt = 0;
+ for (vfsp = vfsconf; vfsp != NULL; vfsp = vfsp->vfc_next)
+ cnt++;
+ xvfsp = malloc(sizeof(struct xvfsconf) * cnt, M_TEMP, M_WAITOK);
+ /*
+ * Handle the race that we will have here when struct vfsconf
+ * will be locked down by using both cnt and checking vfc_next
+ * against NULL to determine the end of the loop. The race will
+ * happen because we will have to unlock before calling malloc().
+ * We are protected by Giant for now.
+ */
+ i = 0;
+ for (vfsp = vfsconf; vfsp != NULL && i < cnt; vfsp = vfsp->vfc_next) {
+ vfsconf2x(vfsp, xvfsp + i);
+ i++;
+ }
+ error = SYSCTL_OUT(req, xvfsp, sizeof(struct xvfsconf) * i);
+ free(xvfsp, M_TEMP);
+ return (error);
+}
+
+SYSCTL_PROC(_vfs, OID_AUTO, conflist, CTLFLAG_RD, NULL, 0, sysctl_vfs_conflist,
+ "S,xvfsconf", "List of all configured filesystems");
+
+/*
* Top level filesystem related information gathering.
*/
static int sysctl_ovfs_conf(SYSCTL_HANDLER_ARGS);
@@ -2640,6 +2690,10 @@ vfs_sysctl(SYSCTL_HANDLER_ARGS)
int *name = (int *)arg1 - 1; /* XXX */
u_int namelen = arg2 + 1; /* XXX */
struct vfsconf *vfsp;
+ struct xvfsconf xvfsp;
+
+ printf("WARNING: userland calling deprecated sysctl, "
+ "please rebuild world\n");
#if 1 || defined(COMPAT_PRELITE2)
/* Resolve ambiguity between VFS_VFSCONF and VFS_GENERIC. */
@@ -2647,21 +2701,6 @@ vfs_sysctl(SYSCTL_HANDLER_ARGS)
return (sysctl_ovfs_conf(oidp, arg1, arg2, req));
#endif
- /* XXX the below code does not compile; vfs_sysctl does not exist. */
-#ifdef notyet
- /* 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);
- return ((*vfsp->vfc_vfsops->vfs_sysctl)(&name[1], namelen - 1,
- oldp, oldlenp, newp, newlen, td));
- }
-#endif
switch (name[1]) {
case VFS_MAXTYPENUM:
if (namelen != 2)
@@ -2675,12 +2714,13 @@ vfs_sysctl(SYSCTL_HANDLER_ARGS)
break;
if (vfsp == NULL)
return (EOPNOTSUPP);
- return (SYSCTL_OUT(req, vfsp, sizeof *vfsp));
+ vfsconf2x(vfsp, &xvfsp);
+ return (SYSCTL_OUT(req, &xvfsp, sizeof(xvfsp)));
}
return (EOPNOTSUPP);
}
-SYSCTL_NODE(_vfs, VFS_GENERIC, generic, CTLFLAG_RD, vfs_sysctl,
+SYSCTL_NODE(_vfs, VFS_GENERIC, generic, CTLFLAG_RD | CTLFLAG_SKIP, vfs_sysctl,
"Generic filesystem");
#if 1 || defined(COMPAT_PRELITE2)
OpenPOWER on IntegriCloud