1// Volume.cpp
2
3#include <new>
4
5#include "AutoLocker.h"
6#include "Compatibility.h"
7#include "Debug.h"
8#include "Node.h"
9#include "QueryManager.h"
10#include "Volume.h"
11#include "VolumeManager.h"
12
13// constructor
14Volume::Volume(VolumeManager* volumeManager)
15	: FSObject(),
16	  fLock("volume"),
17	  fVolumeManager(volumeManager),
18	  fParentVolume(NULL),
19	  fName(),
20	  fUnmounting(false)
21{
22}
23
24// destructor
25Volume::~Volume()
26{
27}
28
29// GetVolumeManager
30VolumeManager*
31Volume::GetVolumeManager() const
32{
33	return fVolumeManager;
34}
35
36// SetParentVolume
37void
38Volume::SetParentVolume(Volume* parent)
39{
40	AutoLocker<Locker> _(fLock);
41	fParentVolume = parent;
42}
43
44// GetParentVolume
45Volume*
46Volume::GetParentVolume() const
47{
48	return fParentVolume;
49}
50
51// PutVolume
52void
53Volume::PutVolume()
54{
55	fVolumeManager->PutVolume(this);
56}
57
58// Init
59status_t
60Volume::Init(const char* name)
61{
62	if (!name || strlen(name) == 0)
63		return B_BAD_VALUE;
64
65	if (!fName.SetTo(name))
66		return B_NO_MEMORY;
67
68	return B_OK;
69}
70
71// Uninit
72void
73Volume::Uninit()
74{
75}
76
77// GetName
78const char*
79Volume::GetName() const
80{
81	return fName.GetString();
82}
83
84// GetRootID
85vnode_id
86Volume::GetRootID() const
87{
88	return GetRootNode()->GetID();
89}
90
91// SetUnmounting
92void
93Volume::SetUnmounting(bool unmounting)
94{
95	fUnmounting = unmounting;
96}
97
98// IsUnmounting
99bool
100Volume::IsUnmounting() const
101{
102	return fUnmounting;
103}
104
105// HandleEvent
106void
107Volume::HandleEvent(VolumeEvent* event)
108{
109}
110
111// PrepareToUnmount
112void
113Volume::PrepareToUnmount()
114{
115	fVolumeManager->GetQueryManager()->VolumeUnmounting(this);
116}
117
118
119// #pragma mark -
120// #pragma mark ----- client methods -----
121
122// GetVNode
123status_t
124Volume::GetVNode(vnode_id vnid, Node** node)
125{
126	return get_vnode(fVolumeManager->GetID(), vnid, (void**)node);
127}
128
129// PutVNode
130status_t
131Volume::PutVNode(vnode_id vnid)
132{
133	return put_vnode(fVolumeManager->GetID(), vnid);
134}
135
136// NewVNode
137status_t
138Volume::NewVNode(vnode_id vnid, Node* node)
139{
140	status_t error = new_vnode(fVolumeManager->GetID(), vnid, node);
141	if (error == B_OK)
142		node->SetKnownToVFS(true);
143	return error;
144}
145
146// RemoveVNode
147status_t
148Volume::RemoveVNode(vnode_id vnid)
149{
150	return remove_vnode(fVolumeManager->GetID(), vnid);
151}
152
153// UnremoveVNode
154status_t
155Volume::UnremoveVNode(vnode_id vnid)
156{
157	return unremove_vnode(fVolumeManager->GetID(), vnid);
158}
159
160// IsVNodeRemoved
161int
162Volume::IsVNodeRemoved(vnode_id vnid)
163{
164	return is_vnode_removed(fVolumeManager->GetID(), vnid);
165}
166
167// SendNotification
168int
169Volume::SendNotification(port_id port, int32 token, uint32 what, int32 op,
170	nspace_id nsida, nspace_id nsidb, vnode_id vnida, vnode_id vnidb,
171	vnode_id vnidc, const char *name)
172{
173PRINT(("Volume::SendNotification(%ld, %ld, 0x%lx, 0x%lx, %ld, %ld, %lld, %lld, %lld, \"%s\")\n", port, token, what, op, nsida, nsidb, vnida, vnidb, vnidc, name));
174	return send_notification(port, token, what, op, nsida, nsidb, vnida,
175		vnidb, vnidc, name);
176}
177
178// NotifyListener
179int
180Volume::NotifyListener(int32 opcode, nspace_id nsid, vnode_id vnida,
181	vnode_id vnidb, vnode_id vnidc, const char *name)
182{
183	return notify_listener(opcode, nsid, vnida, vnidb, vnidc, name);
184}
185
186
187// #pragma mark -
188// #pragma mark ----- FS -----
189
190// Unmount
191status_t
192Volume::Unmount()
193{
194	return B_BAD_VALUE;
195}
196
197// Sync
198status_t
199Volume::Sync()
200{
201	return B_BAD_VALUE;
202}
203
204// ReadFSStat
205status_t
206Volume::ReadFSStat(fs_info* info)
207{
208	return B_BAD_VALUE;
209}
210
211// WriteFSStat
212status_t
213Volume::WriteFSStat(struct fs_info* info, int32 mask)
214{
215	return B_BAD_VALUE;
216}
217
218
219// #pragma mark -
220// #pragma mark ----- vnodes -----
221
222// ReadVNode
223status_t
224Volume::ReadVNode(vnode_id vnid, char reenter, Node** _node)
225{
226	return B_BAD_VALUE;
227}
228
229// WriteVNode
230status_t
231Volume::WriteVNode(Node* node, char reenter)
232{
233	return B_BAD_VALUE;
234}
235
236// RemoveVNode
237status_t
238Volume::RemoveVNode(Node* node, char reenter)
239{
240	return B_BAD_VALUE;
241}
242
243
244// #pragma mark -
245// #pragma mark ----- nodes -----
246
247// FSync
248status_t
249Volume::FSync(Node* node)
250{
251	return B_BAD_VALUE;
252}
253
254// ReadStat
255status_t
256Volume::ReadStat(Node* node, struct stat* st)
257{
258	return B_BAD_VALUE;
259}
260
261// WriteStat
262status_t
263Volume::WriteStat(Node* node, struct stat *st, uint32 mask)
264{
265	return B_BAD_VALUE;
266}
267
268// Access
269status_t
270Volume::Access(Node* node, int mode)
271{
272	return B_BAD_VALUE;
273}
274
275
276// #pragma mark -
277// #pragma mark ----- files -----
278
279// Create
280status_t
281Volume::Create(Node* dir, const char* name, int openMode, int mode,
282	vnode_id* vnid, void** cookie)
283{
284	return B_BAD_VALUE;
285}
286
287// Open
288status_t
289Volume::Open(Node* node, int openMode, void** cookie)
290{
291	return B_BAD_VALUE;
292}
293
294// Close
295status_t
296Volume::Close(Node* node, void* cookie)
297{
298	return B_BAD_VALUE;
299}
300
301// FreeCookie
302status_t
303Volume::FreeCookie(Node* node, void* cookie)
304{
305	return B_BAD_VALUE;
306}
307
308// Read
309status_t
310Volume::Read(Node* node, void* cookie, off_t pos, void* _buffer,
311	size_t bufferSize, size_t* _bytesRead)
312{
313	return B_BAD_VALUE;
314}
315
316// Write
317status_t
318Volume::Write(Node* node, void* cookie, off_t pos, const void* _buffer,
319	size_t bufferSize, size_t* bytesWritten)
320{
321	return B_BAD_VALUE;
322}
323
324// IOCtl
325status_t
326Volume::IOCtl(Node* node, void* cookie, int cmd, void* buffer,
327	size_t bufferSize)
328{
329	return B_BAD_VALUE;
330}
331
332// SetFlags
333status_t
334Volume::SetFlags(Node* node, void* cookie, int flags)
335{
336	return B_BAD_VALUE;
337}
338
339
340// #pragma mark -
341// #pragma mark ----- hard links / symlinks -----
342
343// Link
344status_t
345Volume::Link(Node* dir, const char* name, Node* node)
346{
347	return B_BAD_VALUE;
348}
349
350// Unlink
351status_t
352Volume::Unlink(Node* dir, const char* name)
353{
354	return B_BAD_VALUE;
355}
356
357// Symlink
358status_t
359Volume::Symlink(Node* dir, const char* name, const char* target)
360{
361	return B_BAD_VALUE;
362}
363
364// ReadLink
365status_t
366Volume::ReadLink(Node* node, char* buffer, size_t bufferSize,
367	size_t* bytesRead)
368{
369	return B_BAD_VALUE;
370}
371
372// Rename
373status_t
374Volume::Rename(Node* oldDir, const char* oldName, Node* newDir,
375	const char* newName)
376{
377	return B_BAD_VALUE;
378}
379
380
381// #pragma mark -
382// #pragma mark ----- directories -----
383
384// MkDir
385status_t
386Volume::MkDir(Node* dir, const char* name, int mode)
387{
388	return B_BAD_VALUE;
389}
390
391// RmDir
392status_t
393Volume::RmDir(Node* dir, const char* name)
394{
395	return B_BAD_VALUE;
396}
397
398// OpenDir
399status_t
400Volume::OpenDir(Node* node, void** _cookie)
401{
402	return B_BAD_VALUE;
403}
404
405// CloseDir
406status_t
407Volume::CloseDir(Node* node, void* cookie)
408{
409	return B_BAD_VALUE;
410}
411
412// FreeDirCookie
413status_t
414Volume::FreeDirCookie(Node* node, void* _cookie)
415{
416	return B_BAD_VALUE;
417}
418
419// ReadDir
420status_t
421Volume::ReadDir(Node* node, void* _cookie, struct dirent* buffer,
422	size_t bufferSize, int32 count, int32* countRead)
423{
424	return B_BAD_VALUE;
425}
426
427// RewindDir
428status_t
429Volume::RewindDir(Node* node, void* _cookie)
430{
431	return B_BAD_VALUE;
432}
433
434// Walk
435status_t
436Volume::Walk(Node* dir, const char* entryName, char** resolvedPath,
437	vnode_id* vnid)
438{
439	return B_BAD_VALUE;
440}
441
442
443// #pragma mark -
444// #pragma mark ----- attributes -----
445
446// OpenAttrDir
447status_t
448Volume::OpenAttrDir(Node* node, void** _cookie)
449{
450	return B_BAD_VALUE;
451}
452
453// CloseAttrDir
454status_t
455Volume::CloseAttrDir(Node* node, void* cookie)
456{
457	return B_BAD_VALUE;
458}
459
460// FreeAttrDirCookie
461status_t
462Volume::FreeAttrDirCookie(Node* node, void* _cookie)
463{
464	return B_BAD_VALUE;
465}
466
467// ReadAttrDir
468status_t
469Volume::ReadAttrDir(Node* node, void* _cookie, struct dirent* buffer,
470	size_t bufferSize, int32 count, int32* countRead)
471{
472	return B_BAD_VALUE;
473}
474
475// RewindAttrDir
476status_t
477Volume::RewindAttrDir(Node* node, void* _cookie)
478{
479	return B_BAD_VALUE;
480}
481
482// ReadAttr
483status_t
484Volume::ReadAttr(Node* node, const char* name, int type, off_t pos,
485	void* _buffer, size_t bufferSize, size_t* _bytesRead)
486{
487	return B_BAD_VALUE;
488}
489
490// WriteAttr
491status_t
492Volume::WriteAttr(Node* node, const char* name, int type, off_t pos,
493	const void* _buffer, size_t bufferSize, size_t* bytesWritten)
494{
495	return B_BAD_VALUE;
496}
497
498// RemoveAttr
499status_t
500Volume::RemoveAttr(Node* node, const char* name)
501{
502	return B_BAD_VALUE;
503}
504
505// RenameAttr
506status_t
507Volume::RenameAttr(Node* node, const char* oldName, const char* newName)
508{
509	return B_BAD_VALUE;
510}
511
512// StatAttr
513status_t
514Volume::StatAttr(Node* node, const char* name, struct attr_info* attrInfo)
515{
516	return B_BAD_VALUE;
517}
518
519
520// #pragma mark -
521// #pragma mark ----- queries -----
522
523// OpenQuery
524status_t
525Volume::OpenQuery(const char* queryString, uint32 flags, port_id port,
526	int32 token, QueryIterator** iterator)
527{
528	return B_BAD_VALUE;
529}
530
531// FreeQueryIterator
532void
533Volume::FreeQueryIterator(QueryIterator* iterator)
534{
535}
536
537// ReadQuery
538status_t
539Volume::ReadQuery(QueryIterator* iterator, struct dirent* buffer,
540	size_t bufferSize, int32 count, int32* countRead)
541{
542	return B_BAD_VALUE;
543}
544
545