2 * Copyright 2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Paweł Dziepak, pdziepak@quarnos.org
15 #include <SupportDefs.h>
23 enum CallbackProcedure
{
25 CallbackProcCompound
= 1
29 OpCallbackGetAttr
= 3,
62 OpSetClientIDConfirm
= 36,
65 OpReleaseLockOwner
= 39
69 ACCESS4_READ
= 0x00000001,
70 ACCESS4_LOOKUP
= 0x00000002,
71 ACCESS4_MODIFY
= 0x00000004,
72 ACCESS4_EXTEND
= 0x00000008,
73 ACCESS4_DELETE
= 0x00000010,
74 ACCESS4_EXECUTE
= 0x00000020
78 // Mandatory Attributes
79 FATTR4_SUPPORTED_ATTRS
= 0,
81 FATTR4_FH_EXPIRE_TYPE
= 2,
84 FATTR4_LINK_SUPPORT
= 5,
85 FATTR4_SYMLINK_SUPPORT
= 6,
86 FATTR4_NAMED_ATTR
= 7,
88 FATTR4_UNIQUE_HANDLES
= 9,
89 FATTR4_LEASE_TIME
= 10,
90 FATTR4_RDATTR_ERROR
= 11,
91 FATTR4_FILEHANDLE
= 19,
93 // Recommended Attributes
95 FATTR4_ACLSUPPORT
= 13,
97 FATTR4_CANSETTIME
= 15,
98 FATTR4_CASE_INSENSITIVE
= 16,
99 FATTR4_CASE_PRESERVING
= 17,
100 FATTR4_CHOWN_RESTRICTED
= 18,
102 FATTR4_FILES_AVAIL
= 21,
103 FATTR4_FILES_FREE
= 22,
104 FATTR4_FILES_TOTAL
= 23,
105 FATTR4_FS_LOCATIONS
= 24,
107 FATTR4_HOMOGENEOUS
= 26,
108 FATTR4_MAXFILESIZE
= 27,
112 FATTR4_MAXWRITE
= 31,
113 FATTR4_MIMETYPE
= 32,
115 FATTR4_NO_TRUNC
= 34,
116 FATTR4_NUMLINKS
= 35,
118 FATTR4_OWNER_GROUP
= 37,
119 FATTR4_QUOTA_AVAIL_HARD
= 38,
120 FATTR4_QUOTA_AVAIL_SOFT
= 39,
121 FATTR4_QUOTA_USED
= 40,
123 FATTR4_SPACE_AVAIL
= 42,
124 FATTR4_SPACE_FREE
= 43,
125 FATTR4_SPACE_TOTAL
= 44,
126 FATTR4_SPACE_USED
= 45,
128 FATTR4_TIME_ACCESS
= 47,
129 FATTR4_TIME_ACCESS_SET
= 48,
130 FATTR4_TIME_BACKUP
= 49,
131 FATTR4_TIME_CREATE
= 50,
132 FATTR4_TIME_DELTA
= 51,
133 FATTR4_TIME_METADATA
= 52,
134 FATTR4_TIME_MODIFY
= 53,
135 FATTR4_TIME_MODIFY_SET
= 54,
136 FATTR4_MOUNTED_ON_FILEID
= 55,
137 FATTR4_MAXIMUM_ATTR_ID
141 CallbackAttrSize
= 1,
142 CallbackAttrChange
= 2
145 static inline bool sIsAttrSet(Attribute attr
, const uint32
* bitmap
,
148 if ((uint32
)attr
/ 32 >= count
)
151 return (bitmap
[attr
/ 32] & 1 << attr
% 32) != 0;
156 NF4REG
= 1, /* Regular File */
157 NF4DIR
= 2, /* Directory */
158 NF4BLK
= 3, /* Special File - block device */
159 NF4CHR
= 4, /* Special File - character device */
160 NF4LNK
= 5, /* Symbolic Link */
161 NF4SOCK
= 6, /* Special File - socket */
162 NF4FIFO
= 7, /* Special File - fifo */
163 NF4ATTRDIR
= 8, /* Attribute Directory */
164 NF4NAMEDATTR
= 9 /* Named Attribute */
167 static const mode_t sNFSFileTypeToHaiku
[] = {
168 S_IFREG
, S_IFREG
, S_IFDIR
, S_IFBLK
, S_IFCHR
, S_IFLNK
, S_IFSOCK
, S_IFIFO
,
172 enum FileHandleExpiryType
{
173 FH4_PERSISTENT
= 0x00,
174 FH4_NOEXPIRE_WITH_OPEN
= 0x01,
175 FH4_VOLATILE_ANY
= 0x02,
176 FH4_VOL_MIGRATION
= 0x04,
177 FH4_VOL_RENAME
= 0x08
181 OPEN4_SHARE_ACCESS_READ
= 1,
182 OPEN4_SHARE_ACCESS_WRITE
= 2,
183 OPEN4_SHARE_ACCESS_BOTH
= 3
187 static inline OpenAccess
188 sModeToAccess(int mode
)
190 switch (mode
& O_RWMASK
) {
192 return OPEN4_SHARE_ACCESS_READ
;
194 return OPEN4_SHARE_ACCESS_WRITE
;
196 return OPEN4_SHARE_ACCESS_BOTH
;
199 return OPEN4_SHARE_ACCESS_READ
;
217 CLAIM_DELEGATE_CUR
= 2,
218 CLAIM_DELEGATE_PREV
= 3
221 enum OpenDelegation
{
222 OPEN_DELEGATE_NONE
= 0,
223 OPEN_DELEGATE_READ
= 1,
224 OPEN_DELEGATE_WRITE
= 2
227 struct OpenDelegationData
{
228 OpenDelegation fType
;
238 OPEN4_RESULT_CONFIRM
= 2,
239 OPEN4_RESULT_LOCKTYPE_POSIX
= 4
267 static inline LockType
268 sGetLockType(short type
, bool wait
) {
270 case F_RDLCK
: return wait
? READW_LT
: READ_LT
;
271 case F_WRLCK
: return wait
? WRITEW_LT
: WRITE_LT
;
272 default: return READ_LT
;
278 sLockTypeToHaiku(LockType type
) {
288 default: return F_UNLCK
;
309 NFS4ERR_NAMETOOLONG
= 63,
310 NFS4ERR_NOTEMPTY
= 66,
313 NFS4ERR_BADHANDLE
= 10001,
314 NFS4ERR_BAD_COOKIE
= 10003,
315 NFS4ERR_NOTSUPP
= 10004,
316 NFS4ERR_TOOSMALL
= 10005,
317 NFS4ERR_SERVERFAULT
= 10006,
318 NFS4ERR_BADTYPE
= 10007,
319 NFS4ERR_DELAY
= 10008,
320 NFS4ERR_SAME
= 10009,
321 NFS4ERR_DENIED
= 10010,
322 NFS4ERR_EXPIRED
= 10011,
323 NFS4ERR_LOCKED
= 10012,
324 NFS4ERR_GRACE
= 10013,
325 NFS4ERR_FHEXPIRED
= 10014,
326 NFS4ERR_SHARE_DENIED
= 10015,
327 NFS4ERR_WRONGSEC
= 10016,
328 NFS4ERR_CLID_INUSE
= 10017,
329 NFS4ERR_RESOURCE
= 10018,
330 NFS4ERR_MOVED
= 10019,
331 NFS4ERR_NOFILEHANDLE
= 10020,
332 NFS4ERR_MINOR_VERS_MISMATCH
= 10021,
333 NFS4ERR_STALE_CLIENTID
= 10022,
334 NFS4ERR_STALE_STATEID
= 10023,
335 NFS4ERR_OLD_STATEID
= 10024,
336 NFS4ERR_BAD_STATEID
= 10025,
337 NFS4ERR_BAD_SEQID
= 10026,
338 NFS4ERR_NOT_SAME
= 10027,
339 NFS4ERR_LOCK_RANGE
= 10028,
340 NFS4ERR_SYMLINK
= 10029,
341 NFS4ERR_RESTOREFH
= 10030,
342 NFS4ERR_LEASE_MOVED
= 10031,
343 NFS4ERR_ATTRNOTSUPP
= 10032,
344 NFS4ERR_NO_GRACE
= 10033,
345 NFS4ERR_RECLAIM_BAD
= 10034,
346 NFS4ERR_RECLAIM_CONFLICT
= 10035,
347 NFS4ERR_BADXDR
= 10036,
348 NFS4ERR_LOCKS_HELD
= 10037,
349 NFS4ERR_OPENMODE
= 10038,
350 NFS4ERR_BADOWNER
= 10039,
351 NFS4ERR_BADCHAR
= 10040,
352 NFS4ERR_BADNAME
= 10041,
353 NFS4ERR_BAD_RANGE
= 10042,
354 NFS4ERR_LOCK_NOTSUPP
= 10043,
355 NFS4ERR_OP_ILLEGAL
= 10044,
356 NFS4ERR_DEADLOCK
= 10045,
357 NFS4ERR_FILE_OPEN
= 10046,
358 NFS4ERR_ADMIN_REVOKED
= 10047,
359 NFS4ERR_CB_PATH_DOWN
= 10048
363 static inline bigtime_t
364 sSecToBigTime(uint32 sec
)
366 return static_cast<bigtime_t
>(sec
) * 1000000;
371 IsFileHandleInvalid(uint32 error
)
373 return error
== NFS4ERR_BADHANDLE
|| error
== NFS4ERR_FHEXPIRED
374 || error
== NFS4ERR_STALE
;