1 /* $OpenBSD: nfsnode.h,v 1.18 2003/06/02 23:28:20 millert Exp $ */ 2 /* $NetBSD: nfsnode.h,v 1.16 1996/02/18 11:54:04 fvdl Exp $ */ 3 4 /* 5 * Copyright (c) 1989, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed to Berkeley by 9 * Rick Macklem at The University of Guelph. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)nfsnode.h 8.9 (Berkeley) 5/14/95 36 */ 37 38 39 #ifndef _NFS_NFSNODE_H_ 40 #define _NFS_NFSNODE_H_ 41 42 #ifndef _NFS_NFS_H_ 43 #include <nfs/nfs.h> 44 #endif 45 46 /* 47 * Silly rename structure that hangs off the nfsnode until the name 48 * can be removed by nfs_inactive() 49 */ 50 struct sillyrename { 51 struct ucred *s_cred; 52 struct vnode *s_dvp; 53 long s_namlen; 54 char s_name[20]; 55 }; 56 57 /* 58 * This structure is used to save the logical directory offset to 59 * NFS cookie mappings. 60 * The mappings are stored in a list headed 61 * by n_cookies, as required. 62 * There is one mapping for each NFS_DIRBLKSIZ bytes of directory information 63 * stored in increasing logical offset byte order. 64 */ 65 #define NFSNUMCOOKIES 31 66 67 struct nfsdmap { 68 LIST_ENTRY(nfsdmap) ndm_list; 69 int ndm_eocookie; 70 nfsuint64 ndm_cookies[NFSNUMCOOKIES]; 71 }; 72 73 /* 74 * The nfsnode is the nfs equivalent to ufs's inode. Any similarity 75 * is purely coincidental. 76 * There is a unique nfsnode allocated for each active file, 77 * each current directory, each mounted-on file, text file, and the root. 78 * An nfsnode is 'named' by its file handle. (nget/nfs_node.c) 79 * If this structure exceeds 256 bytes (it is currently 256 using 4.4BSD-Lite 80 * type definitions), file handles of > 32 bytes should probably be split out 81 * into a separate MALLOC()'d data structure. (Reduce the size of nfsfh_t by 82 * changing the definition in sys/mount.h of NFS_SMALLFH.) 83 * NB: Hopefully the current order of the fields is such that everything will 84 * be well aligned and, therefore, tightly packed. 85 */ 86 struct nfsnode { 87 LIST_ENTRY(nfsnode) n_hash; /* Hash chain */ 88 CIRCLEQ_ENTRY(nfsnode) n_timer; /* Nqnfs timer chain */ 89 u_quad_t n_size; /* Current size of file */ 90 u_quad_t n_brev; /* Modify rev when cached */ 91 u_quad_t n_lrev; /* Modify rev for lease */ 92 struct vattr n_vattr; /* Vnode attribute cache */ 93 time_t n_attrstamp; /* Attr. cache timestamp */ 94 time_t n_mtime; /* Prev modify time. */ 95 time_t n_ctime; /* Prev create time. */ 96 time_t n_expiry; /* Lease expiry time */ 97 nfsfh_t *n_fhp; /* NFS File Handle */ 98 struct vnode *n_vnode; /* associated vnode */ 99 struct lockf *n_lockf; /* Locking record of file */ 100 int n_error; /* Save write error value */ 101 union { 102 struct timespec nf_atim; /* Special file times */ 103 nfsuint64 nd_cookieverf; /* Cookie verifier (dir only) */ 104 } n_un1; 105 union { 106 struct timespec nf_mtim; 107 off_t nd_direof; /* Dir. EOF offset cache */ 108 } n_un2; 109 union { 110 struct sillyrename *nf_silly; /* Ptr to silly rename struct */ 111 LIST_HEAD(, nfsdmap) nd_cook; /* cookies */ 112 } n_un3; 113 short n_fhsize; /* size in bytes, of fh */ 114 short n_flag; /* Flag for locking.. */ 115 nfsfh_t n_fh; /* Small File Handle */ 116 struct ucred *n_rcred; 117 struct ucred *n_wcred; 118 }; 119 120 #define n_atim n_un1.nf_atim 121 #define n_mtim n_un2.nf_mtim 122 #define n_sillyrename n_un3.nf_silly 123 #define n_cookieverf n_un1.nd_cookieverf 124 #define n_direofoffset n_un2.nd_direof 125 #define n_cookies n_un3.nd_cook 126 127 /* 128 * Flags for n_flag 129 */ 130 #define NFLUSHWANT 0x0001 /* Want wakeup from a flush in prog. */ 131 #define NFLUSHINPROG 0x0002 /* Avoid multiple calls to vinvalbuf() */ 132 #define NMODIFIED 0x0004 /* Might have a modified buffer in bio */ 133 #define NWRITEERR 0x0008 /* Flag write errors so close will know */ 134 #define NACC 0x0100 /* Special file accessed */ 135 #define NUPD 0x0200 /* Special file updated */ 136 #define NCHG 0x0400 /* Special file times changed */ 137 138 /* 139 * Convert between nfsnode pointers and vnode pointers 140 */ 141 #define VTONFS(vp) ((struct nfsnode *)(vp)->v_data) 142 #define NFSTOV(np) ((np)->n_vnode) 143 144 /* 145 * Queue head for nfsiod's 146 */ 147 extern TAILQ_HEAD(nfs_bufqhead, buf) nfs_bufq; 148 149 #ifdef _KERNEL 150 /* 151 * Prototypes for NFS vnode operations 152 */ 153 int nfs_lookup(void *); 154 int nfs_create(void *); 155 int nfs_mknod(void *); 156 int nfs_open(void *); 157 int nfs_close(void *); 158 int nfsspec_close(void *); 159 int nfsfifo_close(void *); 160 int nfs_access(void *); 161 int nfsspec_access(void *); 162 int nfs_getattr(void *); 163 int nfs_setattr(void *); 164 int nfs_read(void *); 165 int nfs_write(void *); 166 #define nfs_lease_check ((int (*)(void *))nullop) 167 #define nqnfs_vop_lease_check lease_check 168 int nfsspec_read(void *); 169 int nfsspec_write(void *); 170 int nfsfifo_read(void *); 171 int nfsfifo_write(void *); 172 #define nfs_ioctl ((int (*)(void *))enoioctl) 173 #define nfs_select ((int (*)(void *))seltrue) 174 #define nfs_revoke vop_generic_revoke 175 int nfs_fsync(void *); 176 int nfs_remove(void *); 177 int nfs_link(void *); 178 int nfs_rename(void *); 179 int nfs_mkdir(void *); 180 int nfs_rmdir(void *); 181 int nfs_symlink(void *); 182 int nfs_readdir(void *); 183 int nfs_readlink(void *); 184 int nfs_inactive(void *); 185 int nfs_reclaim(void *); 186 #define nfs_lock ((int (*)(void *))vop_generic_lock) 187 #define nfs_unlock ((int (*)(void *))vop_generic_unlock) 188 #define nfs_islocked ((int (*)(void *))vop_generic_islocked) 189 int nfs_bmap(void *); 190 int nfs_strategy(void *); 191 int nfs_print(void *); 192 int nfs_pathconf(void *); 193 int nfs_advlock(void *); 194 int nfs_bwrite(void *); 195 int nfs_vget(struct mount *, ino_t, struct vnode **); 196 #define nfs_reallocblks \ 197 ((int (*)(void *))eopnotsupp) 198 199 /* other stuff */ 200 int nfs_removeit(struct sillyrename *); 201 int nfs_nget(struct mount *,nfsfh_t *,int,struct nfsnode **); 202 int nfs_lookitup(struct vnode *,char *,int,struct ucred *,struct proc *,struct nfsnode **); 203 int nfs_sillyrename(struct vnode *,struct vnode *,struct componentname *); 204 205 extern int (**nfsv2_vnodeop_p)(void *); 206 207 #endif /* _KERNEL */ 208 209 #endif 210