aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/gen/getvfsbyname.c
diff options
context:
space:
mode:
authorMaxime Henrion <mux@FreeBSD.org>2002-08-10 20:19:04 +0000
committerMaxime Henrion <mux@FreeBSD.org>2002-08-10 20:19:04 +0000
commit5965373e69ca208cedd8ede9716ef0d58e6c3434 (patch)
treef2655b26537a3fa42106a5f0b342f24c8d6e679d /lib/libc/gen/getvfsbyname.c
parent306e6b83936d0560c96775d3dbf0767138825040 (diff)
downloadsrc-5965373e69ca208cedd8ede9716ef0d58e6c3434.tar.gz
src-5965373e69ca208cedd8ede9716ef0d58e6c3434.zip
- 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.
Notes
Notes: svn path=/head/; revision=101651
Diffstat (limited to 'lib/libc/gen/getvfsbyname.c')
-rw-r--r--lib/libc/gen/getvfsbyname.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/lib/libc/gen/getvfsbyname.c b/lib/libc/gen/getvfsbyname.c
index eb6f26fde9df..3ab03f4de83b 100644
--- a/lib/libc/gen/getvfsbyname.c
+++ b/lib/libc/gen/getvfsbyname.c
@@ -41,39 +41,43 @@ __FBSDID("$FreeBSD$");
#include <sys/mount.h>
#include <sys/sysctl.h>
#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
/*
* Given a filesystem name, determine if it is resident in the kernel,
- * and if it is resident, return its vfsconf structure.
+ * and if it is resident, return its xvfsconf structure.
*/
+int
getvfsbyname(fsname, vfcp)
const char *fsname;
- struct vfsconf *vfcp;
+ struct xvfsconf *vfcp;
{
#ifdef __NETBSD_SYSCALLS
errno = ENOSYS;
#else
- int name[4], maxtypenum, cnt;
+ struct xvfsconf *xvfsp;
size_t buflen;
+ int cnt, i;
- name[0] = CTL_VFS;
- name[1] = VFS_GENERIC;
- name[2] = VFS_MAXTYPENUM;
- buflen = 4;
- if (sysctl(name, 3, &maxtypenum, &buflen, (void *)0, (size_t)0) < 0)
+ if (sysctlbyname("vfs.conflist", NULL, &buflen, NULL, 0) < 0)
return (-1);
- name[2] = VFS_CONF;
- buflen = sizeof *vfcp;
- for (cnt = 0; cnt < maxtypenum; cnt++) {
- name[3] = cnt;
- if (sysctl(name, 4, vfcp, &buflen, (void *)0, (size_t)0) < 0) {
- if (errno != EOPNOTSUPP)
- return (-1);
- continue;
- }
- if (!strcmp(fsname, vfcp->vfc_name))
+ xvfsp = malloc(buflen);
+ if (xvfsp == NULL)
+ return (-1);
+ if (sysctlbyname("vfs.conflist", xvfsp, &buflen, NULL, 0) < 0) {
+ free(xvfsp);
+ return (-1);
+ }
+ cnt = buflen / sizeof(struct xvfsconf);
+ for (i = 0; i < cnt; i++) {
+ if (strcmp(fsname, xvfsp[i].vfc_name) == 0) {
+ memcpy(vfcp, xvfsp + i, sizeof(struct xvfsconf));
+ free(xvfsp);
return (0);
+ }
}
+ free(xvfsp);
errno = ENOENT;
#endif
return (-1);