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