1// VNode.cpp 2// 3// Copyright (c) 2003, Ingo Weinhold (bonefish@cs.tu-berlin.de) 4// 5// This program is free software; you can redistribute it and/or modify 6// it under the terms of the GNU General Public License as published by 7// the Free Software Foundation; either version 2 of the License, or 8// (at your option) any later version. 9// 10// This program is distributed in the hope that it will be useful, 11// but WITHOUT ANY WARRANTY; without even the implied warranty of 12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13// GNU General Public License for more details. 14// 15// You should have received a copy of the GNU General Public License 16// along with this program; if not, write to the Free Software 17// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18// 19// You can alternatively use *this file* under the terms of the the MIT 20// license included in this package. 21 22#include "VNode.h" 23 24/*! 25 \class VNode 26 \brief Represents a vnode, i.e. an object in a file system. 27 28 This class bundles all information relevant to a vnode, i.e. its ID, 29 the ID of its parent node and its stat data (for fast and convenient 30 access). VNode knows how to convert between the VFS ino_t 31 and the object+dir ID representation in ReiserFS. 32*/ 33 34// constructor 35VNode::VNode() 36 : fParentID(0), 37 fDirID(0), 38 fObjectID(0), 39 fStatData() 40{ 41} 42 43// constructor 44VNode::VNode(const VNode &node) 45 : fParentID(0), 46 fDirID(0), 47 fObjectID(0), 48 fStatData() 49{ 50 *this = node; 51} 52 53// constructor 54VNode::VNode(ino_t id) 55 : fParentID(0), 56 fDirID(GetDirIDFor(id)), 57 fObjectID(GetObjectIDFor(id)), 58 fStatData() 59{ 60} 61 62// constructor 63VNode::VNode(uint32 dirID, uint32 objectID) 64 : fParentID(0), 65 fDirID(dirID), 66 fObjectID(objectID), 67 fStatData() 68{ 69} 70 71// destructor 72VNode::~VNode() 73{ 74} 75 76// SetTo 77status_t 78VNode::SetTo(ino_t id) 79{ 80 return SetTo(GetDirIDFor(id), GetObjectIDFor(id)); 81} 82 83// SetTo 84status_t 85VNode::SetTo(uint32 dirID, uint32 objectID) 86{ 87 fParentID = 0; 88 fDirID = dirID; 89 fObjectID = objectID; 90 fStatData.Unset(); 91 return B_OK; 92} 93 94// GetID 95ino_t 96VNode::GetID() const 97{ 98 return GetIDFor(fDirID, fObjectID); 99} 100 101// SetParentID 102void 103VNode::SetParentID(uint32 dirID, uint32 objectID) 104{ 105 SetParentID(GetIDFor(dirID, objectID)); 106} 107 108// = 109VNode & 110VNode::operator=(const VNode &node) 111{ 112 if (&node != this) { 113 fParentID = node.fParentID; 114 fDirID = node.fDirID; 115 fObjectID = node.fObjectID; 116 fStatData = node.fStatData; 117 } 118 return *this; 119} 120 121