2 * Copyright 2003-2011, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
5 #ifndef _K_DISK_DEVICE_MODULES_H
6 #define _K_DISK_DEVICE_MODULES_H
8 //! Interface to be implemented by partitioning modules.
10 #include <disk_device_manager.h>
12 #include <SupportDefs.h>
15 typedef struct partition_module_info
{
17 const char* short_name
;
18 const char* pretty_name
;
22 // (the device is write locked)
23 float (*identify_partition
)(int fd
, partition_data
* partition
,
25 status_t (*scan_partition
)(int fd
, partition_data
* partition
,
26 void* identifyCookie
);
27 void (*free_identify_partition_cookie
)(partition_data
* partition
,
29 void (*free_partition_cookie
)(partition_data
* partition
);
30 void (*free_partition_content_cookie
)(partition_data
* partition
);
34 // (the device is read locked)
35 uint32 (*get_supported_operations
)(partition_data
* partition
, uint32 mask
);
36 uint32 (*get_supported_child_operations
)(partition_data
* partition
,
37 partition_data
* child
, uint32 mask
);
39 bool (*supports_initializing_child
)(partition_data
* partition
,
41 bool (*is_sub_system_for
)(partition_data
* partition
);
43 bool (*validate_resize
)(partition_data
* partition
, off_t
* size
);
44 bool (*validate_resize_child
)(partition_data
* partition
,
45 partition_data
* child
, off_t
* size
);
46 bool (*validate_move
)(partition_data
* partition
, off_t
* start
);
47 bool (*validate_move_child
)(partition_data
* partition
,
48 partition_data
* child
, off_t
* start
);
49 bool (*validate_set_name
)(partition_data
* partition
, char* name
);
50 bool (*validate_set_content_name
)(partition_data
* partition
, char* name
);
51 bool (*validate_set_type
)(partition_data
* partition
, const char* type
);
52 bool (*validate_set_parameters
)(partition_data
* partition
,
53 const char* parameters
);
55 bool (*validate_set_content_parameters
)(partition_data
* partition
,
56 const char* parameters
);
57 bool (*validate_initialize
)(partition_data
* partition
, char* name
,
58 const char* parameters
);
59 bool (*validate_create_child
)(partition_data
* partition
, off_t
* start
,
60 off_t
* size
, const char* type
, const char* name
,
61 const char* parameters
, int32
* index
);
62 status_t (*get_partitionable_spaces
)(partition_data
* partition
,
63 partitionable_space_data
* buffer
, int32 count
,
65 // When not implemented, a standard algorithm is used.
67 status_t (*get_next_supported_type
)(partition_data
* partition
,
68 int32
* cookie
, char* type
);
69 status_t (*get_type_for_content_type
)(const char* contentType
, char* type
);
72 // shadow partition modification
73 // (device is write locked)
74 status_t (*shadow_changed
)(partition_data
* partition
,
75 partition_data
*child
, uint32 operation
);
79 // (device is NOT locked)
80 status_t (*repair
)(int fd
, partition_id partition
, bool checkOnly
,
82 status_t (*resize
)(int fd
, partition_id partition
, off_t size
,
84 status_t (*resize_child
)(int fd
, partition_id partition
, off_t size
,
86 status_t (*move
)(int fd
, partition_id partition
, off_t offset
,
88 status_t (*move_child
)(int fd
, partition_id partition
, partition_id child
,
89 off_t offset
, disk_job_id job
);
90 status_t (*set_name
)(int fd
, partition_id partition
, const char* name
,
92 status_t (*set_content_name
)(int fd
, partition_id partition
,
93 const char* name
, disk_job_id job
);
94 status_t (*set_type
)(int fd
, partition_id partition
, const char* type
,
96 status_t (*set_parameters
)(int fd
, partition_id partition
,
97 const char* parameters
, disk_job_id job
);
98 status_t (*set_content_parameters
)(int fd
, partition_id partition
,
99 const char* parameters
, disk_job_id job
);
100 status_t (*initialize
)(int fd
, partition_id partition
, const char* name
,
101 const char *parameters
, off_t partitionSize
, disk_job_id job
);
102 status_t (*uninitialize
)(int fd
, partition_id partition
,
103 off_t partitionSize
, uint32 blockSize
, disk_job_id job
);
104 status_t (*create_child
)(int fd
, partition_id partition
, off_t offset
,
105 off_t size
, const char* type
, const char* name
,
106 const char* parameters
, disk_job_id job
,
107 partition_id
* childID
);
108 // childID is used for the return value, but is also an optional input
109 // parameter -- -1 to be ignored
110 status_t (*delete_child
)(int fd
, partition_id partition
, partition_id child
,
112 } partition_module_info
;
114 #endif // _K_DISK_DEVICE_MODULES_H