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 9 10 #include "VnodeToInode.h" 11 12 13 Inode* Get()14VnodeToInode::Get() 15 { 16 if (fInode == NULL) { 17 status_t result = fFileSystem->GetInode(fID, &fInode); 18 if (result != B_OK) 19 fInode = NULL; 20 } 21 22 return fInode; 23 } 24 25 26 void Replace(Inode * newInode)27VnodeToInode::Replace(Inode* newInode) 28 { 29 WriteLocker _(fLock); 30 if (!IsRoot()) 31 delete fInode; 32 33 fInode = newInode; 34 } 35 36 37 bool Unlink(InodeNames * parent,const char * name)38VnodeToInode::Unlink(InodeNames* parent, const char* name) 39 { 40 WriteLocker _(fLock); 41 if (fInode != NULL && !IsRoot()) { 42 bool removed = fInode->GetFileSystem()->InoIdMap()->RemoveName(fID, 43 parent, name); 44 if (removed) { 45 delete fInode; 46 fInode = NULL; 47 } 48 return removed; 49 } 50 51 return false; 52 } 53 54