xref: /haiku/headers/private/kernel/disk_device_manager/ddm_userland_interface.h (revision 95bac3fda53a4cb21880712d7b43f8c21db32a2e)
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 <OS.h>
7 
8 #include <storage/DiskDeviceDefs.h>
9 
10 #include <disk_device_manager/disk_device_manager.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 // userland partition representation
17 typedef struct user_partition_data user_partition_data;
18 struct user_partition_data {
19 	partition_id		id;
20 	partition_id		shadow_id;
21 	off_t				offset;
22 	off_t				size;
23 	off_t				content_size;
24 	uint32				block_size;
25 	uint32				status;
26 	uint32				flags;
27 	dev_t				volume;
28 	int32				index;
29 	int32				change_counter;	// needed?
30 	disk_system_id		disk_system;
31 	char				*name;
32 	char				*content_name;
33 	char				*type;
34 	char				*content_type;
35 	char				*parameters;
36 	char				*content_parameters;
37 	void				*user_data;
38 	int32				child_count;
39 	user_partition_data	*children[1];
40 };
41 
42 // userland disk device representation
43 typedef struct user_disk_device_data {
44 	uint32				device_flags;
45 	char				*path;
46 	user_partition_data	device_partition_data;
47 } user_disk_device_data;
48 
49 // userland partitionable space representation
50 typedef struct user_disk_system_info {
51 	disk_system_id	id;
52 	char			name[B_FILE_NAME_LENGTH];	// better B_PATH_NAME_LENGTH?
53 	char			pretty_name[B_OS_NAME_LENGTH];
54 	uint32			flags;
55 } user_disk_system_info;
56 
57 // userland disk device job representation
58 typedef struct user_disk_device_job_info {
59 	disk_job_id		id;
60 	uint32			type;
61 	partition_id	partition;
62 	char			description[256];
63 } user_disk_device_job_info;
64 
65 
66 /*! Syscalls entries */
67 
68 // iterating, retrieving device/partition data
69 partition_id _user_get_next_disk_device_id(int32 *cookie, size_t *neededSize);
70 partition_id _user_find_disk_device(const char *filename, size_t *neededSize);
71 partition_id _user_find_partition(const char *filename, size_t *neededSize);
72 status_t _user_get_disk_device_data(partition_id deviceID, bool deviceOnly,
73 									bool shadow, user_disk_device_data *buffer,
74 									size_t bufferSize, size_t *neededSize);
75 
76 partition_id _user_register_file_device(const char *filename);
77 status_t _user_unregister_file_device(partition_id deviceID,
78 									  const char *filename);
79 	// Only a valid deviceID or filename need to be passed. The other one
80 	// is -1/NULL. If both is given only filename is ignored.
81 
82 // disk systems
83 status_t _user_get_disk_system_info(disk_system_id id,
84 									user_disk_system_info *info);
85 status_t _user_get_next_disk_system_info(int32 *cookie,
86 										 user_disk_system_info *info);
87 status_t _user_find_disk_system(const char *name, user_disk_system_info *info);
88 
89 bool _user_supports_defragmenting_partition(partition_id partitionID,
90 											int32 changeCounter,
91 											bool *whileMounted);
92 bool _user_supports_repairing_partition(partition_id partitionID,
93 										int32 changeCounter, bool checkOnly,
94 										bool *whileMounted);
95 bool _user_supports_resizing_partition(partition_id partitionID,
96 									   int32 changeCounter,
97 									   bool *canResizeContents,
98 									   bool *whileMounted);
99 bool _user_supports_moving_partition(partition_id partitionID,
100 									 int32 changeCounter,
101 									 partition_id *unmovable,
102 									 partition_id *needUnmounting,
103 									 size_t bufferSize);
104 bool _user_supports_setting_partition_name(partition_id partitionID,
105 										   int32 changeCounter);
106 bool _user_supports_setting_partition_content_name(partition_id partitionID,
107 												   int32 changeCounter,
108 												   bool *whileMounted);
109 bool _user_supports_setting_partition_type(partition_id partitionID,
110 										   int32 changeCounter);
111 bool _user_supports_setting_partition_parameters(partition_id partitionID,
112 												 int32 changeCounter);
113 bool _user_supports_setting_partition_content_parameters(
114 	partition_id partitionID, int32 changeCounter, bool *whileMounted);
115 bool _user_supports_initializing_partition(partition_id partitionID,
116 										   int32 changeCounter,
117 										   const char *diskSystemName);
118 bool _user_supports_creating_child_partition(partition_id partitionID,
119 											 int32 changeCounter);
120 bool _user_supports_deleting_child_partition(partition_id partitionID,
121 											 int32 changeCounter);
122 bool _user_is_sub_disk_system_for(disk_system_id diskSystemID,
123 								  partition_id partitionID,
124 								  int32 changeCounter);
125 
126 status_t _user_validate_resize_partition(partition_id partitionID,
127 										 int32 changeCounter, off_t *size);
128 status_t _user_validate_move_partition(partition_id partitionID,
129 									   int32 changeCounter, off_t *newOffset);
130 status_t _user_validate_set_partition_name(partition_id partitionID,
131 										   int32 changeCounter, char *name);
132 status_t _user_validate_set_partition_content_name(partition_id partitionID,
133 												   int32 changeCounter,
134 												   char *name);
135 status_t _user_validate_set_partition_type(partition_id partitionID,
136 										   int32 changeCounter,
137 										   const char *type);
138 status_t _user_validate_initialize_partition(partition_id partitionID,
139 											 int32 changeCounter,
140 											 const char *diskSystemName,
141 											 char *name,
142 											 const char *parameters,
143 											 size_t parametersSize);
144 status_t _user_validate_create_child_partition(partition_id partitionID,
145 											   int32 changeCounter,
146 											   off_t *offset, off_t *size,
147 											   const char *type,
148 											   const char *parameters,
149 											   size_t parametersSize);
150 status_t _user_get_partitionable_spaces(partition_id partitionID,
151 										int32 changeCounter,
152 										partitionable_space_data *buffer,
153 										int32 count, int32 *actualCount);
154 status_t _user_get_next_supported_partition_type(partition_id partitionID,
155 												 int32 changeCounter,
156 												 int32 *cookie, char *type);
157 status_t _user_get_partition_type_for_content_type(disk_system_id diskSystemID,
158 												   const char *contentType,
159 												   char *type);
160 
161 // disk device modification
162 status_t _user_prepare_disk_device_modifications(partition_id deviceID);
163 status_t _user_commit_disk_device_modifications(partition_id deviceID,
164 												port_id port, int32 token,
165 												bool completeProgress);
166 status_t _user_cancel_disk_device_modifications(partition_id deviceID);
167 bool _user_is_disk_device_modified(partition_id deviceID);
168 
169 status_t _user_defragment_partition(partition_id partitionID,
170 									int32 changeCounter);
171 status_t _user_repair_partition(partition_id partitionID, int32 changeCounter,
172 								bool checkOnly);
173 status_t _user_resize_partition(partition_id partitionID, int32 changeCounter,
174 								off_t size);
175 status_t _user_move_partition(partition_id partitionID, int32 changeCounter,
176 							  off_t newOffset);
177 status_t _user_set_partition_name(partition_id partitionID,
178 								  int32 changeCounter, const char *name);
179 status_t _user_set_partition_content_name(partition_id partitionID,
180 										  int32 changeCounter,
181 										  const char *name);
182 status_t _user_set_partition_type(partition_id partitionID,
183 								  int32 changeCounter, const char *type);
184 status_t _user_set_partition_parameters(partition_id partitionID,
185 										int32 changeCounter,
186 										const char *parameters,
187 										size_t parametersSize);
188 status_t _user_set_partition_content_parameters(partition_id partitionID,
189 												int32 changeCounter,
190 												const char *parameters,
191 												size_t parametersSize);
192 status_t _user_initialize_partition(partition_id partitionID,
193 									int32 changeCounter,
194 									const char *diskSystemName,
195 									const char *name, const char *parameters,
196 									size_t parametersSize);
197 status_t _user_uninitialize_partition(partition_id partitionID,
198 									  int32 changeCounter);
199 status_t _user_create_child_partition(partition_id partitionID,
200 									  int32 changeCounter, off_t offset,
201 									  off_t size, const char *type,
202 									  const char *parameters,
203 									  size_t parametersSize,
204 									  partition_id *childID);
205 status_t _user_delete_partition(partition_id partitionID, int32 changeCounter);
206 
207 // jobs
208 status_t _user_get_next_disk_device_job_info(int32 *cookie,
209 											 user_disk_device_job_info *info);
210 status_t _user_get_disk_device_job_info(disk_job_id id,
211 										user_disk_device_job_info *info);
212 status_t _user_get_disk_device_job_progress_info(disk_job_id id,
213 	disk_device_job_progress_info *info);
214 status_t _user_pause_disk_device_job(disk_job_id id);
215 status_t _user_cancel_disk_device_job(disk_job_id id, bool reverse);
216 
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 #endif	// _DISK_DEVICE_MANAGER_USERLAND_INTERFACE_H
222