1a38a92c9SIngo Weinhold /* 2a38a92c9SIngo Weinhold * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. 3a38a92c9SIngo Weinhold * Distributed under the terms of the MIT License. 4a38a92c9SIngo Weinhold */ 5a38a92c9SIngo Weinhold #ifndef _FSSH_DISK_DEVICE_MANAGER_H 6a38a92c9SIngo Weinhold #define _FSSH_DISK_DEVICE_MANAGER_H 7a38a92c9SIngo Weinhold 8a38a92c9SIngo Weinhold 9a38a92c9SIngo Weinhold #include "fssh_disk_device_defs.h" 10a38a92c9SIngo Weinhold #include "fssh_drivers.h" 11a38a92c9SIngo Weinhold 12a38a92c9SIngo Weinhold 13a38a92c9SIngo Weinhold #ifdef __cplusplus 14a38a92c9SIngo Weinhold extern "C" { 15a38a92c9SIngo Weinhold #endif 16a38a92c9SIngo Weinhold 17a38a92c9SIngo Weinhold // C API partition representation 18a38a92c9SIngo Weinhold // Fields marked [sys] are set by the system and are not to be changed by 19a38a92c9SIngo Weinhold // the disk system modules. 20a38a92c9SIngo Weinhold typedef struct fssh_partition_data { 21a38a92c9SIngo Weinhold fssh_partition_id id; // [sys] 22a38a92c9SIngo Weinhold fssh_off_t offset; 23a38a92c9SIngo Weinhold fssh_off_t size; 24a38a92c9SIngo Weinhold fssh_off_t content_size; 25a38a92c9SIngo Weinhold uint32_t block_size; 26a38a92c9SIngo Weinhold int32_t child_count; 27a38a92c9SIngo Weinhold int32_t index; // [sys] 28a38a92c9SIngo Weinhold uint32_t status; 29a38a92c9SIngo Weinhold uint32_t flags; 30a38a92c9SIngo Weinhold fssh_dev_t volume; // [sys] 31a38a92c9SIngo Weinhold void *mount_cookie; // [sys] 32a38a92c9SIngo Weinhold char *name; // max: B_OS_NAME_LENGTH 33a38a92c9SIngo Weinhold char *content_name; // 34a38a92c9SIngo Weinhold char *type; // 35a38a92c9SIngo Weinhold const char *content_type; // [sys] 36a38a92c9SIngo Weinhold char *parameters; 37a38a92c9SIngo Weinhold char *content_parameters; 38a38a92c9SIngo Weinhold void *cookie; 39a38a92c9SIngo Weinhold void *content_cookie; 40a38a92c9SIngo Weinhold } fssh_partition_data; 41a38a92c9SIngo Weinhold 42a38a92c9SIngo Weinhold // C API disk device representation 43a38a92c9SIngo Weinhold typedef struct fssh_disk_device_data { 44a38a92c9SIngo Weinhold fssh_partition_id id; // equal to that of the root partition 45a38a92c9SIngo Weinhold uint32_t flags; 46a38a92c9SIngo Weinhold char *path; 47a38a92c9SIngo Weinhold fssh_device_geometry geometry; 48a38a92c9SIngo Weinhold } fssh_disk_device_data; 49a38a92c9SIngo Weinhold 50a38a92c9SIngo Weinhold // C API partitionable space representation 51a38a92c9SIngo Weinhold typedef struct fssh_partitionable_space_data { 52a38a92c9SIngo Weinhold fssh_off_t offset; 53a38a92c9SIngo Weinhold fssh_off_t size; 54a38a92c9SIngo Weinhold } fssh_partitionable_space_data; 55a38a92c9SIngo Weinhold 56a38a92c9SIngo Weinhold // operations on partitions 57a38a92c9SIngo Weinhold enum { 58a38a92c9SIngo Weinhold FSSH_B_PARTITION_DEFRAGMENT, 59a38a92c9SIngo Weinhold FSSH_B_PARTITION_REPAIR, 60a38a92c9SIngo Weinhold FSSH_B_PARTITION_RESIZE, 61a38a92c9SIngo Weinhold FSSH_B_PARTITION_RESIZE_CHILD, 62a38a92c9SIngo Weinhold FSSH_B_PARTITION_MOVE, 63a38a92c9SIngo Weinhold FSSH_B_PARTITION_MOVE_CHILD, 64a38a92c9SIngo Weinhold FSSH_B_PARTITION_SET_NAME, 65a38a92c9SIngo Weinhold FSSH_B_PARTITION_SET_CONTENT_NAME, 66a38a92c9SIngo Weinhold FSSH_B_PARTITION_SET_TYPE, 67a38a92c9SIngo Weinhold FSSH_B_PARTITION_SET_PARAMETERS, 68a38a92c9SIngo Weinhold FSSH_B_PARTITION_SET_CONTENT_PARAMETERS, 69a38a92c9SIngo Weinhold FSSH_B_PARTITION_INITIALIZE, 70a38a92c9SIngo Weinhold FSSH_B_PARTITION_CREATE_CHILD, 71a38a92c9SIngo Weinhold FSSH_B_PARTITION_DELETE_CHILD, 72a38a92c9SIngo Weinhold }; 73a38a92c9SIngo Weinhold 74a38a92c9SIngo Weinhold // disk device job cancel status 75a38a92c9SIngo Weinhold enum { 76a38a92c9SIngo Weinhold FSSH_B_DISK_DEVICE_JOB_CONTINUE, 77a38a92c9SIngo Weinhold FSSH_B_DISK_DEVICE_JOB_CANCEL, 78a38a92c9SIngo Weinhold FSSH_B_DISK_DEVICE_JOB_REVERSE, 79a38a92c9SIngo Weinhold }; 80a38a92c9SIngo Weinhold 81a38a92c9SIngo Weinhold // disk device locking 82a38a92c9SIngo Weinhold fssh_disk_device_data* fssh_write_lock_disk_device( 83a38a92c9SIngo Weinhold fssh_partition_id partitionID); 84a38a92c9SIngo Weinhold void fssh_write_unlock_disk_device( 85a38a92c9SIngo Weinhold fssh_partition_id partitionID); 86a38a92c9SIngo Weinhold fssh_disk_device_data* fssh_read_lock_disk_device( 87a38a92c9SIngo Weinhold fssh_partition_id partitionID); 88a38a92c9SIngo Weinhold void fssh_read_unlock_disk_device( 89a38a92c9SIngo Weinhold fssh_partition_id partitionID); 90a38a92c9SIngo Weinhold // parameter is the ID of any partition on the device 91a38a92c9SIngo Weinhold 92a38a92c9SIngo Weinhold // getting disk devices/partitions by path 93a38a92c9SIngo Weinhold // (no locking required) 94a38a92c9SIngo Weinhold int32_t fssh_find_disk_device(const char *path); 95a38a92c9SIngo Weinhold int32_t fssh_find_partition(const char *path); 96a38a92c9SIngo Weinhold 97a38a92c9SIngo Weinhold // disk device/partition read access 98a38a92c9SIngo Weinhold // (read lock required) 99a38a92c9SIngo Weinhold fssh_disk_device_data* fssh_get_disk_device(fssh_partition_id partitionID); 100a38a92c9SIngo Weinhold fssh_partition_data* fssh_get_partition(fssh_partition_id partitionID); 101a38a92c9SIngo Weinhold fssh_partition_data* fssh_get_parent_partition( 102a38a92c9SIngo Weinhold fssh_partition_id partitionID); 103a38a92c9SIngo Weinhold fssh_partition_data* fssh_get_child_partition(fssh_partition_id partitionID, 104a38a92c9SIngo Weinhold int32_t index); 105a38a92c9SIngo Weinhold 106a38a92c9SIngo Weinhold // partition write access 107a38a92c9SIngo Weinhold // (write lock required) 108a38a92c9SIngo Weinhold fssh_partition_data* fssh_create_child_partition( 109a38a92c9SIngo Weinhold fssh_partition_id partitionID, int32_t index, 110a38a92c9SIngo Weinhold fssh_partition_id childID); 111a38a92c9SIngo Weinhold // childID is an optional input parameter -- -1 to be ignored 112a38a92c9SIngo Weinhold bool fssh_delete_partition(fssh_partition_id partitionID); 113a38a92c9SIngo Weinhold void fssh_partition_modified(fssh_partition_id partitionID); 114a38a92c9SIngo Weinhold // tells the disk device manager, that the parition has been modified 115a38a92c9SIngo Weinhold 116*8c8f8c84SIngo Weinhold fssh_status_t fssh_scan_partition(fssh_partition_id partitionID); 117*8c8f8c84SIngo Weinhold // Service method for disks systems: Synchronously scans the partition. 118*8c8f8c84SIngo Weinhold // Device must not be locked. 119*8c8f8c84SIngo Weinhold 120a38a92c9SIngo Weinhold // disk systems 121a38a92c9SIngo Weinhold fssh_disk_system_id fssh_find_disk_system(const char *name); 122a38a92c9SIngo Weinhold 123a38a92c9SIngo Weinhold // jobs 124a38a92c9SIngo Weinhold bool fssh_update_disk_device_job_progress(fssh_disk_job_id jobID, 125a38a92c9SIngo Weinhold float progress); 126a38a92c9SIngo Weinhold bool fssh_update_disk_device_job_extra_progress(fssh_disk_job_id jobID, 127a38a92c9SIngo Weinhold const char *info); 128a38a92c9SIngo Weinhold bool fssh_set_disk_device_job_error_message(fssh_disk_job_id jobID, 129a38a92c9SIngo Weinhold const char *message); 130a38a92c9SIngo Weinhold uint32_t fssh_update_disk_device_job_interrupt_properties( 131a38a92c9SIngo Weinhold fssh_disk_job_id jobID, uint32_t interruptProperties); 132a38a92c9SIngo Weinhold // returns one of B_DISK_DEVICE_JOB_{CONTINUE,CANCEL,REVERSE} 133a38a92c9SIngo Weinhold 134a38a92c9SIngo Weinhold #ifdef __cplusplus 135a38a92c9SIngo Weinhold } 136a38a92c9SIngo Weinhold #endif 137a38a92c9SIngo Weinhold 138a38a92c9SIngo Weinhold #endif // _FSSH_DISK_DEVICE_MANAGER_H 139