xref: /haiku/src/add-ons/kernel/file_systems/nfs4/IdMap.h (revision 2431c4521c4e3a2fb15d3440ee10ebc68c081bce)
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 IDMAP_H
9 #define IDMAP_H
10 
11 
12 #include <lock.h>
13 #include <port.h>
14 #include <SupportDefs.h>
15 
16 
17 class IdMap {
18 public:
19 					IdMap();
20 					~IdMap();
21 
22 		uid_t		GetUserId(const char* owner);
23 		gid_t		GetGroupId(const char* ownerGroup);
24 
25 		char*		GetOwner(uid_t user);
26 		char*		GetOwnerGroup(gid_t group);
27 
28 private:
29 		status_t	_Repair();
30 
31 		template<typename T>
32 		void*		_GetBuffer(T value, int32 code);
33 
34 		template<typename T>
35 		T			_GetValue(const char* buffer, int32 code);
36 
37 		mutex		fLock;
38 
39 		port_id		fRequestPort;
40 		port_id		fReplyPort;
41 };
42 
43 extern IdMap*	gIdMapper;
44 extern mutex	gIdMapperLock;
45 
46 
47 #endif	// IDMAP_H
48 
49