1/*
2 * Copyright 2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Paweł Dziepak, pdziepak@quarnos.org
7 */
8#ifndef OPENSTATE_H
9#define OPENSTATE_H
10
11
12#include <lock.h>
13#include <SupportDefs.h>
14#include <util/KernelReferenceable.h>
15
16#include "Cookie.h"
17#include "NFS4Object.h"
18
19
20struct OpenState : public NFS4Object, public KernelReferenceable,
21	public DoublyLinkedListLinkImpl<OpenState> {
22							OpenState();
23							~OpenState();
24
25			uint64			fClientID;
26
27			int				fMode;
28			mutex			fLock;
29
30			uint32			fStateID[3];
31			uint32			fStateSeq;
32
33			bool			fOpened;
34			Delegation*		fDelegation;
35
36			LockInfo*		fLocks;
37			mutex			fLocksLock;
38
39			LockOwner*		fLockOwners;
40			mutex			fOwnerLock;
41
42			LockOwner*		GetLockOwner(uint32 owner);
43
44			void			AddLock(LockInfo* lock);
45			void			RemoveLock(LockInfo* lock, LockInfo* prev);
46			void			DeleteLock(LockInfo* lock);
47
48			status_t		Reclaim(uint64 newClientID);
49
50			status_t		Close();
51
52private:
53			status_t		_ReclaimOpen(uint64 newClientID);
54			status_t		_ReclaimLocks(uint64 newClientID);
55			status_t		_ReleaseLockOwner(LockOwner* owner);
56};
57
58
59#endif	// OPENSTATE_H
60
61