blob: 8726491de15417d882d36e3184159f79c0bf525e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * include/linux/nfs4.h
3 *
4 * NFSv4 protocol definitions.
5 *
6 * Copyright (c) 2002 The Regents of the University of Michigan.
7 * All rights reserved.
8 *
9 * Kendrick Smith <kmsmith@umich.edu>
10 * Andy Adamson <andros@umich.edu>
11 */
12
13#ifndef _LINUX_NFS4_H
14#define _LINUX_NFS4_H
15
16#include <linux/types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Jeff Laytonaa53ed52007-06-05 14:49:03 -040018#define NFS4_BITMAP_SIZE 2
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#define NFS4_VERIFIER_SIZE 8
Trond Myklebust8ae20ab2007-05-14 16:50:45 -040020#define NFS4_STATEID_SIZE 16
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#define NFS4_FHSIZE 128
22#define NFS4_MAXPATHLEN PATH_MAX
23#define NFS4_MAXNAMLEN NAME_MAX
24
25#define NFS4_ACCESS_READ 0x0001
26#define NFS4_ACCESS_LOOKUP 0x0002
27#define NFS4_ACCESS_MODIFY 0x0004
28#define NFS4_ACCESS_EXTEND 0x0008
29#define NFS4_ACCESS_DELETE 0x0010
30#define NFS4_ACCESS_EXECUTE 0x0020
31
NeilBrown49640002005-06-23 22:02:58 -070032#define NFS4_FH_PERSISTENT 0x0000
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#define NFS4_FH_NOEXPIRE_WITH_OPEN 0x0001
34#define NFS4_FH_VOLATILE_ANY 0x0002
35#define NFS4_FH_VOL_MIGRATION 0x0004
36#define NFS4_FH_VOL_RENAME 0x0008
37
38#define NFS4_OPEN_RESULT_CONFIRM 0x0002
39#define NFS4_OPEN_RESULT_LOCKTYPE_POSIX 0x0004
40
41#define NFS4_SHARE_ACCESS_READ 0x0001
42#define NFS4_SHARE_ACCESS_WRITE 0x0002
43#define NFS4_SHARE_ACCESS_BOTH 0x0003
44#define NFS4_SHARE_DENY_READ 0x0001
45#define NFS4_SHARE_DENY_WRITE 0x0002
46#define NFS4_SHARE_DENY_BOTH 0x0003
47
48#define NFS4_SET_TO_SERVER_TIME 0
49#define NFS4_SET_TO_CLIENT_TIME 1
50
51#define NFS4_ACE_ACCESS_ALLOWED_ACE_TYPE 0
52#define NFS4_ACE_ACCESS_DENIED_ACE_TYPE 1
53#define NFS4_ACE_SYSTEM_AUDIT_ACE_TYPE 2
54#define NFS4_ACE_SYSTEM_ALARM_ACE_TYPE 3
55
56#define ACL4_SUPPORT_ALLOW_ACL 0x01
57#define ACL4_SUPPORT_DENY_ACL 0x02
58#define ACL4_SUPPORT_AUDIT_ACL 0x04
59#define ACL4_SUPPORT_ALARM_ACL 0x08
60
61#define NFS4_ACE_FILE_INHERIT_ACE 0x00000001
62#define NFS4_ACE_DIRECTORY_INHERIT_ACE 0x00000002
63#define NFS4_ACE_NO_PROPAGATE_INHERIT_ACE 0x00000004
64#define NFS4_ACE_INHERIT_ONLY_ACE 0x00000008
65#define NFS4_ACE_SUCCESSFUL_ACCESS_ACE_FLAG 0x00000010
66#define NFS4_ACE_FAILED_ACCESS_ACE_FLAG 0x00000020
67#define NFS4_ACE_IDENTIFIER_GROUP 0x00000040
68#define NFS4_ACE_OWNER 0x00000080
69#define NFS4_ACE_GROUP 0x00000100
70#define NFS4_ACE_EVERYONE 0x00000200
71
72#define NFS4_ACE_READ_DATA 0x00000001
73#define NFS4_ACE_LIST_DIRECTORY 0x00000001
74#define NFS4_ACE_WRITE_DATA 0x00000002
75#define NFS4_ACE_ADD_FILE 0x00000002
76#define NFS4_ACE_APPEND_DATA 0x00000004
77#define NFS4_ACE_ADD_SUBDIRECTORY 0x00000004
78#define NFS4_ACE_READ_NAMED_ATTRS 0x00000008
79#define NFS4_ACE_WRITE_NAMED_ATTRS 0x00000010
80#define NFS4_ACE_EXECUTE 0x00000020
81#define NFS4_ACE_DELETE_CHILD 0x00000040
82#define NFS4_ACE_READ_ATTRIBUTES 0x00000080
83#define NFS4_ACE_WRITE_ATTRIBUTES 0x00000100
84#define NFS4_ACE_DELETE 0x00010000
85#define NFS4_ACE_READ_ACL 0x00020000
86#define NFS4_ACE_WRITE_ACL 0x00040000
87#define NFS4_ACE_WRITE_OWNER 0x00080000
88#define NFS4_ACE_SYNCHRONIZE 0x00100000
89#define NFS4_ACE_GENERIC_READ 0x00120081
90#define NFS4_ACE_GENERIC_WRITE 0x00160106
91#define NFS4_ACE_GENERIC_EXECUTE 0x001200A0
92#define NFS4_ACE_MASK_ALL 0x001F01FF
93
94enum nfs4_acl_whotype {
95 NFS4_ACL_WHO_NAMED = 0,
96 NFS4_ACL_WHO_OWNER,
97 NFS4_ACL_WHO_GROUP,
98 NFS4_ACL_WHO_EVERYONE,
99};
100
David Woodhouse997b7af2006-04-25 14:51:45 +0100101#ifdef __KERNEL__
102#include <linux/list.h>
103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104struct nfs4_ace {
105 uint32_t type;
106 uint32_t flag;
107 uint32_t access_mask;
108 int whotype;
109 uid_t who;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110};
111
112struct nfs4_acl {
113 uint32_t naces;
J. Bruce Fields28e05dd2007-02-16 01:28:30 -0800114 struct nfs4_ace aces[0];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115};
116
117typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier;
Trond Myklebust8ae20ab2007-05-14 16:50:45 -0400118typedef struct { char data[NFS4_STATEID_SIZE]; } nfs4_stateid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
120enum nfs_opnum4 {
121 OP_ACCESS = 3,
122 OP_CLOSE = 4,
123 OP_COMMIT = 5,
124 OP_CREATE = 6,
125 OP_DELEGPURGE = 7,
126 OP_DELEGRETURN = 8,
127 OP_GETATTR = 9,
128 OP_GETFH = 10,
129 OP_LINK = 11,
130 OP_LOCK = 12,
131 OP_LOCKT = 13,
132 OP_LOCKU = 14,
133 OP_LOOKUP = 15,
134 OP_LOOKUPP = 16,
135 OP_NVERIFY = 17,
136 OP_OPEN = 18,
137 OP_OPENATTR = 19,
138 OP_OPEN_CONFIRM = 20,
139 OP_OPEN_DOWNGRADE = 21,
140 OP_PUTFH = 22,
141 OP_PUTPUBFH = 23,
142 OP_PUTROOTFH = 24,
143 OP_READ = 25,
144 OP_READDIR = 26,
145 OP_READLINK = 27,
146 OP_REMOVE = 28,
147 OP_RENAME = 29,
148 OP_RENEW = 30,
149 OP_RESTOREFH = 31,
150 OP_SAVEFH = 32,
151 OP_SECINFO = 33,
152 OP_SETATTR = 34,
153 OP_SETCLIENTID = 35,
154 OP_SETCLIENTID_CONFIRM = 36,
155 OP_VERIFY = 37,
156 OP_WRITE = 38,
157 OP_RELEASE_LOCKOWNER = 39,
158 OP_ILLEGAL = 10044,
159};
160
Shankar Anande2b20952006-07-10 04:45:44 -0700161/*Defining first and last NFS4 operations implemented.
162Needs to be updated if more operations are defined in future.*/
163
164#define FIRST_NFS4_OP OP_ACCESS
165#define LAST_NFS4_OP OP_RELEASE_LOCKOWNER
166
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167enum nfsstat4 {
168 NFS4_OK = 0,
169 NFS4ERR_PERM = 1,
170 NFS4ERR_NOENT = 2,
171 NFS4ERR_IO = 5,
172 NFS4ERR_NXIO = 6,
173 NFS4ERR_ACCESS = 13,
174 NFS4ERR_EXIST = 17,
175 NFS4ERR_XDEV = 18,
176 /* Unused/reserved 19 */
177 NFS4ERR_NOTDIR = 20,
178 NFS4ERR_ISDIR = 21,
179 NFS4ERR_INVAL = 22,
180 NFS4ERR_FBIG = 27,
181 NFS4ERR_NOSPC = 28,
182 NFS4ERR_ROFS = 30,
183 NFS4ERR_MLINK = 31,
184 NFS4ERR_NAMETOOLONG = 63,
185 NFS4ERR_NOTEMPTY = 66,
186 NFS4ERR_DQUOT = 69,
187 NFS4ERR_STALE = 70,
188 NFS4ERR_BADHANDLE = 10001,
189 NFS4ERR_BAD_COOKIE = 10003,
190 NFS4ERR_NOTSUPP = 10004,
191 NFS4ERR_TOOSMALL = 10005,
192 NFS4ERR_SERVERFAULT = 10006,
193 NFS4ERR_BADTYPE = 10007,
194 NFS4ERR_DELAY = 10008,
195 NFS4ERR_SAME = 10009,
196 NFS4ERR_DENIED = 10010,
197 NFS4ERR_EXPIRED = 10011,
198 NFS4ERR_LOCKED = 10012,
199 NFS4ERR_GRACE = 10013,
200 NFS4ERR_FHEXPIRED = 10014,
201 NFS4ERR_SHARE_DENIED = 10015,
202 NFS4ERR_WRONGSEC = 10016,
203 NFS4ERR_CLID_INUSE = 10017,
204 NFS4ERR_RESOURCE = 10018,
205 NFS4ERR_MOVED = 10019,
206 NFS4ERR_NOFILEHANDLE = 10020,
207 NFS4ERR_MINOR_VERS_MISMATCH = 10021,
208 NFS4ERR_STALE_CLIENTID = 10022,
209 NFS4ERR_STALE_STATEID = 10023,
210 NFS4ERR_OLD_STATEID = 10024,
211 NFS4ERR_BAD_STATEID = 10025,
212 NFS4ERR_BAD_SEQID = 10026,
213 NFS4ERR_NOT_SAME = 10027,
214 NFS4ERR_LOCK_RANGE = 10028,
215 NFS4ERR_SYMLINK = 10029,
216 NFS4ERR_RESTOREFH = 10030,
217 NFS4ERR_LEASE_MOVED = 10031,
218 NFS4ERR_ATTRNOTSUPP = 10032,
219 NFS4ERR_NO_GRACE = 10033,
220 NFS4ERR_RECLAIM_BAD = 10034,
221 NFS4ERR_RECLAIM_CONFLICT = 10035,
222 NFS4ERR_BADXDR = 10036,
223 NFS4ERR_LOCKS_HELD = 10037,
224 NFS4ERR_OPENMODE = 10038,
225 NFS4ERR_BADOWNER = 10039,
226 NFS4ERR_BADCHAR = 10040,
227 NFS4ERR_BADNAME = 10041,
228 NFS4ERR_BAD_RANGE = 10042,
229 NFS4ERR_LOCK_NOTSUPP = 10043,
230 NFS4ERR_OP_ILLEGAL = 10044,
231 NFS4ERR_DEADLOCK = 10045,
232 NFS4ERR_FILE_OPEN = 10046,
233 NFS4ERR_ADMIN_REVOKED = 10047,
234 NFS4ERR_CB_PATH_DOWN = 10048
235};
236
237/*
238 * Note: NF4BAD is not actually part of the protocol; it is just used
239 * internally by nfsd.
240 */
241enum nfs_ftype4 {
242 NF4BAD = 0,
243 NF4REG = 1, /* Regular File */
244 NF4DIR = 2, /* Directory */
245 NF4BLK = 3, /* Special File - block device */
246 NF4CHR = 4, /* Special File - character device */
247 NF4LNK = 5, /* Symbolic Link */
248 NF4SOCK = 6, /* Special File - socket */
249 NF4FIFO = 7, /* Special File - fifo */
250 NF4ATTRDIR = 8, /* Attribute Directory */
251 NF4NAMEDATTR = 9 /* Named Attribute */
252};
253
254enum open_claim_type4 {
255 NFS4_OPEN_CLAIM_NULL = 0,
256 NFS4_OPEN_CLAIM_PREVIOUS = 1,
257 NFS4_OPEN_CLAIM_DELEGATE_CUR = 2,
258 NFS4_OPEN_CLAIM_DELEGATE_PREV = 3
259};
260
261enum opentype4 {
262 NFS4_OPEN_NOCREATE = 0,
263 NFS4_OPEN_CREATE = 1
264};
265
266enum createmode4 {
267 NFS4_CREATE_UNCHECKED = 0,
268 NFS4_CREATE_GUARDED = 1,
269 NFS4_CREATE_EXCLUSIVE = 2
270};
271
272enum limit_by4 {
273 NFS4_LIMIT_SIZE = 1,
274 NFS4_LIMIT_BLOCKS = 2
275};
276
277enum open_delegation_type4 {
278 NFS4_OPEN_DELEGATE_NONE = 0,
279 NFS4_OPEN_DELEGATE_READ = 1,
280 NFS4_OPEN_DELEGATE_WRITE = 2
281};
282
283enum lock_type4 {
284 NFS4_UNLOCK_LT = 0,
285 NFS4_READ_LT = 1,
286 NFS4_WRITE_LT = 2,
287 NFS4_READW_LT = 3,
288 NFS4_WRITEW_LT = 4
289};
290
291
292/* Mandatory Attributes */
293#define FATTR4_WORD0_SUPPORTED_ATTRS (1UL << 0)
294#define FATTR4_WORD0_TYPE (1UL << 1)
295#define FATTR4_WORD0_FH_EXPIRE_TYPE (1UL << 2)
296#define FATTR4_WORD0_CHANGE (1UL << 3)
297#define FATTR4_WORD0_SIZE (1UL << 4)
298#define FATTR4_WORD0_LINK_SUPPORT (1UL << 5)
299#define FATTR4_WORD0_SYMLINK_SUPPORT (1UL << 6)
300#define FATTR4_WORD0_NAMED_ATTR (1UL << 7)
301#define FATTR4_WORD0_FSID (1UL << 8)
302#define FATTR4_WORD0_UNIQUE_HANDLES (1UL << 9)
303#define FATTR4_WORD0_LEASE_TIME (1UL << 10)
304#define FATTR4_WORD0_RDATTR_ERROR (1UL << 11)
305
306/* Recommended Attributes */
307#define FATTR4_WORD0_ACL (1UL << 12)
308#define FATTR4_WORD0_ACLSUPPORT (1UL << 13)
309#define FATTR4_WORD0_ARCHIVE (1UL << 14)
310#define FATTR4_WORD0_CANSETTIME (1UL << 15)
311#define FATTR4_WORD0_CASE_INSENSITIVE (1UL << 16)
312#define FATTR4_WORD0_CASE_PRESERVING (1UL << 17)
313#define FATTR4_WORD0_CHOWN_RESTRICTED (1UL << 18)
314#define FATTR4_WORD0_FILEHANDLE (1UL << 19)
315#define FATTR4_WORD0_FILEID (1UL << 20)
316#define FATTR4_WORD0_FILES_AVAIL (1UL << 21)
317#define FATTR4_WORD0_FILES_FREE (1UL << 22)
318#define FATTR4_WORD0_FILES_TOTAL (1UL << 23)
319#define FATTR4_WORD0_FS_LOCATIONS (1UL << 24)
320#define FATTR4_WORD0_HIDDEN (1UL << 25)
321#define FATTR4_WORD0_HOMOGENEOUS (1UL << 26)
322#define FATTR4_WORD0_MAXFILESIZE (1UL << 27)
323#define FATTR4_WORD0_MAXLINK (1UL << 28)
324#define FATTR4_WORD0_MAXNAME (1UL << 29)
325#define FATTR4_WORD0_MAXREAD (1UL << 30)
326#define FATTR4_WORD0_MAXWRITE (1UL << 31)
327#define FATTR4_WORD1_MIMETYPE (1UL << 0)
328#define FATTR4_WORD1_MODE (1UL << 1)
329#define FATTR4_WORD1_NO_TRUNC (1UL << 2)
330#define FATTR4_WORD1_NUMLINKS (1UL << 3)
331#define FATTR4_WORD1_OWNER (1UL << 4)
332#define FATTR4_WORD1_OWNER_GROUP (1UL << 5)
333#define FATTR4_WORD1_QUOTA_HARD (1UL << 6)
334#define FATTR4_WORD1_QUOTA_SOFT (1UL << 7)
335#define FATTR4_WORD1_QUOTA_USED (1UL << 8)
336#define FATTR4_WORD1_RAWDEV (1UL << 9)
337#define FATTR4_WORD1_SPACE_AVAIL (1UL << 10)
338#define FATTR4_WORD1_SPACE_FREE (1UL << 11)
339#define FATTR4_WORD1_SPACE_TOTAL (1UL << 12)
340#define FATTR4_WORD1_SPACE_USED (1UL << 13)
341#define FATTR4_WORD1_SYSTEM (1UL << 14)
342#define FATTR4_WORD1_TIME_ACCESS (1UL << 15)
343#define FATTR4_WORD1_TIME_ACCESS_SET (1UL << 16)
344#define FATTR4_WORD1_TIME_BACKUP (1UL << 17)
345#define FATTR4_WORD1_TIME_CREATE (1UL << 18)
346#define FATTR4_WORD1_TIME_DELTA (1UL << 19)
347#define FATTR4_WORD1_TIME_METADATA (1UL << 20)
348#define FATTR4_WORD1_TIME_MODIFY (1UL << 21)
349#define FATTR4_WORD1_TIME_MODIFY_SET (1UL << 22)
350#define FATTR4_WORD1_MOUNTED_ON_FILEID (1UL << 23)
351
352#define NFSPROC4_NULL 0
353#define NFSPROC4_COMPOUND 1
354#define NFS4_MINOR_VERSION 0
355#define NFS4_DEBUG 1
356
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357/* Index of predefined Linux client operations */
358
359enum {
360 NFSPROC4_CLNT_NULL = 0, /* Unused */
361 NFSPROC4_CLNT_READ,
362 NFSPROC4_CLNT_WRITE,
363 NFSPROC4_CLNT_COMMIT,
364 NFSPROC4_CLNT_OPEN,
365 NFSPROC4_CLNT_OPEN_CONFIRM,
366 NFSPROC4_CLNT_OPEN_NOATTR,
367 NFSPROC4_CLNT_OPEN_DOWNGRADE,
368 NFSPROC4_CLNT_CLOSE,
369 NFSPROC4_CLNT_SETATTR,
370 NFSPROC4_CLNT_FSINFO,
371 NFSPROC4_CLNT_RENEW,
372 NFSPROC4_CLNT_SETCLIENTID,
373 NFSPROC4_CLNT_SETCLIENTID_CONFIRM,
374 NFSPROC4_CLNT_LOCK,
375 NFSPROC4_CLNT_LOCKT,
376 NFSPROC4_CLNT_LOCKU,
377 NFSPROC4_CLNT_ACCESS,
378 NFSPROC4_CLNT_GETATTR,
379 NFSPROC4_CLNT_LOOKUP,
380 NFSPROC4_CLNT_LOOKUP_ROOT,
381 NFSPROC4_CLNT_REMOVE,
382 NFSPROC4_CLNT_RENAME,
383 NFSPROC4_CLNT_LINK,
384 NFSPROC4_CLNT_SYMLINK,
385 NFSPROC4_CLNT_CREATE,
386 NFSPROC4_CLNT_PATHCONF,
387 NFSPROC4_CLNT_STATFS,
388 NFSPROC4_CLNT_READLINK,
389 NFSPROC4_CLNT_READDIR,
390 NFSPROC4_CLNT_SERVER_CAPS,
391 NFSPROC4_CLNT_DELEGRETURN,
J. Bruce Fields029d1052005-06-22 17:16:22 +0000392 NFSPROC4_CLNT_GETACL,
J. Bruce Fields23ec6962005-06-22 17:16:22 +0000393 NFSPROC4_CLNT_SETACL,
Trond Myklebust683b57b2006-06-09 09:34:22 -0400394 NFSPROC4_CLNT_FS_LOCATIONS,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395};
396
397#endif
398#endif
399
400/*
401 * Local variables:
402 * c-basic-offset: 8
403 * End:
404 */