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 status_t _kern_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 status_t _kern_get_partitionable_spaces(partition_id partitionID, 150 int32 changeCounter, 151 partitionable_space_data *buffer, 152 int32 count, int32 *actualCount); 153 status_t _kern_get_next_supported_partition_type(partition_id partitionID, 154 int32 changeCounter, 155 int32 *cookie, char *type); 156 status_t _kern_get_partition_type_for_content_type(disk_system_id diskSystemID, 157 const char *contentType, 158 char *type); 159 160 // disk device modification 161 status_t _kern_prepare_disk_device_modifications(partition_id deviceID); 162 status_t _kern_commit_disk_device_modifications(partition_id deviceID, 163 port_id port, int32 token, 164 bool completeProgress); 165 status_t _kern_cancel_disk_device_modifications(partition_id deviceID); 166 bool _kern_is_disk_device_modified(partition_id deviceID); 167 168 status_t _kern_defragment_partition(partition_id partitionID, 169 int32 changeCounter); 170 status_t _kern_repair_partition(partition_id partitionID, int32 changeCounter, 171 bool checkOnly); 172 status_t _kern_resize_partition(partition_id partitionID, int32 changeCounter, 173 off_t size); 174 status_t _kern_move_partition(partition_id partitionID, int32 changeCounter, 175 off_t newOffset); 176 status_t _kern_set_partition_name(partition_id partitionID, 177 int32 changeCounter, const char *name); 178 status_t _kern_set_partition_content_name(partition_id partitionID, 179 int32 changeCounter, 180 const char *name); 181 status_t _kern_set_partition_type(partition_id partitionID, 182 int32 changeCounter, const char *type); 183 status_t _kern_set_partition_parameters(partition_id partitionID, 184 int32 changeCounter, 185 const char *parameters); 186 status_t _kern_set_partition_content_parameters(partition_id partitionID, 187 int32 changeCounter, 188 const char *parameters); 189 status_t _kern_initialize_partition(partition_id partitionID, 190 int32 changeCounter, 191 const char *diskSystemName, 192 const char *name, const char *parameters); 193 status_t _kern_uninitialize_partition(partition_id partitionID, 194 int32 changeCounter); 195 status_t _kern_create_child_partition(partition_id partitionID, 196 int32 changeCounter, off_t offset, 197 off_t size, const char *type, 198 const char *parameters, 199 partition_id *childID); 200 status_t _kern_delete_partition(partition_id partitionID, int32 changeCounter); 201 202 // jobs 203 status_t _kern_get_next_disk_device_job_info(int32 *cookie, 204 user_disk_device_job_info *info); 205 status_t _kern_get_disk_device_job_info(disk_job_id id, 206 user_disk_device_job_info *info); 207 status_t _kern_get_disk_device_job_progress_info(disk_job_id id, 208 disk_device_job_progress_info *info); 209 status_t _kern_pause_disk_device_job(disk_job_id id); 210 status_t _kern_cancel_disk_device_job(disk_job_id id, bool reverse); 211 212 #if 0 213 214 // watching 215 status_t start_disk_device_watching(port_id, int32 token, uint32 flags); 216 status_t start_disk_device_job_watching(disk_job_id job, port_id, int32 token, 217 uint32 flags); 218 status_t stop_disk_device_watching(port_id, int32 token); 219 220 #endif // 0 221 222 #ifdef __cplusplus 223 } 224 #endif 225 226 #endif // _DISK_DEVICE_MANAGER_USERLAND_INTERFACE_H 227