xref: /haiku/src/add-ons/kernel/file_systems/nfs4/IdMap.h (revision 25a7b01d15612846f332751841da3579db313082)
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 
28bb035526SPawel Dziepak 	inline	status_t	InitStatus();
29bb035526SPawel 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 
39bb035526SPawel Dziepak 			status_t	fInitStatus;
40bb035526SPawel Dziepak 
41b2cea80cSPawel Dziepak 			mutex		fLock;
42b2cea80cSPawel Dziepak 
43b2cea80cSPawel Dziepak 			port_id		fRequestPort;
44b2cea80cSPawel Dziepak 			port_id		fReplyPort;
45b2cea80cSPawel Dziepak };
46b2cea80cSPawel Dziepak 
47bb035526SPawel Dziepak 
48bb035526SPawel Dziepak inline status_t
InitStatus()49bb035526SPawel Dziepak IdMap::InitStatus()
50bb035526SPawel Dziepak {
51bb035526SPawel Dziepak 	return fInitStatus;
52bb035526SPawel Dziepak }
53bb035526SPawel Dziepak 
54*dadd844fSPawel Dziepak 
55b2cea80cSPawel Dziepak extern IdMap*	gIdMapper;
562431c452SPawel Dziepak extern mutex	gIdMapperLock;
57b2cea80cSPawel Dziepak 
58b2cea80cSPawel Dziepak 
59b2cea80cSPawel Dziepak #endif	// IDMAP_H
60b2cea80cSPawel Dziepak 
61