Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 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
 * U9FS mount option flags
52
 */
53
#define	U9FSMNT_SOFT		0x00000001  /* soft mount (hard is default) */
54
#define	U9FSMNT_MAXGRPS		0x00000020  /* set maximum grouplist size */
55
#define	U9FSMNT_INT		0x00000040  /* allow interrupts on hard mount */
56
#define	U9FSMNT_KERB		0x00000400  /* Use Kerberos authentication */
57
#define	U9FSMNT_READAHEAD	0x00002000  /* set read ahead */
58
 
59
struct p9user {
60
  uid_t p9_uid;
61
  char p9_name[U9FS_NAMELEN];
62
};
63
 
64
/*
65
 * Arguments to mount 9FS
66
 */
67
#define U9FS_ARGSVERSION	1	/* change when nfs_args changes */
68
struct u9fs_args {
69
	int		version;	/* args structure version number */
70
	struct sockaddr	*addr;		/* file server address */
71
	int		addrlen;	/* length of address */
72
	int		sotype;		/* Socket type */
73
	int		proto;		/* and Protocol */
74
	int		fhsize;		/* Size, in bytes, of fh */
75
	int		flags;		/* flags */
76
	int		wsize;		/* write size in bytes */
77
	int		rsize;		/* read size in bytes */
78
	int		readdirsize;	/* readdir size in bytes */
79
	char		*hostname;	/* server's name */
80
        struct sockaddr * authaddr;
81
        int             authaddrlen;
82
        int             authsotype;
83
        int             authsoproto;
84
        int             nusers;
85
        char            uname[U9FS_NAMELEN];
86
        char            key[U9AUTH_DESKEYLEN];
87
        struct p9user * users;
88
};
89
 
90
/*
91
 * The u9fsnode is the u9fs equivalent to ufs's inode. Any similarity
92
 * is purely coincidental.
93
 * There is a unique u9fsnode allocated for each active file,
94
 * each current directory, each mounted-on file, text file, and the root.
95
 * An u9fsnode is 'named' by its file handle. (nget/u9fs_node.c)
96
 * If this structure exceeds 256 bytes (it is currently 256 using 4.4BSD-Lite
97
 * type definitions), file handles of > 32 bytes should probably be split out
98
 * into a separate MALLOC()'d data structure. (Reduce the size of u9fsfh_t by
99
 * changing the definition in u9fsproto.h of U9FS_SMALLFH.)
100
 * NB: Hopefully the current order of the fields is such that everything will
101
 *     be well aligned and, therefore, tightly packed.
102
 */
103
struct u9fsnode {
104
	LIST_ENTRY(u9fsnode)	n_hash;		/* Hash chain */
105
	u_quad_t		n_size;		/* Current size of file */
106
	u_quad_t		n_lrev;		/* Modify rev for lease */
107
	struct vattr		n_vattr;	/* Vnode attribute cache */
108
	time_t			n_attrstamp;	/* Attr. cache timestamp */
109
	u_int32_t		n_mode;		/* ACCESS mode cache */
110
	uid_t			n_modeuid;	/* credentials having mode */
111
	time_t			n_modestamp;	/* mode cache timestamp */
112
	time_t			n_mtime;	/* Prev modify time. */
113
	time_t			n_ctime;	/* Prev create time. */
114
	u_short			*n_fid;		/* U9FS FID */
115
	struct vnode		*n_vnode;	/* associated vnode */
116
	struct lockf		*n_lockf;	/* Locking record of file */
117
	int			n_error;	/* Save write error value */
118
#if 0
119
	union {
120
		struct timespec	nf_atim;	/* Special file times */
121
		u9fsuint64	nd_cookieverf;	/* Cookie verifier (dir only) */
122
	} n_un1;
123
	union {
124
		struct timespec	nf_mtim;
125
		off_t		nd_direof;	/* Dir. EOF offset cache */
126
	} n_un2;
127
	union {
128
		struct sillyrename *nf_silly;	/* Ptr to silly rename struct */
129
		LIST_HEAD(, u9fsdmap) nd_cook;	/* cookies */
130
	} n_un3;
131
#endif
132
	short			n_flag;		/* Flag for locking.. */
133
};
134
 
