[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/nfs/nfs_nfssvc.c

Version: -  FREEBSD  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  cheribsd  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1  -  FREEBSD-LIBC  -  FREEBSD8-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1989, 1993
    3  *      The Regents of the University of California.  All rights reserved.
    4  *
    5  * This code is derived from software contributed to Berkeley by
    6  * Rick Macklem at The University of Guelph.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 4. Neither the name of the University nor the names of its contributors
   17  *    may be used to endorse or promote products derived from this software
   18  *    without specific prior written permission.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   30  * SUCH DAMAGE.
   31  *
   32  */
   33 
   34 #include <sys/cdefs.h>
   35 __FBSDID("$FreeBSD: stable/8/sys/nfs/nfs_nfssvc.c 222089 2011-05-19 01:56:46Z rmacklem $");
   36 
   37 #include "opt_nfs.h"
   38 
   39 #include <sys/param.h>
   40 #include <sys/systm.h>
   41 #include <sys/sysproto.h>
   42 #include <sys/kernel.h>
   43 #include <sys/sysctl.h>
   44 #include <sys/priv.h>
   45 #include <sys/proc.h>
   46 #include <sys/lock.h>
   47 #include <sys/mutex.h>
   48 #include <sys/module.h>
   49 #include <sys/sysent.h>
   50 #include <sys/syscall.h>
   51 #include <sys/sysproto.h>
   52 
   53 #include <security/audit/audit.h>
   54 
   55 #include <nfs/nfssvc.h>
   56 
   57 static int nfssvc_offset = SYS_nfssvc;
   58 static struct sysent nfssvc_prev_sysent;
   59 MAKE_SYSENT(nfssvc);
   60 
   61 /*
   62  * This tiny module simply handles the nfssvc() system call. The other
   63  * nfs modules that use the system call register themselves by setting
   64  * the nfsd_call_xxx function pointers non-NULL.
   65  */
   66 
   67 int (*nfsd_call_nfsserver)(struct thread *, struct nfssvc_args *) = NULL;
   68 int (*nfsd_call_nfscommon)(struct thread *, struct nfssvc_args *) = NULL;
   69 int (*nfsd_call_nfscl)(struct thread *, struct nfssvc_args *) = NULL;
   70 int (*nfsd_call_nfsd)(struct thread *, struct nfssvc_args *) = NULL;
   71 
   72 /*
   73  * Nfs server psuedo system call for the nfsd's
   74  */
   75 int
   76 nfssvc(struct thread *td, struct nfssvc_args *uap)
   77 {
   78         int error;
   79 
   80         KASSERT(!mtx_owned(&Giant), ("nfssvc(): called with Giant"));
   81 
   82         AUDIT_ARG_CMD(uap->flag);
   83 
   84         /* Allow anyone to get the stats. */
   85         if ((uap->flag & ~NFSSVC_GETSTATS) != 0) {
   86                 error = priv_check(td, PRIV_NFS_DAEMON);
   87                 if (error != 0)
   88                         return (error);
   89         }
   90         error = EINVAL;
   91         if ((uap->flag & (NFSSVC_ADDSOCK | NFSSVC_OLDNFSD | NFSSVC_NFSD)) &&
   92             nfsd_call_nfsserver != NULL)
   93                 error = (*nfsd_call_nfsserver)(td, uap);
   94         else if ((uap->flag & (NFSSVC_CBADDSOCK | NFSSVC_NFSCBD)) &&
   95             nfsd_call_nfscl != NULL)
   96                 error = (*nfsd_call_nfscl)(td, uap);
   97         else if ((uap->flag & (NFSSVC_IDNAME | NFSSVC_GETSTATS |
   98             NFSSVC_GSSDADDPORT | NFSSVC_GSSDADDFIRST | NFSSVC_GSSDDELETEALL |
   99             NFSSVC_NFSUSERDPORT | NFSSVC_NFSUSERDDELPORT)) &&
  100             nfsd_call_nfscommon != NULL)
  101                 error = (*nfsd_call_nfscommon)(td, uap);
  102         else if ((uap->flag & (NFSSVC_NFSDNFSD | NFSSVC_NFSDADDSOCK |
  103             NFSSVC_PUBLICFH | NFSSVC_V4ROOTEXPORT | NFSSVC_NOPUBLICFH |
  104             NFSSVC_STABLERESTART | NFSSVC_ADMINREVOKE |
  105             NFSSVC_DUMPCLIENTS | NFSSVC_DUMPLOCKS | NFSSVC_BACKUPSTABLE)) &&
  106             nfsd_call_nfsd != NULL)
  107                 error = (*nfsd_call_nfsd)(td, uap);
  108         if (error == EINTR || error == ERESTART)
  109                 error = 0;
  110         return (error);
  111 }
  112 
  113 /*
  114  * Called once to initialize data structures...
  115  */
  116 static int
  117 nfssvc_modevent(module_t mod, int type, void *data)
  118 {
  119         static int registered;
  120         int error = 0;
  121 
  122         switch (type) {
  123         case MOD_LOAD:
  124                 error = syscall_register(&nfssvc_offset, &nfssvc_sysent,
  125                     &nfssvc_prev_sysent);
  126                 if (error)
  127                         break;
  128                 registered = 1;
  129                 break;
  130 
  131         case MOD_UNLOAD:
  132                 if (nfsd_call_nfsserver != NULL || nfsd_call_nfscommon != NULL
  133                     || nfsd_call_nfscl != NULL || nfsd_call_nfsd != NULL) {
  134                         error = EBUSY;
  135                         break;
  136                 }
  137                 if (registered)
  138                         syscall_deregister(&nfssvc_offset, &nfssvc_prev_sysent);
  139                 registered = 0;
  140                 break;
  141         default:
  142                 error = EOPNOTSUPP;
  143                 break;
  144         }
  145         return error;
  146 }
  147 static moduledata_t nfssvc_mod = {
  148         "nfssvc",
  149         nfssvc_modevent,
  150         NULL,
  151 };
  152 DECLARE_MODULE(nfssvc, nfssvc_mod, SI_SUB_VFS, SI_ORDER_ANY);
  153 
  154 /* So that loader and kldload(2) can find us, wherever we are.. */
  155 MODULE_VERSION(nfssvc, 1);
  156 

Cache object: 19ff6be28d4d34b1208cb8db6a4e1d57


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.