xref: /haiku/src/add-ons/kernel/file_systems/nfs4/NFS4Defs.h (revision 1ec6b0c1f74d5cc239bf210740ad35b9479b8ef6)
14aeb5952SPawel Dziepak /*
24aeb5952SPawel Dziepak  * Copyright 2012 Haiku, Inc. All rights reserved.
34aeb5952SPawel Dziepak  * Distributed under the terms of the MIT License.
44aeb5952SPawel Dziepak  *
54aeb5952SPawel Dziepak  * Authors:
64aeb5952SPawel Dziepak  *		Paweł Dziepak, pdziepak@quarnos.org
74aeb5952SPawel Dziepak  */
84aeb5952SPawel Dziepak #ifndef NFS4DEFS_H
94aeb5952SPawel Dziepak #define NFS4DEFS_H
104aeb5952SPawel Dziepak 
114aeb5952SPawel Dziepak 
12d38e98d8SPawel Dziepak #include <sys/stat.h>
13d38e98d8SPawel Dziepak 
1445aa18acSPawel Dziepak #include <SupportDefs.h>
1545aa18acSPawel Dziepak 
167bfa4fe8SPawel Dziepak #include "Filehandle.h"
17196403c9SPawel Dziepak 
184aeb5952SPawel Dziepak enum Procedure {
194aeb5952SPawel Dziepak 	ProcNull		= 0,
204aeb5952SPawel Dziepak 	ProcCompound	= 1
214aeb5952SPawel Dziepak };
224aeb5952SPawel Dziepak 
234aeb5952SPawel Dziepak enum Opcode {
244aeb5952SPawel Dziepak 	OpAccess				= 3,
2560a8140dSPawel Dziepak 	OpClose					= 4,
264aeb5952SPawel Dziepak 	OpGetAttr				= 9,
274aeb5952SPawel Dziepak 	OpGetFH					= 10,
284aeb5952SPawel Dziepak 	OpLookUp				= 15,
297bfa4fe8SPawel Dziepak 	OpLookUpUp				= 16,
302a292557SPawel Dziepak 	OpOpen					= 18,
312a292557SPawel Dziepak 	OpOpenConfirm			= 20,
32bf31ee39SPawel Dziepak 	OpPutFH					= 22,
334b48348fSPawel Dziepak 	OpPutRootFH				= 24,
342f2e57d0SPawel Dziepak 	OpRead					= 25,
352a292557SPawel Dziepak 	OpReadDir				= 26,
36f2da914dSPawel Dziepak 	OpReadLink				= 27,
37*1ec6b0c1SPawel Dziepak 	OpRename				= 29,
3827a291deSPawel Dziepak 	OpRenew					= 30,
39*1ec6b0c1SPawel Dziepak 	OpSaveFH				= 32,
402a292557SPawel Dziepak 	OpSetClientID			= 35,
412a292557SPawel Dziepak 	OpSetClientIDConfirm	= 36
424aeb5952SPawel Dziepak };
434aeb5952SPawel Dziepak 
444aeb5952SPawel Dziepak enum Access {
454aeb5952SPawel Dziepak 	ACCESS4_READ		= 0x00000001,
464aeb5952SPawel Dziepak 	ACCESS4_LOOKUP		= 0x00000002,
474aeb5952SPawel Dziepak 	ACCESS4_MODIFY		= 0x00000004,
484aeb5952SPawel Dziepak 	ACCESS4_EXTEND		= 0x00000008,
494aeb5952SPawel Dziepak 	ACCESS4_DELETE		= 0x00000010,
504aeb5952SPawel Dziepak 	ACCESS4_EXECUTE		= 0x00000020
514aeb5952SPawel Dziepak };
524aeb5952SPawel Dziepak 
534aeb5952SPawel Dziepak enum Attribute {
544aeb5952SPawel Dziepak 	// Mandatory Attributes
554aeb5952SPawel Dziepak 	FATTR4_SUPPORTED_ATTRS		= 0,
564aeb5952SPawel Dziepak 	FATTR4_TYPE					= 1,
574aeb5952SPawel Dziepak 	FATTR4_FH_EXPIRE_TYPE		= 2,
584aeb5952SPawel Dziepak 	FATTR4_CHANGE				= 3,
594aeb5952SPawel Dziepak 	FATTR4_SIZE					= 4,
604aeb5952SPawel Dziepak 	FATTR4_LINK_SUPPORT			= 5,
614aeb5952SPawel Dziepak 	FATTR4_SYMLINK_SUPPORT		= 6,
624aeb5952SPawel Dziepak 	FATTR4_NAMED_ATTR			= 7,
634aeb5952SPawel Dziepak 	FATTR4_FSID					= 8,
644aeb5952SPawel Dziepak 	FATTR4_UNIQUE_HANDLES		= 9,
654aeb5952SPawel Dziepak 	FATTR4_LEASE_TIME			= 10,
664aeb5952SPawel Dziepak 	FATTR4_RDATTR_ERROR			= 11,
674aeb5952SPawel Dziepak 	FATTR4_FILEHANDLE			= 19,
684aeb5952SPawel Dziepak 
694aeb5952SPawel Dziepak 	// Recommended Attributes
704aeb5952SPawel Dziepak 	FATTR4_ACL					= 12,
714aeb5952SPawel Dziepak 	FATTR4_ACLSUPPORT			= 13,
724aeb5952SPawel Dziepak 	FATTR4_ARCHIVE				= 14,
734aeb5952SPawel Dziepak 	FATTR4_CANSETTIME			= 15,
744aeb5952SPawel Dziepak 	FATTR4_CASE_INSENSITIVE		= 16,
754aeb5952SPawel Dziepak 	FATTR4_CASE_PRESERVING		= 17,
764aeb5952SPawel Dziepak 	FATTR4_CHOWN_RESTRICTED		= 18,
774aeb5952SPawel Dziepak 	FATTR4_FILEID				= 20,
784aeb5952SPawel Dziepak 	FATTR4_FILES_AVAIL			= 21,
794aeb5952SPawel Dziepak 	FATTR4_FILES_FREE			= 22,
804aeb5952SPawel Dziepak 	FATTR4_FILES_TOTAL			= 23,
814aeb5952SPawel Dziepak 	FATTR4_FS_LOCATIONS			= 24,
824aeb5952SPawel Dziepak 	FATTR4_HIDDEN				= 25,
834aeb5952SPawel Dziepak 	FATTR4_HOMOGENEOUS			= 26,
844aeb5952SPawel Dziepak 	FATTR4_MAXFILESIZE			= 27,
854aeb5952SPawel Dziepak 	FATTR4_MAXLINK				= 28,
864aeb5952SPawel Dziepak 	FATTR4_MAXNAME				= 29,
874aeb5952SPawel Dziepak 	FATTR4_MAXREAD				= 30,
884aeb5952SPawel Dziepak 	FATTR4_MAXWRITE				= 31,
894aeb5952SPawel Dziepak 	FATTR4_MIMETYPE				= 32,
904aeb5952SPawel Dziepak 	FATTR4_MODE					= 33,
914aeb5952SPawel Dziepak 	FATTR4_NO_TRUNC				= 34,
924aeb5952SPawel Dziepak 	FATTR4_NUMLINKS				= 35,
934aeb5952SPawel Dziepak 	FATTR4_OWNER				= 36,
944aeb5952SPawel Dziepak 	FATTR4_OWNER_GROUP			= 37,
954aeb5952SPawel Dziepak 	FATTR4_QUOTA_AVAIL_HARD		= 38,
964aeb5952SPawel Dziepak 	FATTR4_QUOTA_AVAIL_SOFT		= 39,
974aeb5952SPawel Dziepak 	FATTR4_QUOTA_USED			= 40,
984aeb5952SPawel Dziepak 	FATTR4_RAWDEV				= 41,
994aeb5952SPawel Dziepak 	FATTR4_SPACE_AVAIL			= 42,
1004aeb5952SPawel Dziepak 	FATTR4_SPACE_FREE			= 43,
1014aeb5952SPawel Dziepak 	FATTR4_SPACE_TOTAL			= 44,
1024aeb5952SPawel Dziepak 	FATTR4_SPACE_USED			= 45,
1034aeb5952SPawel Dziepak 	FATTR4_SYSTEM				= 46,
1044aeb5952SPawel Dziepak 	FATTR4_TIME_ACCESS			= 47,
1054aeb5952SPawel Dziepak 	FATTR4_TIME_ACCESS_SET		= 48,
1064aeb5952SPawel Dziepak 	FATTR4_TIME_BACKUP			= 49,
1074aeb5952SPawel Dziepak 	FATTR4_TIME_CREATE			= 50,
1084aeb5952SPawel Dziepak 	FATTR4_TIME_DELTA			= 51,
1094aeb5952SPawel Dziepak 	FATTR4_TIME_METADATA		= 52,
1104aeb5952SPawel Dziepak 	FATTR4_TIME_MODIFY			= 53,
1114aeb5952SPawel Dziepak 	FATTR4_TIME_MODIFY_SET		= 54,
112f29ac4afSPawel Dziepak 	FATTR4_MOUNTED_ON_FILEID	= 55,
113f29ac4afSPawel Dziepak 	FATTR4_MAXIMUM_ATTR_ID
1144aeb5952SPawel Dziepak };
1154aeb5952SPawel Dziepak 
116d38e98d8SPawel Dziepak enum FileType {
117d38e98d8SPawel Dziepak 	NF4REG			= 1,    /* Regular File */
118d38e98d8SPawel Dziepak 	NF4DIR			= 2,    /* Directory */
119d38e98d8SPawel Dziepak 	NF4BLK			= 3,    /* Special File - block device */
120d38e98d8SPawel Dziepak 	NF4CHR			= 4,    /* Special File - character device */
121d38e98d8SPawel Dziepak 	NF4LNK			= 5,    /* Symbolic Link */
122d38e98d8SPawel Dziepak 	NF4SOCK			= 6,    /* Special File - socket */
123d38e98d8SPawel Dziepak 	NF4FIFO			= 7,    /* Special File - fifo */
124d38e98d8SPawel Dziepak 	NF4ATTRDIR		= 8,    /* Attribute Directory */
125d38e98d8SPawel Dziepak 	NF4NAMEDATTR	= 9     /* Named Attribute */
126d38e98d8SPawel Dziepak };
127d38e98d8SPawel Dziepak 
128d38e98d8SPawel Dziepak static const mode_t sNFSFileTypeToHaiku[] = {
129212de720SPawel Dziepak 	S_IFREG, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK, S_IFSOCK, S_IFIFO,
130212de720SPawel Dziepak 	S_IFDIR, S_IFREG
131d38e98d8SPawel Dziepak };
132d38e98d8SPawel Dziepak 
1334aeb5952SPawel Dziepak enum FileHandleExpiryType {
1344aeb5952SPawel Dziepak 	FH4_PERSISTENT			= 0x00,
1354aeb5952SPawel Dziepak 	FH4_NOEXPIRE_WITH_OPEN	= 0x01,
1364aeb5952SPawel Dziepak 	FH4_VOLATILE_ANY		= 0x02,
1374aeb5952SPawel Dziepak 	FH4_VOL_MIGRATION		= 0x04,
1384aeb5952SPawel Dziepak 	FH4_VOL_RENAME			= 0x08
1394aeb5952SPawel Dziepak };
1404aeb5952SPawel Dziepak 
1412a292557SPawel Dziepak enum OpenAccess {
1422a292557SPawel Dziepak 	OPEN4_SHARE_ACCESS_READ		= 1,
1432a292557SPawel Dziepak 	OPEN4_SHARE_ACCESS_WRITE	= 2
1442a292557SPawel Dziepak };
1452a292557SPawel Dziepak 
1462a292557SPawel Dziepak enum OpenCreate {
1472a292557SPawel Dziepak 	OPEN4_NOCREATE			= 0,
1482a292557SPawel Dziepak 	OPEN4_CREATE			= 1
1492a292557SPawel Dziepak };
1502a292557SPawel Dziepak 
151d1e6b61eSPawel Dziepak enum OpenClaim {
152d1e6b61eSPawel Dziepak 	CLAIM_NULL				= 0,
153d1e6b61eSPawel Dziepak 	CLAIM_PREVIOUS			= 1,
154d1e6b61eSPawel Dziepak 	CLAIM_DELEGATE_CUR		= 2,
155d1e6b61eSPawel Dziepak 	CLAIM_DELEGATE_PREV		= 3
156d1e6b61eSPawel Dziepak };
157d1e6b61eSPawel Dziepak 
1582a292557SPawel Dziepak enum OpenFlags {
1592a292557SPawel Dziepak 	OPEN4_RESULT_CONFIRM		= 2,
1602a292557SPawel Dziepak 	OPEN4_RESULT_LOCKTYPE_POSIX	= 4
1612a292557SPawel Dziepak };
1622a292557SPawel Dziepak 
1634aeb5952SPawel Dziepak enum Errors {
1644aeb5952SPawel Dziepak 	NFS4_OK						= 0,
1654aeb5952SPawel Dziepak 	NFS4ERR_PERM				= 1,
1664aeb5952SPawel Dziepak 	NFS4ERR_NOENT				= 2,
1674aeb5952SPawel Dziepak 	NFS4ERR_IO					= 5,
1684aeb5952SPawel Dziepak 	NFS4ERR_NXIO				= 6,
1694aeb5952SPawel Dziepak 	NFS4ERR_ACCESS				= 13,
1704aeb5952SPawel Dziepak 	NFS4ERR_EXIST				= 17,
1714aeb5952SPawel Dziepak 	NFS4ERR_XDEV				= 18,
1724aeb5952SPawel Dziepak 	NFS4ERR_NOTDIR				= 20,
1734aeb5952SPawel Dziepak 	NFS4ERR_ISDIR				= 21,
1744aeb5952SPawel Dziepak 	NFS4ERR_INVAL				= 22,
175b268b6f2SPawel Dziepak 	NFS4ERR_FBIG				= 27,
176b268b6f2SPawel Dziepak 	NFS4ERR_BADHANDLE			= 10001,
177b268b6f2SPawel Dziepak 	NFS4ERR_BAD_COOKIE			= 10003,
178b268b6f2SPawel Dziepak 	NFS4ERR_NOTSUPP				= 10004,
179b268b6f2SPawel Dziepak 	NFS4ERR_TOOSMALL			= 10005,
180b268b6f2SPawel Dziepak 	NFS4ERR_SERVERFAULT			= 10006,
181b268b6f2SPawel Dziepak 	NFS4ERR_BADTYPE				= 10007,
182b268b6f2SPawel Dziepak 	NFS4ERR_DELAY				= 10008,
183b268b6f2SPawel Dziepak 	NFS4ERR_SAME				= 10009,
184b268b6f2SPawel Dziepak 	NFS4ERR_DENIED				= 10010,
185b268b6f2SPawel Dziepak 	NFS4ERR_EXPIRED				= 10011,
186b268b6f2SPawel Dziepak 	NFS4ERR_LOCKED				= 10012,
187b268b6f2SPawel Dziepak 	NFS4ERR_GRACE				= 10013,
188b268b6f2SPawel Dziepak 	NFS4ERR_FHEXPIRED			= 10014,
189b268b6f2SPawel Dziepak 	NFS4ERR_SHARE_DENIED		= 10015,
190b268b6f2SPawel Dziepak 	NFS4ERR_WRONGSEC			= 10016,
191b268b6f2SPawel Dziepak 	NFS4ERR_CLID_INUSE			= 10017,
192b268b6f2SPawel Dziepak 	NFS4ERR_RESOURCE			= 10018,
193b268b6f2SPawel Dziepak 	NFS4ERR_MOVED				= 10019,
194b268b6f2SPawel Dziepak 	NFS4ERR_NOFILEHANDLE		= 10020,
195b268b6f2SPawel Dziepak 	NFS4ERR_MINOR_VERS_MISMATCH	= 10021,
196b268b6f2SPawel Dziepak 	NFS4ERR_STALE_CLIENTID		= 10022,
197b268b6f2SPawel Dziepak 	NFS4ERR_STALE_STATEID		= 10023,
198b268b6f2SPawel Dziepak 	NFS4ERR_OLD_STATEID			= 10024,
199b268b6f2SPawel Dziepak 	NFS4ERR_BAD_STATEID			= 10025,
200b268b6f2SPawel Dziepak 	NFS4ERR_BAD_SEQID			= 10026,
201b268b6f2SPawel Dziepak 	NFS4ERR_NOT_SAME			= 10027,
202b268b6f2SPawel Dziepak 	NFS4ERR_LOCK_RANGE			= 10028,
203b268b6f2SPawel Dziepak 	NFS4ERR_SYMLINK				= 10029,
204b268b6f2SPawel Dziepak 	NFS4ERR_RESTOREFH			= 10030,
205b268b6f2SPawel Dziepak 	NFS4ERR_LEASE_MOVED			= 10031,
206b268b6f2SPawel Dziepak 	NFS4ERR_ATTRNOTSUPP			= 10032,
207b268b6f2SPawel Dziepak 	NFS4ERR_NO_GRACE			= 10033,
208b268b6f2SPawel Dziepak 	NFS4ERR_RECLAIM_BAD			= 10034,
209b268b6f2SPawel Dziepak 	NFS4ERR_RECLAIM_CONFLICT	= 10035,
210b268b6f2SPawel Dziepak 	NFS4ERR_BADXDR				= 10036,
211b268b6f2SPawel Dziepak 	NFS4ERR_LOCKS_HELD			= 10037,
212b268b6f2SPawel Dziepak 	NFS4ERR_OPENMODE			= 10038,
213b268b6f2SPawel Dziepak 	NFS4ERR_BADOWNER			= 10039,
214b268b6f2SPawel Dziepak 	NFS4ERR_BADCHAR				= 10040,
215b268b6f2SPawel Dziepak 	NFS4ERR_BADNAME				= 10041,
216b268b6f2SPawel Dziepak 	NFS4ERR_BAD_RANGE			= 10042,
217b268b6f2SPawel Dziepak 	NFS4ERR_LOCK_NOTSUPP		= 10043,
218b268b6f2SPawel Dziepak 	NFS4ERR_OP_ILLEGAL			= 10044,
219b268b6f2SPawel Dziepak 	NFS4ERR_DEADLOCK			= 10045,
220b268b6f2SPawel Dziepak 	NFS4ERR_FILE_OPEN			= 10046,
221b268b6f2SPawel Dziepak 	NFS4ERR_ADMIN_REVOKED		= 10047,
222b268b6f2SPawel Dziepak 	NFS4ERR_CB_PATH_DOWN		= 10048
2234aeb5952SPawel Dziepak };
2244aeb5952SPawel Dziepak 
2254aeb5952SPawel Dziepak 
2264aeb5952SPawel Dziepak #endif	// NFS4DEFS_H
2274aeb5952SPawel Dziepak 
228