xref: /haiku/headers/private/storage/DiskSystemAddOn.h (revision 8a990d5228b2d1099e3062180532ba709dfeef6d)
1 /*
2  * Copyright 2007, Ingo Weinhold, bonefish@users.sf.net.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _DISK_SYSTEM_ADD_ON_H
6 #define _DISK_SYSTEM_ADD_ON_H
7 
8 #include <DiskDeviceDefs.h>
9 #include <String.h>
10 #include <SupportDefs.h>
11 
12 
13 class BPartitionParameterEditor;
14 class BList;
15 class BMutablePartition;
16 class BPartitionHandle;
17 class BPartitioningInfo;
18 
19 
20 class BDiskSystemAddOn {
21 public:
22 								BDiskSystemAddOn(const char* name,
23 									uint32 flags);
24 	virtual						~BDiskSystemAddOn();
25 
26 			const char*			Name() const;
27 			uint32				Flags() const;
28 
29 	virtual	status_t			CreatePartitionHandle(
30 									BMutablePartition* partition,
31 									BPartitionHandle** handle) = 0;
32 
33 	virtual	bool				CanInitialize(
34 									const BMutablePartition* partition);
35 	virtual	status_t			ValidateInitialize(
36 									const BMutablePartition* partition,
37 									BString* name, const char* parameters);
38 	virtual	status_t			Initialize(BMutablePartition* partition,
39 									const char* name, const char* parameters,
40 									BPartitionHandle** handle);
41 
42 	virtual	status_t			GetParameterEditor(
43 									B_PARAMETER_EDITOR_TYPE type,
44 									BPartitionParameterEditor** editor);
45 	virtual	status_t			GetTypeForContentType(const char* contentType,
46 									BString* type);
47 	virtual	bool				IsSubSystemFor(const BMutablePartition* child);
48 
49 private:
50 			BString				fName;
51 			uint32				fFlags;
52 };
53 
54 
55 class BPartitionHandle {
56 public:
57 								BPartitionHandle(BMutablePartition* partition);
58 	virtual						~BPartitionHandle();
59 
60 			BMutablePartition*	Partition() const;
61 
62 	virtual	uint32				SupportedOperations(uint32 mask);
63 	virtual	uint32				SupportedChildOperations(
64 									const BMutablePartition* child,
65 									uint32 mask);
66 
67 	virtual	bool				SupportsInitializingChild(
68 									const BMutablePartition* child,
69 									const char* diskSystem);
70 
71 	virtual	status_t			GetNextSupportedType(
72 									const BMutablePartition* child,
73 									int32* cookie, BString* type);
74 									// child can be NULL
75 
76 	virtual	status_t			GetPartitioningInfo(BPartitioningInfo* info);
77 
78 
79 	virtual	status_t			Defragment();
80 	virtual	status_t			Repair(bool checkOnly);
81 
82 	virtual	status_t			ValidateResize(off_t* size);
83 	virtual	status_t			ValidateResizeChild(
84 									const BMutablePartition* child,
85 									off_t* size);
86 	virtual	status_t			Resize(off_t size);
87 	virtual	status_t			ResizeChild(BMutablePartition* child,
88 									off_t size);
89 
90 	virtual	status_t			ValidateMove(off_t* offset);
91 	virtual	status_t			ValidateMoveChild(
92 									const BMutablePartition* child,
93 									off_t* offset);
94 	virtual	status_t			Move(off_t offset);
95 	virtual	status_t			MoveChild(BMutablePartition* child,
96 									off_t offset);
97 
98 	virtual	status_t			ValidateSetContentName(BString* name);
99 	virtual	status_t			ValidateSetName(const BMutablePartition* child,
100 									BString* name);
101 	virtual	status_t			SetContentName(const char* name);
102 	virtual	status_t			SetName(BMutablePartition* child,
103 									const char* name);
104 
105 	virtual	status_t			ValidateSetType(const BMutablePartition* child,
106 									const char* type);
107 	virtual	status_t			SetType(BMutablePartition* child,
108 									const char* type);
109 
110 	virtual	status_t			GetContentParameterEditor(
111 									BPartitionParameterEditor** editor);
112 
113 	virtual	status_t			ValidateSetContentParameters(
114 									const char* parameters);
115 	virtual	status_t			ValidateSetParameters(
116 									const BMutablePartition* child,
117 									const char* parameters);
118 	virtual	status_t			SetContentParameters(const char* parameters);
119 	virtual	status_t			SetParameters(BMutablePartition* child,
120 									const char* parameters);
121 
122 	virtual	status_t			GetParameterEditor(
123 									B_PARAMETER_EDITOR_TYPE type,
124 									BPartitionParameterEditor** editor);
125 	virtual	status_t			ValidateCreateChild(off_t* offset,
126 									off_t* size, const char* type,
127 									BString* name, const char* parameters);
128 	virtual	status_t			CreateChild(off_t offset, off_t size,
129 									const char* type, const char* name,
130 									const char* parameters,
131 									BMutablePartition** child);
132 
133 	virtual	status_t			DeleteChild(BMutablePartition* child);
134 
135 private:
136 			BMutablePartition*	fPartition;
137 };
138 
139 
140 extern "C" status_t get_disk_system_add_ons(BList* addOns);
141 	// Implemented in the add-on
142 
143 #endif	// _DISK_SYSTEM_ADD_ON_H
144