xref: /haiku/headers/private/kernel/disk_device_manager/ddm_modules.h (revision 51978af14a173e7fae0563b562be5603bc652aeb)
1 // ddm_modules.h
2 //
3 // Interfaces to be implemented by partition/FS modules.
4 
5 #ifndef _K_DISK_DEVICE_MODULES_H
6 #define _K_DISK_DEVICE_MODULES_H
7 
8 #include <disk_device_manager.h>
9 #include <module.h>
10 #include <SupportDefs.h>
11 
12 // partition module interface
13 
14 // scanning
15 // (the device is write locked)
16 typedef float (*partition_identify_partition)(int fd,
17 	partition_data *partition, void **cookie);
18 typedef status_t (*partition_scan_partition)(int fd,
19 	partition_data *partition, void *identifyCookie);
20 typedef void (*partition_free_identify_partition_cookie)(
21 	partition_data *partition, void *cookie);
22 typedef void (*partition_free_partition_cookie)(partition_data *partition);
23 typedef void (*partition_free_partition_content_cookie)(
24 	partition_data *partition);
25 
26 // querying
27 // (the device is read locked)
28 typedef bool (*partition_supports_repairing)(partition_data *partition,
29 	bool checkOnly);
30 typedef bool (*partition_supports_resizing)(partition_data *partition);
31 typedef bool (*partition_supports_resizing_child)(partition_data *partition,
32 	partition_data *child);
33 typedef bool (*partition_supports_moving)(partition_data *partition,
34 	bool *isNoOp);
35 typedef bool (*partition_supports_moving_child)(partition_data *partition,
36 	partition_data *child);
37 typedef bool (*partition_supports_setting_name)(partition_data *partition);
38 typedef bool (*partition_supports_setting_content_name)(
39 	partition_data *partition);
40 typedef bool (*partition_supports_setting_type)(partition_data *partition);
41 typedef bool (*partition_supports_setting_parameters)(
42 	partition_data *partition);
43 typedef bool (*partition_supports_setting_content_parameters)(
44 	partition_data *partition);
45 typedef bool (*partition_supports_initializing)(partition_data *partition);
46 typedef bool (*partition_supports_initializing_child)(
47 	partition_data *partition, const char *system);
48 typedef bool (*partition_supports_creating_child)(partition_data *partition);
49 typedef bool (*partition_supports_deleting_child)(partition_data *partition,
50 	partition_data *child);
51 typedef bool (*partition_is_sub_system_for)(partition_data *partition);
52 
53 typedef bool (*partition_validate_resize)(partition_data *partition,
54 	off_t *size);
55 typedef bool (*partition_validate_resize_child)(partition_data *partition,
56 	partition_data *child, off_t *size);
57 typedef bool (*partition_validate_move)(partition_data *partition,
58 	off_t *start);
59 typedef bool (*partition_validate_move_child)(partition_data *partition,
60 	partition_data *child, off_t *start);
61 typedef bool (*partition_validate_set_name)(partition_data *partition,
62 											char *name);
63 typedef bool (*partition_validate_set_content_name)(partition_data *partition,
64 													char *name);
65 typedef bool (*partition_validate_set_type)(partition_data *partition,
66 											const char *type);
67 typedef bool (*partition_validate_set_parameters)(partition_data *partition,
68 	const char *parameters);
69 typedef bool (*partition_validate_set_content_parameters)(
70 	partition_data *partition, const char *parameters);
71 typedef bool (*partition_validate_initialize)(partition_data *partition,
72 	char *name, const char *parameters);
73 typedef bool (*partition_validate_create_child)(partition_data *partition,
74 	off_t *start, off_t *size, const char *type, const char *parameters,
75 	int32 *index);
76 typedef status_t (*partition_get_partitionable_spaces)(
77 	partition_data *partition, partitionable_space_data *buffer, int32 count,
78 	int32 *actualCount);
79 	// When not implemented, a standard algorithm is used.
80 
81 typedef status_t (*partition_get_next_supported_type)(
82 	partition_data *partition, int32 *cookie, char *type);
83 typedef status_t (*partition_get_type_for_content_type)(
84 	const char *contentType, char *type);
85 
86 // shadow partition modification
87 // (device is write locked)
88 typedef status_t (*partition_shadow_changed)(partition_data *partition,
89 	uint32 operation);
90 
91 // writing
92 // (device is NOT locked)
93 typedef status_t (*partition_repair)(int fd, partition_id partition,
94 	bool checkOnly, disk_job_id job);
95 typedef status_t (*partition_resize)(int fd, partition_id partition,
96 	off_t size, disk_job_id job);
97 typedef status_t (*partition_resize_child)(int fd, partition_id partition,
98 	off_t size, disk_job_id job);
99 typedef status_t (*partition_move)(int fd, partition_id partition,
100 	off_t offset, disk_job_id job);
101 typedef status_t (*partition_move_child)(int fd, partition_id partition,
102 	partition_id child, off_t offset, disk_job_id job);
103 typedef status_t (*partition_set_name)(int fd, partition_id partition,
104 	const char *name, disk_job_id job);
105 typedef status_t (*partition_set_content_name)(int fd, partition_id partition,
106 	const char *name, disk_job_id job);
107 typedef status_t (*partition_set_type)(int fd, partition_id partition,
108 	const char *type, disk_job_id job);
109 typedef status_t (*partition_set_parameters)(int fd, partition_id partition,
110 	const char *parameters, disk_job_id job);
111 typedef status_t (*partition_set_content_parameters)(int fd,
112 	partition_id partition, const char *parameters, disk_job_id job);
113 typedef status_t (*partition_initialize)(int fd, partition_id partition,
114 	const char *name, const char *parameters, disk_job_id job);
115 typedef status_t (*partition_create_child)(int fd, partition_id partition,
116 	off_t offset, off_t size, const char *type, const char *parameters,
117 	disk_job_id job, partition_id *childID);
118 	// childID is used for the return value, but is also an optional input
119 	// parameter -- -1 to be ignored
120 typedef status_t (*partition_delete_child)(int fd, partition_id partition,
121 	partition_id child, disk_job_id job);
122 
123 typedef struct partition_module_info {
124 	module_info									module;
125 	const char									*pretty_name;
126 	uint32										flags;
127 
128 	// scanning
129 	partition_identify_partition				identify_partition;
130 	partition_scan_partition					scan_partition;
131 	partition_free_identify_partition_cookie	free_identify_partition_cookie;
132 	partition_free_partition_cookie				free_partition_cookie;
133 	partition_free_partition_content_cookie		free_partition_content_cookie;
134 
135 	// querying
136 	partition_supports_repairing				supports_repairing;
137 	partition_supports_resizing					supports_resizing;
138 	partition_supports_resizing_child			supports_resizing_child;
139 	partition_supports_moving					supports_moving;
140 	partition_supports_moving_child				supports_moving_child;
141 	partition_supports_setting_name				supports_setting_name;
142 	partition_supports_setting_content_name		supports_setting_content_name;
143 	partition_supports_setting_type				supports_setting_type;
144 	partition_supports_setting_parameters		supports_setting_parameters;
145 	partition_supports_setting_content_parameters
146 			supports_setting_content_parameters;
147 	partition_supports_initializing				supports_initializing;
148 	partition_supports_initializing_child		supports_initializing_child;
149 	partition_supports_creating_child			supports_creating_child;
150 	partition_supports_deleting_child			supports_deleting_child;
151 	partition_is_sub_system_for					is_sub_system_for;
152 
153 	partition_validate_resize					validate_resize;
154 	partition_validate_resize_child				validate_resize_child;
155 	partition_validate_move						validate_move;
156 	partition_validate_move_child				validate_move_child;
157 	partition_validate_set_name					validate_set_name;
158 	partition_validate_set_content_name			validate_set_content_name;
159 	partition_validate_set_type					validate_set_type;
160 	partition_validate_set_parameters			validate_set_parameters;
161 	partition_validate_set_content_parameters
162 			validate_set_content_parameters;
163 	partition_validate_initialize				validate_initialize;
164 	partition_validate_create_child				validate_create_child;
165 	partition_get_partitionable_spaces			get_partitionable_spaces;
166 	partition_get_next_supported_type			get_next_supported_type;
167 	partition_get_type_for_content_type			get_type_for_content_type;
168 
169 	// shadow partition modification
170 	partition_shadow_changed					shadow_changed;
171 
172 	// writing
173 	partition_repair							repair;
174 	partition_resize							resize;
175 	partition_resize_child						resize_child;
176 	partition_move								move;
177 	partition_move_child						move_child;
178 	partition_set_name							set_name;
179 	partition_set_content_name					set_content_name;
180 	partition_set_type							set_type;
181 	partition_set_parameters					set_parameters;
182 	partition_set_content_parameters			set_content_parameters;
183 	partition_initialize						initialize;
184 	partition_create_child						create_child;
185 	partition_delete_child						delete_child;
186 } partition_module_info;
187 
188 
189 // FS module interface
190 
191 // scanning
192 // (the device is write locked)
193 typedef float (*fs_identify_partition)(int fd, partition_data *partition,
194 	void **cookie);
195 typedef status_t (*fs_scan_partition)(int fd, partition_data *partition,
196 	void *cookie);
197 typedef void (*fs_free_identify_partition_cookie)(partition_data *partition,
198 	void *cookie);
199 typedef void (*fs_free_partition_content_cookie)(partition_data *partition);
200 
201 // querying
202 // (the device is read locked)
203 typedef bool (*fs_supports_defragmenting)(partition_data *partition,
204 	bool *whileMounted);
205 typedef bool (*fs_supports_repairing)(partition_data *partition,
206 	bool checkOnly, bool *whileMounted);
207 typedef bool (*fs_supports_resizing)(partition_data *partition,
208 	bool *whileMounted);
209 typedef bool (*fs_supports_moving)(partition_data *partition, bool *isNoOp);
210 typedef bool (*fs_supports_setting_content_name)(partition_data *partition,
211 	bool *whileMounted);
212 typedef bool (*fs_supports_setting_content_parameters)(
213 	partition_data *partition, bool *whileMounted);
214 typedef bool (*fs_supports_initializing)(partition_data *partition);
215 
216 typedef bool (*fs_validate_resize)(partition_data *partition, off_t *size);
217 typedef bool (*fs_validate_move)(partition_data *partition, off_t *start);
218 typedef bool (*fs_validate_set_content_name)(partition_data *partition,
219 	char *name);
220 typedef bool (*fs_validate_set_content_parameters)(partition_data *partition,
221 	const char *parameters);
222 typedef bool (*fs_validate_initialize)(partition_data *partition, char *name,
223 	const char *parameters);
224 
225 // shadow partition modification
226 // (device is write locked)
227 typedef status_t (*fs_shadow_changed)(partition_data *partition,
228 	uint32 operation);
229 
230 // writing
231 // (the device is NOT locked)
232 typedef status_t (*fs_defragment)(int fd, partition_id partition,
233 	disk_job_id job);
234 typedef status_t (*fs_repair)(int fd, partition_id partition, bool checkOnly,
235 	disk_job_id job);
236 typedef status_t (*fs_resize)(int fd, partition_id partition, off_t size,
237 	disk_job_id job);
238 typedef status_t (*fs_move)(int fd, partition_id partition, off_t offset,
239 	disk_job_id job);
240 typedef status_t (*fs_set_content_name)(int fd, partition_id partition,
241 	const char *name, disk_job_id job);
242 typedef status_t (*fs_set_content_parameters)(int fd, partition_id partition,
243 	const char *parameters, disk_job_id job);
244 typedef status_t (*fs_initialize)(const char *partition, const char *name,
245 	const char *parameters, disk_job_id job);
246 	// This is pretty close to how the hook in R5 looked. Save the job ID, of
247 	// course and that the parameters were given as (void*, size_t) pair.
248 
249 typedef struct fs_module_info {
250 	module_info									module;
251 	const char									*pretty_name;
252 	uint32										flags;
253 
254 	// scanning
255 	fs_identify_partition						identify_partition;
256 	fs_scan_partition							scan_partition;
257 	fs_free_identify_partition_cookie			free_identify_partition_cookie;
258 	fs_free_partition_content_cookie			free_partition_content_cookie;
259 
260 	// querying
261 	fs_supports_defragmenting					supports_defragmenting;
262 	fs_supports_repairing						supports_repairing;
263 	fs_supports_resizing						supports_resizing;
264 	fs_supports_moving							supports_moving;
265 	fs_supports_setting_content_name			supports_setting_content_name;
266 	fs_supports_setting_content_parameters
267 			supports_setting_content_parameters;
268 	fs_supports_initializing					supports_initializing;
269 
270 	fs_validate_resize							validate_resize;
271 	fs_validate_move							validate_move;
272 	fs_validate_set_content_name				validate_set_content_name;
273 	fs_validate_set_content_parameters
274 			validate_set_content_parameters;
275 	fs_validate_initialize						validate_initialize;
276 
277 	// shadow partition modification
278 	fs_shadow_changed							shadow_changed;
279 
280 	// writing
281 	fs_defragment								defragment;
282 	fs_repair									repair;
283 	fs_resize									resize;
284 	fs_move										move;
285 	fs_set_content_name							set_content_name;
286 	fs_set_content_parameters					set_content_parameters;
287 	fs_initialize								initialize;
288 } fs_module_info;
289 
290 #endif	// _K_DISK_DEVICE_MODULES_H
291