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 inline status_t InitStatus(); 29 30 private: 31 status_t _Repair(); 32 33 template<typename T> 34 void* _GetBuffer(T value, int32 code); 35 36 template<typename T> 37 T _GetValue(const char* buffer, int32 code); 38 39 status_t fInitStatus; 40 41 mutex fLock; 42 43 port_id fRequestPort; 44 port_id fReplyPort; 45 }; 46 47 48 inline status_t 49 IdMap::InitStatus() 50 { 51 return fInitStatus; 52 } 53 54 55 extern IdMap* gIdMapper; 56 extern mutex gIdMapperLock; 57 58 59 #endif // IDMAP_H 60 61