summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_subr.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/vfs_subr.c')
-rw-r--r--sys/kern/vfs_subr.c346
1 files changed, 0 insertions, 346 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 4bb58fe..17d4089 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -50,38 +50,24 @@
#include <sys/bio.h>
#include <sys/buf.h>
#include <sys/conf.h>
-#include <sys/dirent.h>
-#include <sys/domain.h>
#include <sys/eventhandler.h>
-#include <sys/event.h>
#include <sys/fcntl.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
-#include <sys/ktr.h>
#include <sys/malloc.h>
-#include <net/radix.h>
-#include <sys/socket.h>
#include <sys/mount.h>
-#include <sys/mutex.h>
#include <sys/namei.h>
-#include <sys/proc.h>
-#include <sys/reboot.h>
-#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
#include <sys/vmmeter.h>
#include <sys/vnode.h>
-#include <machine/limits.h>
-#include <net/radix.h>
#include <vm/vm.h>
#include <vm/vm_object.h>
#include <vm/vm_extern.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <vm/vm_page.h>
-#include <vm/vm_pager.h>
-#include <vm/vnode_pager.h>
#include <vm/vm_zone.h>
static MALLOC_DEFINE(M_NETADDR, "Export Host", "Export host address structure");
@@ -253,28 +239,6 @@ int desiredvnodes;
SYSCTL_INT(_kern, KERN_MAXVNODES, maxvnodes, CTLFLAG_RW,
&desiredvnodes, 0, "Maximum number of vnodes");
-static void vfs_free_addrlist __P((struct netexport *nep));
-static int vfs_free_netcred __P((struct radix_node *rn, void *w));
-static int vfs_hang_addrlist __P((struct mount *mp, struct netexport *nep,
- struct export_args *argp));
-
-/*
- * Network address lookup element
- */
-struct netcred {
- struct radix_node netc_rnodes[2];
- int netc_exflags;
- struct ucred netc_anon;
-};
-
-/*
- * Network export information
- */
-struct netexport {
- struct netcred ne_defexported; /* Default export */
- struct radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */
-};
-
/*
* Initialize the vnode management data structures.
*/
@@ -2343,290 +2307,6 @@ vfs_unmountall()
}
/*
- * Build hash lists of net addresses and hang them off the mount point.
- * Called by ufs_mount() to set up the lists of export addresses.
- */
-static int
-vfs_hang_addrlist(mp, nep, argp)
- struct mount *mp;
- struct netexport *nep;
- struct export_args *argp;
-{
- register struct netcred *np;
- register struct radix_node_head *rnh;
- register int i;
- struct radix_node *rn;
- struct sockaddr *saddr, *smask = 0;
- struct domain *dom;
- int error;
-
- if (argp->ex_addrlen == 0) {
- if (mp->mnt_flag & MNT_DEFEXPORTED)
- return (EPERM);
- np = &nep->ne_defexported;
- np->netc_exflags = argp->ex_flags;
- bzero(&np->netc_anon, sizeof(np->netc_anon));
- np->netc_anon.cr_uid = argp->ex_anon.cr_uid;
- np->netc_anon.cr_ngroups = argp->ex_anon.cr_ngroups;
- bcopy(argp->ex_anon.cr_groups, np->netc_anon.cr_groups,
- sizeof(np->netc_anon.cr_groups));
- np->netc_anon.cr_ref = 1;
- mp->mnt_flag |= MNT_DEFEXPORTED;
- return (0);
- }
- i = sizeof(struct netcred) + argp->ex_addrlen + argp->ex_masklen;
- np = (struct netcred *) malloc(i, M_NETADDR, M_WAITOK | M_ZERO);
- saddr = (struct sockaddr *) (np + 1);
- if ((error = copyin(argp->ex_addr, (caddr_t) saddr, argp->ex_addrlen)))
- goto out;
- if (saddr->sa_len > argp->ex_addrlen)
- saddr->sa_len = argp->ex_addrlen;
- if (argp->ex_masklen) {
- smask = (struct sockaddr *) ((caddr_t) saddr + argp->ex_addrlen);
- error = copyin(argp->ex_mask, (caddr_t) smask, argp->ex_masklen);
- if (error)
- goto out;
- if (smask->sa_len > argp->ex_masklen)
- smask->sa_len = argp->ex_masklen;
- }
- i = saddr->sa_family;
- if ((rnh = nep->ne_rtable[i]) == 0) {
- /*
- * Seems silly to initialize every AF when most are not used,
- * do so on demand here
- */
- for (dom = domains; dom; dom = dom->dom_next)
- if (dom->dom_family == i && dom->dom_rtattach) {
- dom->dom_rtattach((void **) &nep->ne_rtable[i],
- dom->dom_rtoffset);
- break;
- }
- if ((rnh = nep->ne_rtable[i]) == 0) {
- error = ENOBUFS;
- goto out;
- }
- }
- rn = (*rnh->rnh_addaddr) ((caddr_t) saddr, (caddr_t) smask, rnh,
- np->netc_rnodes);
- if (rn == 0 || np != (struct netcred *) rn) { /* already exists */
- error = EPERM;
- goto out;
- }
- np->netc_exflags = argp->ex_flags;
- bzero(&np->netc_anon, sizeof(np->netc_anon));
- np->netc_anon.cr_uid = argp->ex_anon.cr_uid;
- np->netc_anon.cr_ngroups = argp->ex_anon.cr_ngroups;
- bcopy(argp->ex_anon.cr_groups, np->netc_anon.cr_groups,
- sizeof(np->netc_anon.cr_groups));
- np->netc_anon.cr_ref = 1;
- return (0);
-out:
- free(np, M_NETADDR);
- return (error);
-}
-
-/* Helper for vfs_free_addrlist. */
-/* ARGSUSED */
-static int
-vfs_free_netcred(rn, w)
- struct radix_node *rn;
- void *w;
-{
- register struct radix_node_head *rnh = (struct radix_node_head *) w;
-
- (*rnh->rnh_deladdr) (rn->rn_key, rn->rn_mask, rnh);
- free((caddr_t) rn, M_NETADDR);
- return (0);
-}
-
-/*
- * Free the net address hash lists that are hanging off the mount points.
- */
-static void
-vfs_free_addrlist(nep)
- struct netexport *nep;
-{
- register int i;
- register struct radix_node_head *rnh;
-
- for (i = 0; i <= AF_MAX; i++)
- if ((rnh = nep->ne_rtable[i])) {
- (*rnh->rnh_walktree) (rnh, vfs_free_netcred,
- (caddr_t) rnh);
- free((caddr_t) rnh, M_RTABLE);
- nep->ne_rtable[i] = 0;
- }
-}
-
-/*
- * High level function to manipulate export options on a mount point
- * and the passed in netexport.
- * Struct export_args *argp is the variable used to twiddle options,
- * the structure is described in sys/mount.h
- */
-int
-vfs_export(mp, argp)
- struct mount *mp;
- struct export_args *argp;
-{
- struct netexport *nep;
- int error;
-
- nep = mp->mnt_export;
- if (argp->ex_flags & MNT_DELEXPORT) {
- if (nep == NULL)
- return (EINVAL);
- if (mp->mnt_flag & MNT_EXPUBLIC) {
- vfs_setpublicfs(NULL, NULL, NULL);
- mp->mnt_flag &= ~MNT_EXPUBLIC;
- }
- vfs_free_addrlist(nep);
- mp->mnt_export = NULL;
- free(nep, M_MOUNT);
- mp->mnt_flag &= ~(MNT_EXPORTED | MNT_DEFEXPORTED);
- }
- if (argp->ex_flags & MNT_EXPORTED) {
- if (nep == NULL) {
- nep = malloc(sizeof(struct netexport), M_MOUNT, M_WAITOK | M_ZERO);
- mp->mnt_export = nep;
- }
- if (argp->ex_flags & MNT_EXPUBLIC) {
- if ((error = vfs_setpublicfs(mp, nep, argp)) != 0)
- return (error);
- mp->mnt_flag |= MNT_EXPUBLIC;
- }
- if ((error = vfs_hang_addrlist(mp, nep, argp)))
- return (error);
- mp->mnt_flag |= MNT_EXPORTED;
- }
- return (0);
-}
-
-/*
- * Set the publicly exported filesystem (WebNFS). Currently, only
- * one public filesystem is possible in the spec (RFC 2054 and 2055)
- */
-int
-vfs_setpublicfs(mp, nep, argp)
- struct mount *mp;
- struct netexport *nep;
- struct export_args *argp;
-{
- int error;
- struct vnode *rvp;
- char *cp;
-
- /*
- * mp == NULL -> invalidate the current info, the FS is
- * no longer exported. May be called from either vfs_export
- * or unmount, so check if it hasn't already been done.
- */
- if (mp == NULL) {
- if (nfs_pub.np_valid) {
- nfs_pub.np_valid = 0;
- if (nfs_pub.np_index != NULL) {
- FREE(nfs_pub.np_index, M_TEMP);
- nfs_pub.np_index = NULL;
- }
- }
- return (0);
- }
-
- /*
- * Only one allowed at a time.
- */
- if (nfs_pub.np_valid != 0 && mp != nfs_pub.np_mount)
- return (EBUSY);
-
- /*
- * Get real filehandle for root of exported FS.
- */
- bzero((caddr_t)&nfs_pub.np_handle, sizeof(nfs_pub.np_handle));
- nfs_pub.np_handle.fh_fsid = mp->mnt_stat.f_fsid;
-
- if ((error = VFS_ROOT(mp, &rvp)))
- return (error);
-
- if ((error = VFS_VPTOFH(rvp, &nfs_pub.np_handle.fh_fid)))
- return (error);
-
- vput(rvp);
-
- /*
- * If an indexfile was specified, pull it in.
- */
- if (argp->ex_indexfile != NULL) {
- MALLOC(nfs_pub.np_index, char *, MAXNAMLEN + 1, M_TEMP,
- M_WAITOK);
- error = copyinstr(argp->ex_indexfile, nfs_pub.np_index,
- MAXNAMLEN, (size_t *)0);
- if (!error) {
- /*
- * Check for illegal filenames.
- */
- for (cp = nfs_pub.np_index; *cp; cp++) {
- if (*cp == '/') {
- error = EINVAL;
- break;
- }
- }
- }
- if (error) {
- FREE(nfs_pub.np_index, M_TEMP);
- return (error);
- }
- }
-
- nfs_pub.np_mount = mp;
- nfs_pub.np_valid = 1;
- return (0);
-}
-
-/*
- * Used by the filesystems to determine if a given network address
- * (passed in 'nam') is present in thier exports list, returns a pointer
- * to struct netcred so that the filesystem can examine it for
- * access rights (read/write/etc).
- */
-struct netcred *
-vfs_export_lookup(mp, nam)
- register struct mount *mp;
- struct sockaddr *nam;
-{
- struct netexport *nep;
- register struct netcred *np;
- register struct radix_node_head *rnh;
- struct sockaddr *saddr;
-
- nep = mp->mnt_export;
- if (nep == NULL)
- return (NULL);
- np = NULL;
- if (mp->mnt_flag & MNT_EXPORTED) {
- /*
- * Lookup in the export list first.
- */
- if (nam != NULL) {
- saddr = nam;
- rnh = nep->ne_rtable[saddr->sa_family];
- if (rnh != NULL) {
- np = (struct netcred *)
- (*rnh->rnh_matchaddr)((caddr_t)saddr,
- rnh);
- if (np && np->netc_rnodes->rn_flags & RNF_ROOT)
- np = NULL;
- }
- }
- /*
- * If no address match, use the default if it exists.
- */
- if (np == NULL && mp->mnt_flag & MNT_DEFEXPORTED)
- np = &nep->ne_defexported;
- }
- return (np);
-}
-
-/*
* perform msync on all vnodes under a mount point
* the mount point must be locked.
*/
@@ -3206,29 +2886,3 @@ privcheck:
return ((acc_mode & VADMIN) ? EPERM : EACCES);
}
-/*
- * XXX: This comment comes from the deprecated ufs_check_export()
- * XXX: and may not entirely apply, but lacking something better:
- * This is the generic part of fhtovp called after the underlying
- * filesystem has validated the file handle.
- *
- * Verify that a host should have access to a filesystem.
- */
-
-int
-vfs_stdcheckexp(mp, nam, extflagsp, credanonp)
- struct mount *mp;
- struct sockaddr *nam;
- int *extflagsp;
- struct ucred **credanonp;
-{
- struct netcred *np;
-
- np = vfs_export_lookup(mp, nam);
- if (np == NULL)
- return (EACCES);
- *extflagsp = np->netc_exflags;
- *credanonp = &np->netc_anon;
- return (0);
-}
-
OpenPOWER on IntegriCloud