xref: /haiku/src/add-ons/kernel/file_systems/udf/Volume.h (revision 5d9e40fe9252c8f9c5e5e41594545bfa4419fcc7)
1 //----------------------------------------------------------------------
2 //  This software is part of the OpenBeOS distribution and is covered
3 //  by the OpenBeOS license.
4 //
5 //  Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net
6 //  Mad props to Axel Dörfler and his BFS implementation, from which
7 //  this UDF implementation draws much influence (and a little code :-P).
8 //---------------------------------------------------------------------
9 #ifndef _UDF_VOLUME_H
10 #define _UDF_VOLUME_H
11 
12 /*! \file Volume.h
13 */
14 
15 #include <KernelExport.h>
16 extern "C" {
17 	#ifndef _IMPEXP_KERNEL
18 	#	define _IMPEXP_KERNEL
19 	#endif
20 
21 	#include <fsproto.h>
22 }
23 
24 #include "kernel_cpp.h"
25 #include "UdfDebug.h"
26 
27 #include "UdfString.h"
28 #include "UdfStructures.h"
29 #include "Partition.h"
30 
31 namespace Udf {
32 
33 class Icb;
34 
35 class Volume {
36 public:
37 	// Construction/destruction
38 	Volume(nspace_id id);
39 	~Volume();
40 
41 	// Mounting/unmounting
42 	status_t Mount(const char *deviceName, off_t offset, off_t length,
43                    uint32 blockSize, uint32 flags);
44 	status_t Unmount();
45 
46 	// Address mapping
47 	status_t MapBlock(long_address address, off_t *mappedBlock);
48 	status_t MapExtent(long_address logicalExtent, extent_address &physicalExtent);
49 
50 	// Miscellaneous info
51 	const char *Name() const;
52 	int Device() const { return fDevice; }
53 	nspace_id Id() const { return fId; }
54 	off_t Offset() const { return fOffset; }
55 	off_t Length() const { return fLength; }
56 	uint32 BlockSize() const { return fBlockSize; }
57 	uint32 BlockShift() const { return fBlockShift; }
58 	bool Mounted() const { return fMounted; }
59 	Icb* RootIcb() { return fRootIcb; }
60 
61 private:
62 	Volume();						// unimplemented
63 	Volume(const Volume &ref);		// unimplemented
64 	Volume& operator=(const Volume &ref);	// unimplemented
65 
66 	void _Unset();
67 
68 	status_t _SetPartition(uint number, Partition *partition);
69 	Partition* _GetPartition(uint number);
70 
71 private:
72 	nspace_id fId;
73 	int fDevice;
74 	bool fMounted;
75 	off_t fOffset;
76 	off_t fLength;
77 	uint32 fBlockSize;
78 	uint32 fBlockShift;
79 	Partition *fPartitions[UDF_MAX_PARTITION_MAPS];
80 	Icb *fRootIcb;	// Destroyed by vfs via callback to release_node()
81 	String fName;
82 };
83 
84 };	// namespace Udf
85 
86 #endif	// _UDF_VOLUME_H
87