1 /* 2 * Copyright 2003-2006, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _DISK_DEVICE_MANAGER_H 6 #define _DISK_DEVICE_MANAGER_H 7 8 9 #include <DiskDeviceDefs.h> 10 #include <Drivers.h> 11 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 /** \brief C API partition representation 18 * 19 * Fields marked [sys] are set by the system and are not to be changed by 20 * the disk system modules. 21 */ 22 typedef struct partition_data { 23 partition_id id; // [sys] 24 off_t offset; 25 off_t size; 26 off_t content_size; 27 uint32 block_size; 28 int32 child_count; 29 int32 index; // [sys] 30 uint32 status; 31 uint32 flags; 32 dev_t volume; // [sys] 33 void *mount_cookie; // [sys] 34 char *name; // max: B_OS_NAME_LENGTH 35 char *content_name; // 36 char *type; // 37 const char *content_type; // [sys] 38 char *parameters; 39 char *content_parameters; 40 void *cookie; 41 void *content_cookie; 42 } partition_data; 43 44 // C API disk device representation 45 typedef struct disk_device_data { 46 partition_id id; // equal to that of the root partition 47 uint32 flags; 48 char *path; 49 device_geometry geometry; 50 } disk_device_data; 51 52 // C API partitionable space representation 53 typedef struct partitionable_space_data { 54 off_t offset; 55 off_t size; 56 } partitionable_space_data; 57 58 // operations on partitions 59 enum { 60 B_PARTITION_SHADOW, // indicates creation of a shadow partition 61 B_PARTITION_SHADOW_CHILD, // 62 B_PARTITION_DEFRAGMENT, 63 B_PARTITION_REPAIR, 64 B_PARTITION_RESIZE, 65 B_PARTITION_RESIZE_CHILD, 66 B_PARTITION_MOVE, 67 B_PARTITION_MOVE_CHILD, 68 B_PARTITION_SET_NAME, 69 B_PARTITION_SET_CONTENT_NAME, 70 B_PARTITION_SET_TYPE, 71 B_PARTITION_SET_PARAMETERS, 72 B_PARTITION_SET_CONTENT_PARAMETERS, 73 B_PARTITION_INITIALIZE, 74 B_PARTITION_CREATE_CHILD, 75 B_PARTITION_DELETE_CHILD, 76 }; 77 78 // disk device job cancel status 79 enum { 80 B_DISK_DEVICE_JOB_CONTINUE, 81 B_DISK_DEVICE_JOB_CANCEL, 82 B_DISK_DEVICE_JOB_REVERSE, 83 }; 84 85 // disk device locking 86 disk_device_data *write_lock_disk_device(partition_id partitionID); 87 void write_unlock_disk_device(partition_id partitionID); 88 disk_device_data *read_lock_disk_device(partition_id partitionID); 89 void read_unlock_disk_device(partition_id partitionID); 90 // parameter is the ID of any partition on the device 91 92 // getting disk devices/partitions by path 93 // (no locking required) 94 int32 find_disk_device(const char *path); 95 int32 find_partition(const char *path); 96 97 // disk device/partition read access 98 // (read lock required) 99 disk_device_data *get_disk_device(partition_id partitionID); 100 partition_data *get_partition(partition_id partitionID); 101 partition_data *get_parent_partition(partition_id partitionID); 102 partition_data *get_child_partition(partition_id partitionID, int32 index); 103 104 int open_partition(partition_id partitionID, int openMode); 105 106 // partition write access 107 // (write lock required) 108 partition_data *create_child_partition(partition_id partitionID, int32 index, 109 off_t offset, off_t size, partition_id childID); 110 // childID is an optional input parameter -- -1 to be ignored 111 bool delete_partition(partition_id partitionID); 112 void partition_modified(partition_id partitionID); 113 // tells the disk device manager, that the partition has been modified 114 115 status_t scan_partition(partition_id partitionID); 116 // Service method for disks systems: Synchronously scans the partition. 117 // Device must not be locked. 118 119 // partition support functions 120 // (no lock required) 121 status_t get_default_partition_content_name(partition_id partitionID, 122 const char* fileSystemName, char* buffer, size_t bufferSize); 123 // The partition_data::content_size field must already be initialized. 124 125 // disk systems 126 disk_system_id find_disk_system(const char *name); 127 128 // jobs 129 bool update_disk_device_job_progress(disk_job_id jobID, float progress); 130 bool update_disk_device_job_extra_progress(disk_job_id jobID, const char *info); 131 bool set_disk_device_job_error_message(disk_job_id jobID, const char *message); 132 uint32 update_disk_device_job_interrupt_properties(disk_job_id jobID, 133 uint32 interruptProperties); 134 // returns one of B_DISK_DEVICE_JOB_{CONTINUE,CANCEL,REVERSE} 135 136 #ifdef __cplusplus 137 } 138 #endif 139 140 #endif // _DISK_DEVICE_MANAGER_H 141