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