68 |
7u83 |
1 |
/*
|
|
|
2 |
* Copyright (c) 1989, 1993, 1995
|
|
|
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 |
* 3. All advertising materials mentioning features or use of this software
|
|
|
17 |
* must display the following acknowledgement:
|
|
|
18 |
* This product includes software developed by the University of
|
|
|
19 |
* California, Berkeley and its contributors.
|
|
|
20 |
* 4. Neither the name of the University nor the names of its contributors
|
|
|
21 |
* may be used to endorse or promote products derived from this software
|
|
|
22 |
* without specific prior written permission.
|
|
|
23 |
*
|
|
|
24 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
25 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
26 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
27 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
28 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
29 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
30 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
31 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
32 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
33 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
34 |
* SUCH DAMAGE.
|
|
|
35 |
*
|
|
|
36 |
* @(#)nfs.h 8.4 (Berkeley) 5/1/95
|
|
|
37 |
* $Id: nfs.h,v 1.44 1998/09/07 05:42:15 bde Exp $
|
|
|
38 |
*/
|
|
|
39 |
|
|
|
40 |
#ifndef _9FS_H_
|
|
|
41 |
#define _9FS_H_
|
|
|
42 |
|
|
|
43 |
#ifdef KERNEL
|
|
|
44 |
#include "opt_u9fs.h"
|
|
|
45 |
#endif
|
|
|
46 |
|
|
|
47 |
#define U9FS_FABLKSIZE 512
|
|
|
48 |
#define U9FS_PORT 17008
|
|
|
49 |
|
|
|
50 |
/*
|
|
|
51 |
* The set of signals the interrupt an I/O in progress for U9FSMNT_INT mounts.
|
|
|
52 |
* What should be in this set is open to debate, but I believe that since
|
|
|
53 |
* I/O system calls on ufs are never interrupted by signals the set should
|
|
|
54 |
* be minimal. My reasoning is that many current programs that use signals
|
|
|
55 |
* such as SIGALRM will not expect file I/O system calls to be interrupted
|
|
|
56 |
* by them and break.
|
|
|
57 |
*/
|
|
|
58 |
#define U9FSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
|
|
|
59 |
sigmask(SIGHUP)|sigmask(SIGQUIT))
|
|
|
60 |
|
|
|
61 |
/*
|
|
|
62 |
* U9FS mount option flags
|
|
|
63 |
*/
|
|
|
64 |
#define U9FSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
|
|
|
65 |
#define U9FSMNT_MAXGRPS 0x00000020 /* set maximum grouplist size */
|
|
|
66 |
#define U9FSMNT_INT 0x00000040 /* allow interrupts on hard mount */
|
|
|
67 |
#define U9FSMNT_KERB 0x00000400 /* Use Kerberos authentication */
|
|
|
68 |
#define U9FSMNT_READAHEAD 0x00002000 /* set read ahead */
|
|
|
69 |
|
|
|
70 |
#define U9FSSTA_HASWRITEVERF 0x00040000 /* Has write verifier for V3 */
|
|
|
71 |
#define U9FSSTA_GOTPATHCONF 0x00080000 /* Got the V3 pathconf info */
|
|
|
72 |
#define U9FSSTA_GOTFSINFO 0x00100000 /* Got the V3 fsinfo */
|
|
|
73 |
#define U9FSSTA_MNTD 0x00200000 /* Mnt server for mnt point */
|
|
|
74 |
#define U9FSSTA_DISMINPROG 0x00400000 /* Dismount in progress */
|
|
|
75 |
#define U9FSSTA_DISMNT 0x00800000 /* Dismounted */
|
|
|
76 |
#define U9FSSTA_SNDLOCK 0x01000000 /* Send socket lock */
|
|
|
77 |
#define U9FSSTA_WANTSND 0x02000000 /* Want above */
|
|
|
78 |
#define U9FSSTA_RCVLOCK 0x04000000 /* Rcv socket lock */
|
|
|
79 |
#define U9FSSTA_WANTRCV 0x08000000 /* Want above */
|
|
|
80 |
#define U9FSSTA_WAITAUTH 0x10000000 /* Wait for authentication */
|
|
|
81 |
#define U9FSSTA_HASAUTH 0x20000000 /* Has authenticator */
|
|
|
82 |
#define U9FSSTA_WANTAUTH 0x40000000 /* Wants an authenticator */
|
|
|
83 |
#define U9FSSTA_AUTHERR 0x80000000 /* Authentication error */
|
|
|
84 |
|
|
|
85 |
#define U9FSNOHASH(fhsum) (&u9fsnodehashtbl[(fhsum) % u9fsnodehash])
|
|
|
86 |
|
|
|
87 |
/*
|
|
|
88 |
* Arguments to mount 9FS
|
|
|
89 |
*/
|
|
|
90 |
#define U9FS_ARGSVERSION 1 /* change when nfs_args changes */
|
|
|
91 |
struct u9fs_args {
|
|
|
92 |
int version; /* args structure version number */
|
|
|
93 |
struct sockaddr *addr; /* file server address */
|
|
|
94 |
int addrlen; /* length of address */
|
|
|
95 |
int sotype; /* Socket type */
|
|
|
96 |
int proto; /* and Protocol */
|
|
|
97 |
int fhsize; /* Size, in bytes, of fh */
|
|
|
98 |
int flags; /* flags */
|
|
|
99 |
int wsize; /* write size in bytes */
|
|
|
100 |
int rsize; /* read size in bytes */
|
|
|
101 |
int readdirsize; /* readdir size in bytes */
|
|
|
102 |
char *hostname; /* server's name */
|
|
|
103 |
|
|
|
104 |
struct sockaddr * authaddr;
|
|
|
105 |
int authaddrlen;
|
|
|
106 |
int authsotype;
|
|
|
107 |
int authsoproto;
|
|
|
108 |
|
|
|
109 |
int nusers;
|
|
|
110 |
char user[U9FS_NAMELEN];
|
|
|
111 |
char key[U9AUTH_DESKEYLEN];
|
|
|
112 |
struct p9user {
|
|
|
113 |
uid_t p9_uid;
|
|
|
114 |
char p9_name[U9FS_NAMELEN];
|
|
|
115 |
} * users;
|
|
|
116 |
};
|
|
|
117 |
|
|
|
118 |
#define U9FS_USER_HASHSIZE 512
|
|
|
119 |
|
|
|
120 |
struct u9fsuser {
|
|
|
121 |
LIST_ENTRY(u9fsuser) u_hash;
|
|
|
122 |
uid_t u_uid;
|
|
|
123 |
char u_name[U9FS_NAMELEN];
|
|
|
124 |
char u_ckey[U9AUTH_DESKEYLEN]; /* user key */
|
|
|
125 |
char u_skey[U9AUTH_DESKEYLEN]; /* session key */
|
|
|
126 |
};
|
|
|
127 |
|
|
|
128 |
/*
|
|
|
129 |
* The u9fsnode is the u9fs equivalent to ufs's inode. Any similarity
|
|
|
130 |
* is purely coincidental.
|
|
|
131 |
* There is a unique u9fsnode allocated for each active file,
|
|
|
132 |
* each current directory, each mounted-on file, text file, and the root.
|
|
|
133 |
* An u9fsnode is 'named' by its file handle. (nget/u9fs_node.c)
|
|
|
134 |
* If this structure exceeds 256 bytes (it is currently 256 using 4.4BSD-Lite
|
|
|
135 |
* type definitions), file handles of > 32 bytes should probably be split out
|
|
|
136 |
* into a separate MALLOC()'d data structure. (Reduce the size of u9fsfh_t by
|
|
|
137 |
* changing the definition in u9fsproto.h of U9FS_SMALLFH.)
|
|
|
138 |
* NB: Hopefully the current order of the fields is such that everything will
|
|
|
139 |
* be well aligned and, therefore, tightly packed.
|
|
|
140 |
*/
|
|
|
141 |
struct u9fsnode {
|
|
|
142 |
LIST_ENTRY(u9fsnode) n_hash; /* Hash chain */
|
|
|
143 |
u_quad_t n_size; /* Current size of file */
|
|
|
144 |
struct vattr n_vattr; /* Vnode attribute cache */
|
|
|
145 |
time_t n_attrstamp; /* Attr. cache timestamp */
|
|
|
146 |
u_int32_t n_mode; /* ACCESS mode cache */
|
|
|
147 |
uid_t n_modeuid; /* credentials having mode */
|
|
|
148 |
time_t n_modestamp; /* mode cache timestamp */
|
|
|
149 |
time_t n_mtime; /* Prev modify time. */
|
|
|
150 |
time_t n_ctime; /* Prev create time. */
|
|
|
151 |
struct u9fs_qid n_qid;
|
|
|
152 |
u_short n_fid; /* U9FS FID */
|
|
|
153 |
u_short n_rdfid;
|
|
|
154 |
u_short n_wrfid;
|
|
|
155 |
struct vnode *n_vnode; /* associated vnode */
|
|
|
156 |
struct lockf *n_lockf; /* Locking record of file */
|
|
|
157 |
int n_error; /* Save write error value */
|
|
|
158 |
struct u9fsdir n_dir;
|
|
|
159 |
short n_flag; /* Flag for locking.. */
|
|
|
160 |
int n_opens; /* number of opens */
|
|
|
161 |
};
|
|
|
162 |
|
|
|
163 |
#define n_atim n_un1.nf_atim
|
|
|
164 |
#define n_mtim n_un2.nf_mtim
|
|
|
165 |
#define n_sillyrename n_un3.nf_silly
|
|
|
166 |
#define n_cookieverf n_un1.nd_cookieverf
|
|
|
167 |
#define n_direofoffset n_un2.nd_direof
|
|
|
168 |
#define n_cookies n_un3.nd_cook
|
|
|
169 |
|
|
|
170 |
/*
|
|
|
171 |
* Flags for n_flag
|
|
|
172 |
*/
|
|
|
173 |
#define NFLUSHWANT 0x0001 /* Want wakeup from a flush in prog. */
|
|
|
174 |
#define NFLUSHINPROG 0x0002 /* Avoid multiple calls to vinvalbuf() */
|
|
|
175 |
#define NMODIFIED 0x0004 /* Might have a modified buffer in bio */
|
|
|
176 |
#define NWRITEERR 0x0008 /* Flag write errors so close will know */
|
|
|
177 |
#define NQU9FSNONCACHE 0x0020 /* Non-cachable lease */
|
|
|
178 |
#define NQU9FSWRITE 0x0040 /* Write lease */
|
|
|
179 |
#define NQU9FSEVICTED 0x0080 /* Has been evicted */
|
|
|
180 |
#define NACC 0x0100 /* Special file accessed */
|
|
|
181 |
#define NUPD 0x0200 /* Special file updated */
|
|
|
182 |
#define NCHG 0x0400 /* Special file times changed */
|
|
|
183 |
#define NLOCKED 0x0800 /* node is locked */
|
|
|
184 |
#define NWANTED 0x0100 /* someone wants to lock */
|
|
|
185 |
|
|
|
186 |
/*
|
|
|
187 |
* Convert between u9fsnode pointers and vnode pointers
|
|
|
188 |
*/
|
|
|
189 |
#define VTOU9FS(vp) ((struct u9fsnode *)(vp)->v_data)
|
|
|
190 |
#define U9FSTOV(np) ((struct vnode *)(np)->n_vnode)
|
|
|
191 |
|
|
|
192 |
/*
|
|
|
193 |
* Mount structure.
|
|
|
194 |
* One allocated on every U9FS mount.
|
|
|
195 |
* Holds U9FS specific information for mount.
|
|
|
196 |
*/
|
|
|
197 |
struct u9fsmount {
|
|
|
198 |
int nm_flag; /* Flags for soft/hard... */
|
|
|
199 |
int nm_state; /* Internal state flags */
|
|
|
200 |
struct mount *nm_mountp; /* Vfs structure for this filesystem */
|
|
|
201 |
int nm_numgrps; /* Max. size of groupslist */
|
|
|
202 |
u9fsfh_t nm_fh; /* qid.path */
|
|
|
203 |
u_short nm_fid; /* fid of root dir */
|
|
|
204 |
struct socket *nm_so; /* Rpc socket */
|
|
|
205 |
int nm_sotype; /* Type of socket */
|
|
|
206 |
int nm_soproto; /* and protocol */
|
|
|
207 |
int nm_soflags; /* pr_flags for socket protocol */
|
|
|
208 |
struct sockaddr *nm_nam; /* Addr of server */
|
|
|
209 |
int nm_sent; /* Request send count */
|
|
|
210 |
int nm_cwnd; /* Request send window */
|
|
|
211 |
int nm_rsize; /* Max size of read rpc */
|
|
|
212 |
int nm_wsize; /* Max size of write rpc */
|
|
|
213 |
int nm_readdirsize; /* Size of a readdir rpc */
|
|
|
214 |
|
|
|
215 |
struct lock nm_lock; /* lock for tag/fid freelist */
|
|
|
216 |
bitstr_t * nm_tags;
|
|
|
217 |
bitstr_t * nm_fids;
|
|
|
218 |
TAILQ_HEAD(u9fs_reqq, u9fsreq) nm_reqq;
|
|
|
219 |
|
|
|
220 |
uid_t nm_authuid; /* Uid for authenticator */
|
|
|
221 |
#if 0
|
|
|
222 |
struct vnode *nm_inprog; /* Vnode in prog by nqu9fs_clientd() */
|
|
|
223 |
uid_t nm_authuid; /* Uid for authenticator */
|
|
|
224 |
int nm_authtype; /* Authenticator type */
|
|
|
225 |
int nm_authlen; /* and length */
|
|
|
226 |
char *nm_authstr; /* Authenticator string */
|
|
|
227 |
char *nm_verfstr; /* and the verifier */
|
|
|
228 |
int nm_verflen;
|
|
|
229 |
u_char nm_verf[U9FSX_V3WRITEVERF]; /* V3 write verifier */
|
|
|
230 |
U9FSKERBKEY_T nm_key; /* and the session key */
|
|
|
231 |
int nm_numuids; /* Number of u9fsuid mappings */
|
|
|
232 |
TAILQ_HEAD(, u9fsuid) nm_uidlruhead; /* Lists of u9fsuid mappings */
|
|
|
233 |
LIST_HEAD(, u9fsuid) nm_uidhashtbl[U9FS_MUIDHASHSIZ];
|
|
|
234 |
TAILQ_HEAD(, buf) nm_bufq; /* async io buffer queue */
|
|
|
235 |
short nm_bufqlen; /* number of buffers in queue */
|
|
|
236 |
short nm_bufqwant; /* process wants to add to the queue */
|
|
|
237 |
int nm_bufqiods; /* number of iods processing queue */
|
|
|
238 |
#endif
|
|
|
239 |
u_int64_t nm_maxfilesize; /* maximum file size */
|
|
|
240 |
};
|
|
|
241 |
|
|
|
242 |
#ifdef KERNEL
|
|
|
243 |
|
|
|
244 |
#ifdef MALLOC_DECLARE
|
|
|
245 |
MALLOC_DECLARE(M_U9FSHASH);
|
|
|
246 |
MALLOC_DECLARE(M_U9FSBITS);
|
|
|
247 |
|
|
|
248 |
extern vop_t **u9fs_vnodeop_p;
|
|
|
249 |
|
|
|
250 |
/* u9fs_node.c */
|
|
|
251 |
void u9fs_nhinit __P((void));
|
|
|
252 |
int u9fs_nget __P((struct mount *mntp, u9fsfh_t fh, struct u9fsnode **npp, struct proc * p));
|
|
|
253 |
|
|
|
254 |
/* u9fs_subr.c */
|
|
|
255 |
void u9fs_id_init __P((bitstr_t ** bits));
|
|
|
256 |
u_short u9fs_id_new __P((bitstr_t * bits));
|
|
|
257 |
void u9fs_id_free __P((bitstr_t * bits, u_short v));
|
|
|
258 |
void u9fs_uhinit __P((void));
|
|
|
259 |
uid_t u9fs_name2uid __P((char * name));
|
|
|
260 |
struct u9fsuser * u9fs_finduser __P((uid_t uid));
|
|
|
261 |
void u9fs_hashuser __P((uid_t uid, char *name));
|
|
|
262 |
int u9fs_mbuftouio __P((struct mbuf *m, struct uio *uiop, int siz));
|
|
|
263 |
int u9fs_uiotombuf __P((struct uio *uiop, struct mbuf **mq, int siz));
|
|
|
264 |
|
|
|
265 |
/* u9fs_vnopes.c */
|
|
|
266 |
int u9fs_readdirrpc __P((struct vnode *, struct uio *, struct ucred *));
|
|
|
267 |
int u9fs_readrpc __P((struct vnode *vp, struct uio *uiop, struct ucred *cred));
|
|
|
268 |
int u9fs_writerpc __P((struct vnode *vp, struct uio *uiop, struct ucred *cred));
|
|
|
269 |
|
|
|
270 |
/* u9fs_bio.c */
|
|
|
271 |
int u9fs_bioread __P((struct vnode *, struct uio *, int, struct ucred *,int));
|
|
|
272 |
int u9fs_biowrite __P((struct vnode *, struct uio *, int ioflag, struct ucred *));
|
|
|
273 |
int u9fs_doio __P((struct buf *, struct ucred *, struct proc *));
|
|
|
274 |
int u9fs_vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *, int));
|
|
|
275 |
|
|
|
276 |
|
|
|
277 |
/* u9fs_socket.c */
|
|
|
278 |
int u9fs_sigintr __P((struct u9fsmount *nmp, struct proc *p));
|
|
|
279 |
void u9fs_disconnect __P((struct socket *));
|
|
|
280 |
int u9fs_connect __P((struct socket ** sop, struct sockaddr * saddr, int sotype, int soproto, struct proc * p));
|
|
|
281 |
int u9fs_connect_9fs __P((struct u9fsmount *));
|
|
|
282 |
int u9fs_connect_9auth __P((struct u9fsmount *, struct u9fs_args *, struct socket **));
|
|
|
283 |
int u9fs_request __P((struct u9fsreq * req, struct u9fsreq * rep, int relm));
|
|
|
284 |
|
|
|
285 |
#endif
|
|
|
286 |
|
|
|
287 |
/*
|
|
|
288 |
* Convert mount ptr to u9fsmount ptr.
|
|
|
289 |
*/
|
|
|
290 |
#define VFSTOU9FS(mp) ((struct u9fsmount *)((mp)->mnt_data))
|
|
|
291 |
|
|
|
292 |
#endif /* KERNEL */
|
|
|
293 |
|
|
|
294 |
#endif
|