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