xref: /haiku/src/add-ons/kernel/file_systems/packagefs/nodes/Node.cpp (revision 6a2d53e7237764eab0c7b6d121772f26d636fb60)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include "Node.h"
8 
9 #include <stdlib.h>
10 #include <string.h>
11 
12 #include "DebugSupport.h"
13 #include "EmptyAttributeDirectoryCookie.h"
14 
15 
16 DEFINE_REFERENCEABLE_ACQUIRE_RELEASE(Node, fReferenceable);
17 
18 
19 Node::Node(ino_t id)
20 	:
21 	fID(id),
22 	fParent(NULL),
23 	fName(),
24 	fFlags(0)
25 {
26 	rw_lock_init(&fLock, "packagefs node");
27 }
28 
29 
30 Node::~Node()
31 {
32 	rw_lock_destroy(&fLock);
33 }
34 
35 
36 status_t
37 Node::Init(Directory* parent, const String& name)
38 {
39 	fParent = parent;
40 	fName = name;
41 	fFlags = 0;
42 	return B_OK;
43 }
44 
45 
46 status_t
47 Node::VFSInit(dev_t deviceID)
48 {
49 	fFlags |= NODE_FLAG_KNOWN_TO_VFS;
50 	return B_OK;
51 }
52 
53 
54 void
55 Node::VFSUninit()
56 {
57 	fFlags &= ~(uint32)NODE_FLAG_KNOWN_TO_VFS;
58 }
59 
60 
61 void
62 Node::SetID(ino_t id)
63 {
64 	fID = id;
65 }
66 
67 
68 void
69 Node::SetParent(Directory* parent)
70 {
71 	fParent = parent;
72 }
73 
74 
75 uid_t
76 Node::UserID() const
77 {
78 	return 0;
79 }
80 
81 
82 gid_t
83 Node::GroupID() const
84 {
85 	return 0;
86 }
87 
88 
89 status_t
90 Node::OpenAttributeDirectory(AttributeDirectoryCookie*& _cookie)
91 {
92 	AttributeDirectoryCookie* cookie
93 		= new(std::nothrow) EmptyAttributeDirectoryCookie;
94 	if (cookie == NULL)
95 		return B_NO_MEMORY;
96 
97 	_cookie = cookie;
98 	return B_OK;
99 }
100 
101 
102 status_t
103 Node::OpenAttribute(const StringKey& name, int openMode,
104 	AttributeCookie*& _cookie)
105 {
106 	return B_ENTRY_NOT_FOUND;
107 }
108 
109 
110 status_t
111 Node::IndexAttribute(AttributeIndexer* indexer)
112 {
113 	return B_NOT_SUPPORTED;
114 }
115 
116 
117 void*
118 Node::IndexCookieForAttribute(const StringKey& name) const
119 {
120 	return NULL;
121 }
122