Home | History | Annotate | Line # | Download | only in nfs
nfs_var.h revision 1.43
      1 /*	$NetBSD: nfs_var.h,v 1.43 2004/04/05 10:44:09 yamt Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1996 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Christos Zoulas.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 /*
     40  * XXX needs <nfs/rpcv2.h> and <nfs/nfs.h> because of typedefs
     41  */
     42 
     43 #ifdef _KERNEL
     44 #include <sys/mallocvar.h>
     45 #include <sys/pool.h>
     46 
     47 MALLOC_DECLARE(M_NFSREQ);
     48 MALLOC_DECLARE(M_NFSMNT);
     49 MALLOC_DECLARE(M_NFSUID);
     50 MALLOC_DECLARE(M_NFSD);
     51 MALLOC_DECLARE(M_NFSDIROFF);
     52 MALLOC_DECLARE(M_NFSBIGFH);
     53 MALLOC_DECLARE(M_NQLEASE);
     54 extern struct pool nfs_srvdesc_pool;
     55 
     56 struct vnode;
     57 struct uio;
     58 struct ucred;
     59 struct proc;
     60 struct buf;
     61 struct nfs_diskless;
     62 struct sockaddr_in;
     63 struct nfs_dlmount;
     64 struct vnode;
     65 struct nfsd;
     66 struct mbuf;
     67 struct file;
     68 struct nqlease;
     69 struct nqhost;
     70 struct nfssvc_sock;
     71 struct nfsmount;
     72 struct socket;
     73 struct nfsreq;
     74 struct vattr;
     75 struct nameidata;
     76 struct nfsnode;
     77 struct sillyrename;
     78 struct componentname;
     79 struct nfsd_srvargs;
     80 struct nfsrv_descript;
     81 struct nfs_fattr;
     82 struct nfsdircache;
     83 union nethostaddr;
     84 
     85 /* nfs_bio.c */
     86 int nfs_bioread __P((struct vnode *, struct uio *, int, struct ucred *, int));
     87 struct buf *nfs_getcacheblk __P((struct vnode *, daddr_t, int, struct proc *));
     88 int nfs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *,
     89 		       int));
     90 int nfs_asyncio __P((struct buf *));
     91 int nfs_doio __P((struct buf *, struct proc *));
     92 
     93 /* nfs_boot.c */
     94 /* see nfsdiskless.h */
     95 
     96 /* nfs_kq.c */
     97 void nfs_kqinit __P((void));
     98 
     99 /* nfs_node.c */
    100 void nfs_nhinit __P((void));
    101 void nfs_nhreinit __P((void));
    102 void nfs_nhdone __P((void));
    103 int nfs_nget1 __P((struct mount *, nfsfh_t *, int, struct nfsnode **, int));
    104 #define	nfs_nget(mp, fhp, fhsize, npp) \
    105 	nfs_nget1((mp), (fhp), (fhsize), (npp), 0)
    106 
    107 /* nfs_vnops.c */
    108 int nfs_null __P((struct vnode *, struct ucred *, struct proc *));
    109 int nfs_setattrrpc __P((struct vnode *, struct vattr *, struct ucred *,
    110 			struct proc *));
    111 int nfs_readlinkrpc __P((struct vnode *, struct uio *, struct ucred *));
    112 int nfs_readrpc __P((struct vnode *, struct uio *));
    113 int nfs_writerpc __P((struct vnode *, struct uio *, int *, boolean_t,
    114 			boolean_t *));
    115 int nfs_mknodrpc __P((struct vnode *, struct vnode **, struct componentname *,
    116 		      struct vattr *));
    117 int nfs_removeit __P((struct sillyrename *));
    118 int nfs_removerpc __P((struct vnode *, const char *, int, struct ucred *,
    119 		       struct proc *));
    120 int nfs_renameit __P((struct vnode *, struct componentname *,
    121 		      struct sillyrename *));
    122 int nfs_renamerpc __P((struct vnode *, const char *, int, struct vnode *,
    123 		       const char *, int, struct ucred *, struct proc *));
    124 int nfs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *));
    125 int nfs_readdirplusrpc __P((struct vnode *, struct uio *, struct ucred *));
    126 int nfs_sillyrename __P((struct vnode *, struct vnode *,
    127 			 struct componentname *));
    128 int nfs_lookitup __P((struct vnode *, const char *, int, struct ucred *,
    129 		      struct proc *, struct nfsnode **));
    130 int nfs_commit __P((struct vnode *, off_t, uint32_t, struct proc *));
    131 int nfs_flush __P((struct vnode *, struct ucred *, int, struct proc *, int));
    132 
    133 /* nfs_nqlease.c */
    134 void nqnfs_lease_updatetime __P((int));
    135 void nqnfs_clientlease __P((struct nfsmount *, struct nfsnode *, int, int,
    136 			    time_t, u_quad_t));
    137 void nqsrv_locklease __P((struct nqlease *));
    138 void nqsrv_unlocklease __P((struct nqlease *));
    139 int nqsrv_getlease __P((struct vnode *, u_int32_t *, int, struct nfssvc_sock *,
    140 			struct proc *, struct mbuf *, int *, u_quad_t *,
    141 			struct ucred *));
    142 void nqsrv_addhost __P((struct nqhost *, struct nfssvc_sock *, struct mbuf *));
    143 void nqsrv_instimeq __P((struct nqlease *, u_int32_t));
    144 int nqsrv_cmpnam __P((struct nfssvc_sock *, struct mbuf *, struct nqhost *));
    145 void nqsrv_send_eviction __P((struct vnode *, struct nqlease *,
    146 			      struct nfssvc_sock *, struct mbuf *,
    147 			      struct ucred *));
    148 void nqsrv_waitfor_expiry __P((struct nqlease *));
    149 void nqnfs_serverd __P((void));
    150 int nqnfsrv_getlease __P((struct nfsrv_descript *, struct nfssvc_sock *,
    151 			  struct proc *, struct mbuf **));
    152 int nqnfsrv_vacated __P((struct nfsrv_descript *, struct nfssvc_sock *,
    153 			 struct proc *, struct mbuf **));
    154 int nqnfs_getlease __P((struct vnode *, int, struct ucred *, struct proc *));
    155 int nqnfs_vacated __P((struct vnode *, struct ucred *));
    156 int nqnfs_callback __P((struct nfsmount *, struct mbuf *, struct mbuf *,
    157 			caddr_t));
    158 
    159 /* nfs_serv.c */
    160 int nfsrv3_access __P((struct nfsrv_descript *, struct nfssvc_sock *,
    161 		       struct proc *, struct mbuf **));
    162 int nfsrv_getattr __P((struct nfsrv_descript *, struct nfssvc_sock *,
    163 		       struct proc *, struct mbuf **));
    164 int nfsrv_setattr __P((struct nfsrv_descript *, struct nfssvc_sock *,
    165 		       struct proc *, struct mbuf **));
    166 int nfsrv_lookup __P((struct nfsrv_descript *, struct nfssvc_sock *,
    167 		      struct proc *, struct mbuf **));
    168 int nfsrv_readlink __P((struct nfsrv_descript *, struct nfssvc_sock *,
    169 			struct proc *, struct mbuf **));
    170 int nfsrv_read __P((struct nfsrv_descript *, struct nfssvc_sock *,
    171 		    struct proc *, struct mbuf **));
    172 int nfsrv_write __P((struct nfsrv_descript *, struct nfssvc_sock *,
    173 		     struct proc *, struct mbuf **));
    174 int nfsrv_writegather __P((struct nfsrv_descript **, struct nfssvc_sock *,
    175 			   struct proc *, struct mbuf **));
    176 void nfsrvw_coalesce __P((struct nfsrv_descript *, struct nfsrv_descript *));
    177 int nfsrv_create __P((struct nfsrv_descript *, struct nfssvc_sock *,
    178 		      struct proc *, struct mbuf **));
    179 int nfsrv_mknod __P((struct nfsrv_descript *, struct nfssvc_sock *,
    180 		     struct proc *, struct mbuf **));
    181 int nfsrv_remove __P((struct nfsrv_descript *, struct nfssvc_sock *,
    182 		      struct proc *, struct mbuf **));
    183 int nfsrv_rename __P((struct nfsrv_descript *, struct nfssvc_sock *,
    184 		      struct proc *, struct mbuf **));
    185 int nfsrv_link __P((struct nfsrv_descript *, struct nfssvc_sock *,
    186 		    struct proc *, struct mbuf **));
    187 int nfsrv_symlink __P((struct nfsrv_descript *, struct nfssvc_sock *,
    188 		       struct proc *, struct mbuf **));
    189 int nfsrv_mkdir __P((struct nfsrv_descript *, struct nfssvc_sock *,
    190 		     struct proc *, struct mbuf **));
    191 int nfsrv_rmdir __P((struct nfsrv_descript *, struct nfssvc_sock *,
    192 		     struct proc *, struct mbuf **));
    193 int nfsrv_readdir __P((struct nfsrv_descript *, struct nfssvc_sock *,
    194 		       struct proc *, struct mbuf **));
    195 int nfsrv_readdirplus __P((struct nfsrv_descript *, struct nfssvc_sock *,
    196 			   struct proc *, struct mbuf **));
    197 int nfsrv_commit __P((struct nfsrv_descript *, struct nfssvc_sock *,
    198 		      struct proc *, struct mbuf **));
    199 int nfsrv_statfs __P((struct nfsrv_descript *, struct nfssvc_sock *,
    200 		      struct proc *, struct mbuf **));
    201 int nfsrv_fsinfo __P((struct nfsrv_descript *, struct nfssvc_sock *,
    202 		      struct proc *, struct mbuf **));
    203 int nfsrv_pathconf __P((struct nfsrv_descript *, struct nfssvc_sock *,
    204 		        struct proc *, struct mbuf **));
    205 int nfsrv_null __P((struct nfsrv_descript *, struct nfssvc_sock *,
    206 		    struct proc *, struct mbuf **));
    207 int nfsrv_noop __P((struct nfsrv_descript *, struct nfssvc_sock *,
    208 		    struct proc *, struct mbuf **));
    209 int nfsrv_access __P((struct vnode *, int, struct ucred *, int, struct proc *,
    210 		      int));
    211 
    212 /* nfs_socket.c */
    213 int nfs_connect __P((struct nfsmount *, struct nfsreq *));
    214 int nfs_reconnect __P((struct nfsreq *));
    215 void nfs_disconnect __P((struct nfsmount *));
    216 void nfs_safedisconnect __P((struct nfsmount *));
    217 int nfs_send __P((struct socket *, struct mbuf *, struct mbuf *,
    218 		  struct nfsreq *));
    219 int nfs_receive __P((struct nfsreq *, struct mbuf **, struct mbuf **));
    220 int nfs_reply __P((struct nfsreq *));
    221 int nfs_request __P((struct nfsnode *, struct mbuf *, int, struct proc *,
    222 		     struct ucred *, struct mbuf **, struct mbuf **,
    223 		     caddr_t *));
    224 int nfs_rephead __P((int, struct nfsrv_descript *, struct nfssvc_sock *,
    225 		     int, int, u_quad_t *, struct mbuf **, struct mbuf **,			     caddr_t *));
    226 void nfs_timer __P((void *));
    227 int nfs_sigintr __P((struct nfsmount *, struct nfsreq *, struct proc *));
    228 int nfs_sndlock __P((int *, struct nfsreq *));
    229 void nfs_exit __P((struct proc *, void *));
    230 void nfs_sndunlock __P((int *));
    231 int nfs_rcvlock __P((struct nfsreq *));
    232 void nfs_rcvunlock __P((struct nfsmount *));
    233 int nfs_getreq __P((struct nfsrv_descript *, struct nfsd *, int));
    234 int nfs_msg __P((struct proc *, char *, char *));
    235 void nfsrv_rcv __P((struct socket *, caddr_t, int));
    236 int nfsrv_getstream __P((struct nfssvc_sock *, int));
    237 int nfsrv_dorec __P((struct nfssvc_sock *, struct nfsd *,
    238 		     struct nfsrv_descript **));
    239 void nfsrv_wakenfsd __P((struct nfssvc_sock *));
    240 
    241 /* nfs_srvcache.c */
    242 void nfsrv_initcache __P((void ));
    243 int nfsrv_getcache __P((struct nfsrv_descript *, struct nfssvc_sock *,
    244 			struct mbuf **));
    245 void nfsrv_updatecache __P((struct nfsrv_descript *, int, struct mbuf *));
    246 void nfsrv_cleancache __P((void));
    247 
    248 /* nfs_subs.c */
    249 struct mbuf *nfsm_reqh __P((struct nfsnode *, u_long, int, caddr_t *));
    250 struct mbuf *nfsm_rpchead __P((struct ucred *, int, int, int, int, char *, int,
    251 			       char *, struct mbuf *, int, struct mbuf **,
    252 			       u_int32_t *));
    253 int nfsm_mbuftouio __P((struct mbuf **, struct uio *, int, caddr_t *));
    254 int nfsm_uiotombuf __P((struct uio *, struct mbuf **, int, caddr_t *));
    255 int nfsm_disct __P((struct mbuf **, caddr_t *, int, int, caddr_t *));
    256 int nfs_adv __P((struct mbuf **, caddr_t *, int, int));
    257 int nfsm_strtmbuf __P((struct mbuf **, char **, const char *, long));
    258 u_long nfs_dirhash __P((off_t));
    259 void nfs_initdircache __P((struct vnode *));
    260 void nfs_initdirxlatecookie __P((struct vnode *));
    261 struct nfsdircache *nfs_searchdircache __P((struct vnode *, off_t, int, int *));
    262 struct nfsdircache *nfs_enterdircache __P((struct vnode *, off_t, off_t,						   int, daddr_t));
    263 void nfs_invaldircache __P((struct vnode *, int));
    264 void nfs_init __P((void));
    265 int nfsm_loadattrcache __P((struct vnode **, struct mbuf **, caddr_t *,
    266 			   struct vattr *, int flags));
    267 int nfs_loadattrcache __P((struct vnode **, struct nfs_fattr *,
    268 			   struct vattr *, int flags));
    269 int nfs_getattrcache __P((struct vnode *, struct vattr *));
    270 void nfs_delayedtruncate __P((struct vnode *));
    271 int nfs_namei __P((struct nameidata *, fhandle_t *, uint32_t,
    272 		   struct nfssvc_sock *, struct mbuf *, struct mbuf **,
    273 		   caddr_t *, struct vnode **, struct proc *, int, int));
    274 void nfs_zeropad __P((struct mbuf *, int, int));
    275 void nfsm_srvwcc __P((struct nfsrv_descript *, int, struct vattr *, int,
    276 		      struct vattr *, struct mbuf **, char **));
    277 void nfsm_srvpostopattr __P((struct nfsrv_descript *, int, struct vattr *,
    278 			     struct mbuf **, char **));
    279 void nfsm_srvfattr __P((struct nfsrv_descript *, struct vattr *,
    280 			struct nfs_fattr *));
    281 int nfsrv_fhtovp __P((fhandle_t *, int, struct vnode **, struct ucred *,
    282 		      struct nfssvc_sock *, struct mbuf *, int *, int, int));
    283 int nfsrv_setpublicfs __P((struct mount *, struct netexport *,
    284 			   struct export_args *));
    285 int nfs_ispublicfh __P((fhandle_t *));
    286 int netaddr_match __P((int, union nethostaddr *, struct mbuf *));
    287 
    288 /* flags for nfs_loadattrcache and friends */
    289 #define	NAC_NOTRUNC	1	/* don't truncate file size */
    290 
    291 void nfs_clearcommit __P((struct mount *));
    292 void nfs_merge_commit_ranges __P((struct vnode *));
    293 int nfs_in_committed_range __P((struct vnode *, off_t, off_t));
    294 int nfs_in_tobecommitted_range __P((struct vnode *, off_t, off_t));
    295 void nfs_add_committed_range __P((struct vnode *, off_t, off_t));
    296 void nfs_del_committed_range __P((struct vnode *, off_t, off_t));
    297 void nfs_add_tobecommitted_range __P((struct vnode *, off_t, off_t));
    298 void nfs_del_tobecommitted_range __P((struct vnode *, off_t, off_t));
    299 
    300 int nfsrv_errmap __P((struct nfsrv_descript *, int));
    301 void nfsrvw_sort __P((gid_t *, int));
    302 void nfsrv_setcred __P((struct ucred *, struct ucred *));
    303 void nfs_cookieheuristic __P((struct vnode *, int *, struct proc *,
    304 			      struct ucred *));
    305 
    306 u_int32_t nfs_getxid __P((void));
    307 void nfs_renewxid __P((struct nfsreq *));
    308 
    309 /* nfs_syscalls.c */
    310 int sys_getfh __P((struct lwp *, void *, register_t *));
    311 int sys_nfssvc __P((struct lwp *, void *, register_t *));
    312 int nfssvc_addsock __P((struct file *, struct mbuf *));
    313 int nfssvc_nfsd __P((struct nfsd_srvargs *, caddr_t, struct lwp *));
    314 void nfsrv_zapsock __P((struct nfssvc_sock *));
    315 void nfsrv_slpderef __P((struct nfssvc_sock *));
    316 void nfsrv_init __P((int));
    317 int nfssvc_iod __P((struct lwp *));
    318 void nfs_iodinit __P((void));
    319 void start_nfsio __P((void *));
    320 void nfs_getset_niothreads __P((int));
    321 int nfs_getauth __P((struct nfsmount *, struct nfsreq *, struct ucred *,
    322 		     char **, int *, char *, int *, NFSKERBKEY_T));
    323 int nfs_getnickauth __P((struct nfsmount *, struct ucred *, char **, int *,
    324 			 char *, int));
    325 int nfs_savenickauth __P((struct nfsmount *, struct ucred *, int, NFSKERBKEY_T,
    326 			  struct mbuf **, char **, struct mbuf *));
    327 #endif /* _KERNEL */
    328