nfs4.h
上传用户:szlgq88
上传日期:2009-04-28
资源大小:48287k
文件大小:11k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

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