BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / file_systems / nfs4 / Cookie.h
blob056fb5d845bd689946c2e46c3412cb2f7d939dcf
1 /*
2 * Copyright 2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Paweł Dziepak, pdziepak@quarnos.org
7 */
8 #ifndef COOKIE_H
9 #define COOKIE_H
12 #include <SupportDefs.h>
14 #include "DirectoryCache.h"
15 #include "FileSystem.h"
18 struct OpenState;
20 struct LockOwner {
21 uint64 fClientId;
23 uint32 fStateId[3];
24 uint32 fStateSeq;
25 uint32 fSequence;
27 uint32 fOwner;
29 uint32 fUseCount;
31 mutex fLock;
33 LockOwner* fNext;
34 LockOwner* fPrev;
36 LockOwner(uint32 owner);
37 ~LockOwner();
40 struct LockInfo {
41 LockOwner* fOwner;
43 uint64 fStart;
44 uint64 fLength;
45 LockType fType;
47 LockInfo* fNext;
48 LockInfo* fCookieNext;
50 LockInfo(LockOwner* owner);
51 ~LockInfo();
53 bool operator==(const struct flock& lock) const;
54 bool operator==(const LockInfo& lock) const;
57 struct Cookie {
58 struct RequestEntry {
59 RPC::Request* fRequest;
60 RequestEntry* fNext;
63 FileSystem* fFileSystem;
64 RequestEntry* fRequests;
65 mutex fRequestLock;
67 sem_id fSnoozeCancel;
69 Cookie(FileSystem* fileSystem);
70 virtual ~Cookie();
72 status_t RegisterRequest(RPC::Request* req);
73 status_t UnregisterRequest(RPC::Request* req);
74 status_t CancelAll();
77 struct OpenStateCookie : public Cookie {
78 OpenState* fOpenState;
79 uint32 fMode;
81 OpenStateCookie(FileSystem* fileSystem);
84 struct OpenFileCookie : public OpenStateCookie {
85 LockInfo* fLocks;
87 void AddLock(LockInfo* lock);
88 void RemoveLock(LockInfo* lock, LockInfo* prev);
90 OpenFileCookie(FileSystem* fileSystem);
93 struct OpenDirCookie : public Cookie {
94 int fSpecial;
95 DirectoryCacheSnapshot* fSnapshot;
96 NameCacheEntry* fCurrent;
97 bool fEOF;
99 bool fAttrDir;
101 OpenDirCookie(FileSystem* fileSystem);
102 ~OpenDirCookie();
105 struct OpenAttrCookie : public OpenStateCookie {
106 OpenAttrCookie(FileSystem* fileSystem);
110 #endif // COOKIE_H