xref: /haiku/src/add-ons/kernel/file_systems/reiserfs/VNode.h (revision 1214ef1b2100f2b3299fc9d8d6142e46f70a4c3f)
1 // VNode.h
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 #ifndef V_NODE_H
23 #define V_NODE_H
24 
25 #include <fs_interface.h>
26 
27 #include "StatItem.h"
28 
29 class VNode {
30 public:
31 	VNode();
32 	VNode(const VNode &node);
33 	VNode(ino_t id);
34 	VNode(uint32 dirID, uint32 objectID);
35 	~VNode();
36 
37 	status_t SetTo(ino_t id);
38 	status_t SetTo(uint32 dirID, uint32 objectID);
39 
40 //	void SetParentDirID(uint32 id)		{ fParentDirID = id; }
41 //	uint32 GetParentDirID() const		{ return fParentDirID; }
42 //	void SetParentObjectID(uint32 id)	{ fParentObjectID = id; }
43 //	uint32 GetParentObjectID() const	{ return fParentObjectID; }
44 	void SetDirID(uint32 id)			{ fDirID = id; }
45 	uint32 GetDirID() const				{ return fDirID; }
46 	void SetObjectID(uint32 id)			{ fObjectID = id; }
47 	uint32 GetObjectID() const			{ return fObjectID; }
48 
49 	ino_t GetID() const;
50 	void SetParentID(uint32 dirID, uint32 objectID);
51 	void SetParentID(ino_t id)		{ fParentID = id; }
52 	// only valid for dirs!
53 	ino_t GetParentID() const		{ return fParentID; }
54 
55 	StatData *GetStatData() { return &fStatData; }
56 	const StatData *GetStatData() const { return &fStatData; }
57 
58 	bool IsDir() const { return fStatData.IsDir(); }
59 	bool IsFile() const { return fStatData.IsFile(); }
60 	bool IsSymlink() const { return fStatData.IsSymlink(); }
61 	bool IsEsoteric() const { return fStatData.IsEsoteric(); }
62 
63 	// vnode ID <-> dir,object ID conversion
64 	static ino_t GetIDFor(uint32 dirID, uint32 objectID)
65 		{ return (ino_t)((uint64)dirID << 32 | (uint64)objectID); }
66 	static uint32 GetDirIDFor(ino_t id) { return uint32((uint64)id >> 32); }
67 	static uint32 GetObjectIDFor(ino_t id)
68 		{ return uint32((uint64)id & 0xffffffffULL); }
69 
70 	VNode &operator=(const VNode &node);
71 
72 private:
73 	ino_t		fParentID;
74 	uint32		fDirID;
75 	uint32		fObjectID;
76 	StatData	fStatData;
77 };
78 
79 #endif	// V_NODE_H
80