From f43070c32510080cd90cfad7384d00f798c8d852 Mon Sep 17 00:00:00 2001 From: mux Date: Sat, 10 Aug 2002 20:19:04 +0000 Subject: - 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. --- lib/libc/gen/getvfsbyname.3 | 27 +++++++++++++++++++++------ lib/libc/gen/getvfsbyname.c | 40 ++++++++++++++++++++++------------------ lib/libc/gen/getvfsent.c | 31 ------------------------------- 3 files changed, 43 insertions(+), 55 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/getvfsbyname.3 b/lib/libc/gen/getvfsbyname.3 index da115ec..277b964 100644 --- a/lib/libc/gen/getvfsbyname.3 +++ b/lib/libc/gen/getvfsbyname.3 @@ -44,7 +44,7 @@ .In sys/param.h .In sys/mount.h .Ft int -.Fn getvfsbyname "const char *name" "struct vfsconf *vfc" +.Fn getvfsbyname "const char *name" "struct xvfsconf *vfc" .Sh DESCRIPTION The .Fn getvfsbyname @@ -52,11 +52,11 @@ function provides access to information about a filesystem module that is configured in the kernel. If successful, the requested filesystem -.Fa vfsconf +.Fa xvfsconf is returned in the location pointed to by .Fa vfc . The fields in a -.Dq Li struct vfsconf +.Dq Li struct xvfsconf are defined as follows: .Pp .Bl -tag -compact -width vfc_refcount @@ -67,8 +67,24 @@ the filesystem type number assigned by the kernel .It vfc_refcount the number of active mount points using the filesystem .It vfc_flags -flag bits as described in -.Xr getvfsent 3 +flag bits, as described below +.El +.Pp +The flags are defined as follows: +.Pp +.Bl -tag -width VFCF_SYNTHETIC -compact +.It Dv VFCF_STATIC +statically compiled into kernel +.It Dv VFCF_NETWORK +may get data over the network +.It Dv VFCF_READONLY +writes are not implemented +.It Dv VFCF_SYNTHETIC +data does not represent real files +.It Dv VFCF_LOOPBACK +aliases some other mounted FS +.It Dv VFCF_UNICODE +stores file names as Unicode .El .Sh RETURN VALUES .Rv -std getvfsbyname @@ -86,7 +102,6 @@ specifies a filesystem that is unknown or not configured in the kernel. .El .Sh SEE ALSO .Xr mount 2 , -.Xr getvfsent 3 , .Xr sysctl 3 , .Xr mount 8 , .Xr sysctl 8 diff --git a/lib/libc/gen/getvfsbyname.c b/lib/libc/gen/getvfsbyname.c index eb6f26f..3ab03f4 100644 --- a/lib/libc/gen/getvfsbyname.c +++ b/lib/libc/gen/getvfsbyname.c @@ -41,39 +41,43 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include /* * 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); diff --git a/lib/libc/gen/getvfsent.c b/lib/libc/gen/getvfsent.c index 140664b..3ca3eac 100644 --- a/lib/libc/gen/getvfsent.c +++ b/lib/libc/gen/getvfsent.c @@ -21,7 +21,6 @@ __FBSDID("$FreeBSD$"); #include /* XXX hide some compatibility problems. */ -#undef getvfsbyname #define vfsconf ovfsconf static struct vfsconf *_vfslist = 0; @@ -81,36 +80,6 @@ getvfsent(void) } struct vfsconf * -getvfsbyname(const char *name) -{ - int i; - - if(!_vfslist && !initvfs()) { - return 0; - } - - for(i = 0; i < _vfslistlen; i++) { - if( ! strcmp(_vfslist[i].vfc_name, name) ) - break; - } - - if(i < _vfslistlen) { - _vfsconf = _vfslist[i]; - } - - if(!_vfs_keeplist) { - free(_vfslist); - _vfslist = 0; - } - - if(i < _vfslistlen) { - return &_vfsconf; - } else { - return 0; - } -} - -struct vfsconf * getvfsbytype(int type) { int i; -- cgit v1.1