135
#define n_atim		n_un1.nf_atim
136
#define n_mtim		n_un2.nf_mtim
137
#define n_sillyrename	n_un3.nf_silly
138
#define n_cookieverf	n_un1.nd_cookieverf
139
#define n_direofoffset	n_un2.nd_direof
140
#define n_cookies	n_un3.nd_cook
141
 
142
/*
143
 * Flags for n_flag
144
 */
145
#define	NFLUSHWANT	0x0001	/* Want wakeup from a flush in prog. */
146
#define	NFLUSHINPROG	0x0002	/* Avoid multiple calls to vinvalbuf() */
147
#define	NMODIFIED	0x0004	/* Might have a modified buffer in bio */
148
#define	NWRITEERR	0x0008	/* Flag write errors so close will know */
149
#define	NQU9FSNONCACHE	0x0020	/* Non-cachable lease */
150
#define	NQU9FSWRITE	0x0040	/* Write lease */
151
#define	NQU9FSEVICTED	0x0080	/* Has been evicted */
152
#define	NACC		0x0100	/* Special file accessed */
153
#define	NUPD		0x0200	/* Special file updated */
154
#define	NCHG		0x0400	/* Special file times changed */
155
#define NLOCKED		0x0800  /* node is locked */
156
#define NWANTED		0x0100  /* someone wants to lock */
157
 
158
/*
159
 * Convert between u9fsnode pointers and vnode pointers
160
 */
161
#define VTOU9FS(vp)	((struct u9fsnode *)(vp)->v_data)
162
#define U9FSTOV(np)	((struct vnode *)(np)->n_vnode)
163
 
164
/*
165
 * Mount structure.
166
 * One allocated on every U9FS mount.
167
 * Holds U9FS specific information for mount.
168
 */
169
struct	u9fsmount {
170
	int	nm_flag;		/* Flags for soft/hard... */
171
	int	nm_state;		/* Internal state flags */
172
	struct	mount *nm_mountp;	/* Vfs structure for this filesystem */
173
	int	nm_numgrps;		/* Max. size of groupslist */
174
	u_short	nm_fid;	                /* fid of root dir */
175
	struct	socket *nm_so;		/* Rpc socket */
176
	int	nm_sotype;		/* Type of socket */
177
	int	nm_soproto;		/* and protocol */
178
	int	nm_soflags;		/* pr_flags for socket protocol */
179
	struct	sockaddr *nm_nam;	/* Addr of server */
180
	int	nm_sent;		/* Request send count */
181
	int	nm_cwnd;		/* Request send window */
182
	int	nm_rsize;		/* Max size of read rpc */
183
	int	nm_wsize;		/* Max size of write rpc */
184
	int	nm_readdirsize;		/* Size of a readdir rpc */
185
#if 0
186
	struct vnode *nm_inprog;	/* Vnode in prog by nqu9fs_clientd() */
187
	uid_t	nm_authuid;		/* Uid for authenticator */
188
	int	nm_authtype;		/* Authenticator type */
189
	int	nm_authlen;		/* and length */
190
	char	*nm_authstr;		/* Authenticator string */
191
	char	*nm_verfstr;		/* and the verifier */
192
	int	nm_verflen;
193
	u_char	nm_verf[U9FSX_V3WRITEVERF]; /* V3 write verifier */
194
	U9FSKERBKEY_T nm_key;		/* and the session key */
195
	int	nm_numuids;		/* Number of u9fsuid mappings */
196
	TAILQ_HEAD(, u9fsuid) nm_uidlruhead; /* Lists of u9fsuid mappings */
197
	LIST_HEAD(, u9fsuid) nm_uidhashtbl[U9FS_MUIDHASHSIZ];
198
	TAILQ_HEAD(, buf) nm_bufq;	/* async io buffer queue */
199
	short	nm_bufqlen;		/* number of buffers in queue */
200
	short	nm_bufqwant;		/* process wants to add to the queue */
201
	int	nm_bufqiods;		/* number of iods processing queue */
202
#endif
203
	u_int64_t nm_maxfilesize;	/* maximum file size */
204
};
205
 
206
#ifdef KERNEL
207
 
208
#ifdef MALLOC_DECLARE
209
MALLOC_DECLARE(M_U9FSHASH);
210
#endif
211
 
212
/*
213
 * Convert mount ptr to u9fsmount ptr.
214
 */
215
#define VFSTOU9FS(mp)	((struct u9fsmount *)((mp)->mnt_data))
216
 
217
#endif	/* KERNEL */
218
 
219
#endif