xref: /haiku/headers/os/drivers/disk_device_manager.h (revision 93aeb8c3bc3f13cb1f282e3e749258a23790d947)
1 // disk_device_manager.h
2 //
3 // C API exported by the disk device manager.
4 // Currently only functions of interest for partition modules/FS add-ons
5 // are considered.
6 
7 #ifndef _DISK_DEVICE_MANAGER_H
8 #define _DISK_DEVICE_MANAGER_H
9 
10 #include <Drivers.h>
11 
12 #include <storage/DiskDeviceDefs.h>
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 // C API partition representation
19 // Fields marked [sys] are set by the system and are not to be changed by
20 // the disk system modules.
21 typedef struct partition_data {
22 	partition_id	id;				// [sys]
23 	off_t			offset;
24 	off_t			size;
25 	off_t			content_size;
26 	uint32			block_size;
27 	int32			child_count;
28 	int32			index;			// [sys]
29 	uint32			status;
30 	uint32			flags;
31 	dev_t			volume;			// [sys]
32 	void			*mount_cookie;	// [sys]
33 	char			*name;			// max: B_OS_NAME_LENGTH
34 	char			*content_name;	//
35 	char			*type;			//
36 	const char		*content_type;	// [sys]
37 	char			*parameters;
38 	char			*content_parameters;
39 	void			*cookie;
40 	void			*content_cookie;
41 } partition_data;
42 
43 // C API disk device representation
44 typedef struct disk_device_data {
45 	partition_id	id;				// equal to that of the root partition
46 	uint32			flags;
47 	char			*path;
48 	device_geometry	geometry;
49 } disk_device_data;
50 
51 // C API partitionable space representation
52 typedef struct partitionable_space_data {
53 	off_t	offset;
54 	off_t	size;
55 } partitionable_space_data;
56 
57 // operations on partitions
58 enum {
59 	B_PARTITION_DEFRAGMENT,
60 	B_PARTITION_REPAIR,
61 	B_PARTITION_RESIZE,
62 	B_PARTITION_RESIZE_CHILD,
63 	B_PARTITION_MOVE,
64 	B_PARTITION_MOVE_CHILD,
65 	B_PARTITION_SET_NAME,
66 	B_PARTITION_SET_CONTENT_NAME,
67 	B_PARTITION_SET_TYPE,
68 	B_PARTITION_SET_PARAMETERS,
69 	B_PARTITION_SET_CONTENT_PARAMETERS,
70 	B_PARTITION_INITIALIZE,
71 	B_PARTITION_CREATE_CHILD,
72 	B_PARTITION_DELETE_CHILD,
73 };
74 
75 // disk device job cancel status
76 enum {
77 	B_DISK_DEVICE_JOB_CONTINUE,
78 	B_DISK_DEVICE_JOB_CANCEL,
79 	B_DISK_DEVICE_JOB_REVERSE,
80 };
81 
82 // disk device locking
83 disk_device_data *write_lock_disk_device(partition_id partitionID);
84 void write_unlock_disk_device(partition_id partitionID);
85 disk_device_data *read_lock_disk_device(partition_id partitionID);
86 void read_unlock_disk_device(partition_id partitionID);
87 	// parameter is the ID of any partition on the device
88 
89 // getting disk devices/partitions by path
90 // (no locking required)
91 int32 find_disk_device(const char *path);
92 int32 find_partition(const char *path);
93 
94 // disk device/partition read access
95 // (read lock required)
96 disk_device_data *get_disk_device(partition_id partitionID);
97 partition_data *get_partition(partition_id partitionID);
98 partition_data *get_parent_partition(partition_id partitionID);
99 partition_data *get_child_partition(partition_id partitionID, int32 index);
100 
101 // partition write access
102 // (write lock required)
103 partition_data *create_child_partition(partition_id partitionID, int32 index,
104 									   partition_id childID);
105 	// childID is an optional input parameter -- -1 to be ignored
106 bool delete_partition(partition_id partitionID);
107 void partition_modified(partition_id partitionID);
108 	// tells the disk device manager, that the parition has been modified
109 
110 // disk systems
111 disk_system_id find_disk_system(const char *name);
112 
113 // jobs
114 bool update_disk_device_job_progress(disk_job_id jobID, float progress);
115 bool update_disk_device_job_extra_progress(disk_job_id jobID,
116 										   const char *info);
117 bool set_disk_device_job_error_message(disk_job_id jobID, const char *message);
118 uint32 update_disk_device_job_interrupt_properties(disk_job_id jobID,
119 												   uint32 interruptProperties);
120 	// returns one of B_DISK_DEVICE_JOB_{CONTINUE,CANCEL,REVERSE}
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif	// _DISK_DEVICE_MANAGER_H
127