2 * Copyright 2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Paweł Dziepak, pdziepak@quarnos.org
12 #include <SupportDefs.h>
13 #include <util/AutoLock.h>
16 #include "InodeIdMap.h"
17 #include "RootInode.h"
21 inline VnodeToInode(ino_t id
, FileSystem
* fileSystem
);
22 inline ~VnodeToInode();
27 inline Inode
* GetPointer() const;
29 void Replace(Inode
* newInode
);
31 bool Unlink(InodeNames
* parent
, const char* name
);
34 inline ino_t
ID() const;
36 inline bool IsRoot() const;
42 FileSystem
* fFileSystem
;
45 class VnodeToInodeLocking
{
47 inline bool Lock(VnodeToInode
* vti
)
53 inline void Unlock(VnodeToInode
* vti
)
59 typedef AutoLocker
<VnodeToInode
, VnodeToInodeLocking
> VnodeToInodeLocker
;
62 VnodeToInode::VnodeToInode(ino_t id
, FileSystem
* fileSystem
)
66 fFileSystem(fileSystem
)
68 rw_lock_init(&fLock
, NULL
);
73 VnodeToInode::~VnodeToInode()
76 if (fFileSystem
!= NULL
&& !IsRoot())
77 fFileSystem
->InoIdMap()->RemoveEntry(fID
);
78 rw_lock_destroy(&fLock
);
85 rw_lock_read_lock(&fLock
);
90 VnodeToInode::Unlock()
92 rw_lock_read_unlock(&fLock
);
104 VnodeToInode::IsRoot() const
106 return fInode
&& fFileSystem
&& fInode
->ID() == fFileSystem
->Root()->ID();
111 VnodeToInode::GetPointer() const
118 VnodeToInode::ID() const
123 #endif // VNODETOINODE_H