1 /*
2 * Copyright 2012,2013 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 INODEIDMAP_H
9 #define INODEIDMAP_H
10
11
12 #include <lock.h>
13 #include <SupportDefs.h>
14 #include <util/AutoLock.h>
15 #include <util/AVLTreeMap.h>
16
17 #include "FileInfo.h"
18
19
20 class InodeIdMap {
21 public:
22 inline InodeIdMap();
23 inline ~InodeIdMap();
24
25 status_t AddName(FileInfo& fileInfo,
26 InodeNames* parent,
27 const char* name, ino_t id);
28 bool RemoveName(ino_t id,
29 InodeNames* parent,
30 const char* name);
31 status_t RemoveEntry(ino_t id);
32 status_t GetFileInfo(FileInfo* fileInfo,
33 ino_t id);
34
35 private:
36 AVLTreeMap<ino_t, FileInfo> fMap;
37 mutex fLock;
38
39 };
40
41
42 inline
InodeIdMap()43 InodeIdMap::InodeIdMap()
44 {
45 mutex_init(&fLock, NULL);
46 }
47
48
49 inline
~InodeIdMap()50 InodeIdMap::~InodeIdMap()
51 {
52 mutex_destroy(&fLock);
53 }
54
55
56 #endif // INODEIDMAP_H
57
58