xref: /haiku/headers/private/kernel/disk_device_manager/ddm_modules.h (revision 0b2dbe7d46ee888392907c60131b7f7652314175)
1 // ddm_modules.h
2 //
3 // Interface to be implemented by partition 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 #endif	// _K_DISK_DEVICE_MODULES_H
189