xref: /haiku/src/add-ons/kernel/file_systems/nfs4/IdMap.h (revision bb0355263687491aa7abe5a54bfd98e35fc3665d)
1b2cea80cSPawel Dziepak /*
2b2cea80cSPawel Dziepak  * Copyright 2012 Haiku, Inc. All rights reserved.
3b2cea80cSPawel Dziepak  * Distributed under the terms of the MIT License.
4b2cea80cSPawel Dziepak  *
5b2cea80cSPawel Dziepak  * Authors:
6b2cea80cSPawel Dziepak  *		Paweł Dziepak, pdziepak@quarnos.org
7b2cea80cSPawel Dziepak  */
8b2cea80cSPawel Dziepak #ifndef IDMAP_H
9b2cea80cSPawel Dziepak #define IDMAP_H
10b2cea80cSPawel Dziepak 
11b2cea80cSPawel Dziepak 
12b2cea80cSPawel Dziepak #include <lock.h>
13b2cea80cSPawel Dziepak #include <port.h>
14b2cea80cSPawel Dziepak #include <SupportDefs.h>
15b2cea80cSPawel Dziepak 
16b2cea80cSPawel Dziepak 
17b2cea80cSPawel Dziepak class IdMap {
18b2cea80cSPawel Dziepak public:
19b2cea80cSPawel Dziepak 						IdMap();
20b2cea80cSPawel Dziepak 						~IdMap();
21b2cea80cSPawel Dziepak 
22b2cea80cSPawel Dziepak 			uid_t		GetUserId(const char* owner);
23b2cea80cSPawel Dziepak 			gid_t		GetGroupId(const char* ownerGroup);
24b2cea80cSPawel Dziepak 
25b2cea80cSPawel Dziepak 			char*		GetOwner(uid_t user);
26b2cea80cSPawel Dziepak 			char*		GetOwnerGroup(gid_t group);
27b2cea80cSPawel Dziepak 
28*bb035526SPawel Dziepak 	inline	status_t	InitStatus();
29*bb035526SPawel Dziepak 
30b2cea80cSPawel Dziepak private:
31b2cea80cSPawel Dziepak 			status_t	_Repair();
32b2cea80cSPawel Dziepak 
33b2cea80cSPawel Dziepak 			template<typename T>
34b2cea80cSPawel Dziepak 			void*		_GetBuffer(T value, int32 code);
35b2cea80cSPawel Dziepak 
36b2cea80cSPawel Dziepak 			template<typename T>
37b2cea80cSPawel Dziepak 			T			_GetValue(const char* buffer, int32 code);
38b2cea80cSPawel Dziepak 
39*bb035526SPawel Dziepak 			status_t	fInitStatus;
40*bb035526SPawel Dziepak 
41b2cea80cSPawel Dziepak 			mutex		fLock;
42b2cea80cSPawel Dziepak 
43b2cea80cSPawel Dziepak 			port_id		fRequestPort;
44b2cea80cSPawel Dziepak 			port_id		fReplyPort;
45b2cea80cSPawel Dziepak };
46b2cea80cSPawel Dziepak 
47*bb035526SPawel Dziepak 
48*bb035526SPawel Dziepak inline status_t
49*bb035526SPawel Dziepak IdMap::InitStatus()
50*bb035526SPawel Dziepak {
51*bb035526SPawel Dziepak 	return fInitStatus;
52*bb035526SPawel Dziepak }
53*bb035526SPawel Dziepak 
54b2cea80cSPawel Dziepak extern IdMap*	gIdMapper;
552431c452SPawel Dziepak extern mutex	gIdMapperLock;
56b2cea80cSPawel Dziepak 
57b2cea80cSPawel Dziepak 
58b2cea80cSPawel Dziepak #endif	// IDMAP_H
59b2cea80cSPawel Dziepak 
60