vfs: check userland buffers before reading them.
[haiku.git] / src / add-ons / kernel / file_systems / nfs4 / VnodeToInode.cpp
blob6e260bc4baa71d89eac03d60f26ae8643a31cb36
1 /*
2 * Copyright 2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Paweł Dziepak, pdziepak@quarnos.org
7 */
10 #include "VnodeToInode.h"
13 Inode*
14 VnodeToInode::Get()
16 if (fInode == NULL) {
17 status_t result = fFileSystem->GetInode(fID, &fInode);
18 if (result != B_OK)
19 fInode = NULL;
22 return fInode;
26 void
27 VnodeToInode::Replace(Inode* newInode)
29 WriteLocker _(fLock);
30 if (!IsRoot())
31 delete fInode;
33 fInode = newInode;
37 bool
38 VnodeToInode::Unlink(InodeNames* parent, const char* name)
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;
48 return removed;
51 return false;