xref: /haiku/headers/private/kernel/disk_device_manager/ddm_userland_interface.h (revision 5d9e40fe9252c8f9c5e5e41594545bfa4419fcc7)
1 // ddm_userland_interface.h
2 
3 #ifndef _DISK_DEVICE_MANAGER_USERLAND_INTERFACE_H
4 #define _DISK_DEVICE_MANAGER_USERLAND_INTERFACE_H
5 
6 #include <DiskDeviceDefs.h>
7 #include <disk_device_manager.h>
8 #include <OS.h>
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 // userland partition representation
15 struct user_partition_data {
16 	partition_id		id;
17 	partition_id		shadow_id;
18 	off_t				offset;
19 	off_t				size;
20 	off_t				content_size;
21 	uint32				block_size;
22 	uint32				status;
23 	uint32				flags;
24 	dev_t				volume;
25 	int32				index;
26 	int32				change_counter;	// needed?
27 	disk_system_id		disk_system;
28 	char				*name;
29 	char				*content_name;
30 	char				*type;
31 	char				*content_type;
32 	char				*parameters;
33 	char				*content_parameters;
34 	void				*user_data;
35 	int32				child_count;
36 	user_partition_data	*children[1];
37 };
38 
39 // userland disk device representation
40 struct user_disk_device_data {
41 	uint32				device_flags;
42 	char				*path;
43 	user_partition_data	device_partition_data;
44 };
45 
46 // userland partitionable space representation
47 struct user_disk_system_info {
48 	disk_system_id	id;
49 	char			name[B_FILE_NAME_LENGTH];	// better B_PATH_NAME_LENGTH?
50 	char			pretty_name[B_OS_NAME_LENGTH];
51 	uint32			flags;
52 };
53 
54 // userland disk device job representation
55 struct user_disk_device_job_info {
56 	disk_job_id		id;
57 	uint32			type;
58 	partition_id	partition;
59 	char			description[256];
60 };
61 
62 // iterating, retrieving device/partition data
63 partition_id _kern_get_next_disk_device_id(int32 *cookie,
64 										   size_t *neededSize = NULL);
65 partition_id _kern_find_disk_device(const char *filename,
66 									size_t *neededSize = NULL);
67 partition_id _kern_find_partition(const char *filename,
68 								  size_t *neededSize = NULL);
69 status_t _kern_get_disk_device_data(partition_id deviceID, bool deviceOnly,
70 									bool shadow, user_disk_device_data *buffer,
71 									size_t bufferSize, size_t *neededSize);
72 status_t _kern_get_partition_data(partition_id partitionID, bool shadow,
73 								  user_partition_data *buffer,
74 								  size_t bufferSize, size_t *neededSize);
75 	// Dangerous?!
76 
77 partition_id _kern_register_file_device(const char *filename);
78 status_t _kern_unregister_file_device(partition_id deviceID,
79 									  const char *filename);
80 	// Only a valid deviceID or filename need to be passed. The other one
81 	// is -1/NULL. If both is given only filename is ignored.
82 
83 // disk systems
84 status_t _kern_get_disk_system_info(disk_system_id id,
85 									user_disk_system_info *info);
86 status_t _kern_get_next_disk_system_info(int32 *cookie,
87 										 user_disk_system_info *info);
88 status_t _kern_find_disk_system(const char *name, user_disk_system_info *info);
89 
90 bool _kern_supports_defragmenting_partition(partition_id partitionID,
91 											int32 changeCounter,
92 											bool *whileMounted);
93 bool _kern_supports_repairing_partition(partition_id partitionID,
94 										int32 changeCounter, bool checkOnly,
95 										bool *whileMounted);
96 bool _kern_supports_resizing_partition(partition_id partitionID,
97 									   int32 changeCounter,
98 									   bool *canResizeContents,
99 									   bool *whileMounted);
100 bool _kern_supports_moving_partition(partition_id partitionID,
101 									 int32 changeCounter,
102 									 partition_id *unmovable,
103 									 partition_id *needUnmounting,
104 									 size_t bufferSize);
105 bool _kern_supports_setting_partition_name(partition_id partitionID,
106 										   int32 changeCounter);
107 bool _kern_supports_setting_partition_content_name(partition_id partitionID,
108 												   int32 changeCounter,
109 												   bool *whileMounted);
110 bool _kern_supports_setting_partition_type(partition_id partitionID,
111 										   int32 changeCounter);
112 bool _kern_supports_setting_partition_parameters(partition_id partitionID,
113 												 int32 changeCounter);
114 bool _kern_supports_setting_partition_content_parameters(
115 	partition_id partitionID, int32 changeCounter, bool *whileMounted);
116 bool _kern_supports_initializing_partition(partition_id partitionID,
117 										   int32 changeCounter,
118 										   const char *diskSystemName);
119 bool _kern_supports_creating_child_partition(partition_id partitionID,
120 											 int32 changeCounter);
121 bool _kern_supports_deleting_child_partition(partition_id partitionID,
122 											 int32 changeCounter);
123 bool _kern_is_sub_disk_system_for(disk_system_id diskSystemID,
124 								  partition_id partitionID,
125 								  int32 changeCounter);
126 
127 status_t _kern_validate_resize_partition(partition_id partitionID,
128 										 int32 changeCounter, off_t *size);
129 status_t _kern_validate_move_partition(partition_id partitionID,
130 									   int32 changeCounter, off_t *newOffset);
131 status_t _kern_validate_set_partition_name(partition_id partitionID,
132 										   int32 changeCounter, char *name);
133 status_t _kern_validate_set_partition_content_name(partition_id partitionID,
134 												   int32 changeCounter,
135 												   char *name);
136 status_t _kern_validate_set_partition_type(partition_id partitionID,
137 										   int32 changeCounter,
138 										   const char *type);
139 status_t _kern_validate_initialize_partition(partition_id partitionID,
140 											 int32 changeCounter,
141 											 const char *diskSystemName,
142 											 char *name,
143 											 const char *parameters,
144 											 size_t parametersSize);
145 status_t _kern_validate_create_child_partition(partition_id partitionID,
146 											   int32 changeCounter,
147 											   off_t *offset, off_t *size,
148 											   const char *type,
149 											   const char *parameters,
150 											   size_t parametersSize);
151 status_t _kern_get_partitionable_spaces(partition_id partitionID,
152 										int32 changeCounter,
153 										partitionable_space_data *buffer,
154 										int32 count, int32 *actualCount);
155 status_t _kern_get_next_supported_partition_type(partition_id partitionID,
156 												 int32 changeCounter,
157 												 int32 *cookie, char *type);
158 status_t _kern_get_partition_type_for_content_type(disk_system_id diskSystemID,
159 												   const char *contentType,
160 												   char *type);
161 
162 // disk device modification
163 status_t _kern_prepare_disk_device_modifications(partition_id deviceID);
164 status_t _kern_commit_disk_device_modifications(partition_id deviceID,
165 												port_id port, int32 token,
166 												bool completeProgress);
167 status_t _kern_cancel_disk_device_modifications(partition_id deviceID);
168 bool _kern_is_disk_device_modified(partition_id deviceID);
169 
170 status_t _kern_defragment_partition(partition_id partitionID,
171 									int32 changeCounter);
172 status_t _kern_repair_partition(partition_id partitionID, int32 changeCounter,
173 								bool checkOnly);
174 status_t _kern_resize_partition(partition_id partitionID, int32 changeCounter,
175 								off_t size);
176 status_t _kern_move_partition(partition_id partitionID, int32 changeCounter,
177 							  off_t newOffset);
178 status_t _kern_set_partition_name(partition_id partitionID,
179 								  int32 changeCounter, const char *name);
180 status_t _kern_set_partition_content_name(partition_id partitionID,
181 										  int32 changeCounter,
182 										  const char *name);
183 status_t _kern_set_partition_type(partition_id partitionID,
184 								  int32 changeCounter, const char *type);
185 status_t _kern_set_partition_parameters(partition_id partitionID,
186 										int32 changeCounter,
187 										const char *parameters,
188 										size_t parametersSize);
189 status_t _kern_set_partition_content_parameters(partition_id partitionID,
190 												int32 changeCounter,
191 												const char *parameters,
192 												size_t parametersSize);
193 status_t _kern_initialize_partition(partition_id partitionID,
194 									int32 changeCounter,
195 									const char *diskSystemName,
196 									const char *name, const char *parameters,
197 									size_t parametersSize);
198 status_t _kern_uninitialize_partition(partition_id partitionID,
199 									  int32 changeCounter);
200 status_t _kern_create_child_partition(partition_id partitionID,
201 									  int32 changeCounter, off_t offset,
202 									  off_t size, const char *type,
203 									  const char *parameters,
204 									  size_t parametersSize,
205 									  partition_id *childID);
206 status_t _kern_delete_partition(partition_id partitionID, int32 changeCounter);
207 
208 // jobs
209 status_t _kern_get_next_disk_device_job_info(int32 *cookie,
210 											 user_disk_device_job_info *info);
211 status_t _kern_get_disk_device_job_info(disk_job_id id,
212 										user_disk_device_job_info *info);
213 status_t _kern_get_disk_device_job_progress_info(disk_job_id id,
214 	disk_device_job_progress_info *info);
215 status_t _kern_pause_disk_device_job(disk_job_id id);
216 status_t _kern_cancel_disk_device_job(disk_job_id id, bool reverse);
217 
218 #if 0
219 
220 // watching
221 status_t start_disk_device_watching(port_id, int32 token, uint32 flags);
222 status_t start_disk_device_job_watching(disk_job_id job, port_id, int32 token,
223 										uint32 flags);
224 status_t stop_disk_device_watching(port_id, int32 token);
225 
226 #endif	// 0
227 
228 #ifdef __cplusplus
229 }
230 #endif
231 
232 #endif	// _DISK_DEVICE_MANAGER_USERLAND_INTERFACE_H
233