xref: /haiku/headers/os/drivers/disk_device_manager.h (revision e6b30aee0fd7a23d6a6baab9f3718945a0cd838a)
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 // partition write access
105 // (write lock required)
106 partition_data *create_child_partition(partition_id partitionID, int32 index,
107 		partition_id childID);
108 	// childID is an optional input parameter -- -1 to be ignored
109 bool delete_partition(partition_id partitionID);
110 void partition_modified(partition_id partitionID);
111 	// tells the disk device manager, that the partition has been modified
112 
113 status_t scan_partition(partition_id partitionID);
114 	// Service method for disks systems: Synchronously scans the partition.
115 	// Device must not be locked.
116 
117 // disk systems
118 disk_system_id find_disk_system(const char *name);
119 
120 // jobs
121 bool update_disk_device_job_progress(disk_job_id jobID, float progress);
122 bool update_disk_device_job_extra_progress(disk_job_id jobID, const char *info);
123 bool set_disk_device_job_error_message(disk_job_id jobID, const char *message);
124 uint32 update_disk_device_job_interrupt_properties(disk_job_id jobID,
125 		uint32 interruptProperties);
126 	// returns one of B_DISK_DEVICE_JOB_{CONTINUE,CANCEL,REVERSE}
127 
128 #ifdef __cplusplus
129 }
130 #endif
131 
132 #endif	// _DISK_DEVICE_MANAGER_H
133