xref: /haiku/headers/os/drivers/disk_device_manager.h (revision 2710b4f5d4251c5cf88c82b0114ea99b0ef46d22)
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 	uint32			physical_block_size;
29 	int32			child_count;
30 	int32			index;			// [sys]
31 	uint32			status;
32 	uint32			flags;
33 	dev_t			volume;			// [sys]
34 	void			*mount_cookie;	// [sys]
35 	char			*name;			// max: B_OS_NAME_LENGTH
36 	char			*content_name;	//
37 	char			*type;			//
38 	const char		*content_type;	// [sys]
39 	char			*parameters;
40 	char			*content_parameters;
41 	void			*cookie;
42 	void			*content_cookie;
43 } partition_data;
44 
45 // C API disk device representation
46 typedef struct disk_device_data {
47 	partition_id	id;				// equal to that of the root partition
48 	uint32			flags;
49 	char			*path;
50 	device_geometry	geometry;
51 } disk_device_data;
52 
53 // C API partitionable space representation
54 typedef struct partitionable_space_data {
55 	off_t	offset;
56 	off_t	size;
57 } partitionable_space_data;
58 
59 // operations on partitions
60 enum {
61 	B_PARTITION_SHADOW,			// indicates creation of a shadow partition
62 	B_PARTITION_SHADOW_CHILD,	//
63 	B_PARTITION_DEFRAGMENT,
64 	B_PARTITION_REPAIR,
65 	B_PARTITION_RESIZE,
66 	B_PARTITION_RESIZE_CHILD,
67 	B_PARTITION_MOVE,
68 	B_PARTITION_MOVE_CHILD,
69 	B_PARTITION_SET_NAME,
70 	B_PARTITION_SET_CONTENT_NAME,
71 	B_PARTITION_SET_TYPE,
72 	B_PARTITION_SET_PARAMETERS,
73 	B_PARTITION_SET_CONTENT_PARAMETERS,
74 	B_PARTITION_INITIALIZE,
75 	B_PARTITION_CREATE_CHILD,
76 	B_PARTITION_DELETE_CHILD,
77 };
78 
79 // disk device job cancel status
80 enum {
81 	B_DISK_DEVICE_JOB_CONTINUE,
82 	B_DISK_DEVICE_JOB_CANCEL,
83 	B_DISK_DEVICE_JOB_REVERSE,
84 };
85 
86 // disk device locking
87 disk_device_data *write_lock_disk_device(partition_id partitionID);
88 void write_unlock_disk_device(partition_id partitionID);
89 disk_device_data *read_lock_disk_device(partition_id partitionID);
90 void read_unlock_disk_device(partition_id partitionID);
91 	// parameter is the ID of any partition on the device
92 
93 // getting disk devices/partitions by path
94 // (no locking required)
95 int32 find_disk_device(const char *path);
96 int32 find_partition(const char *path);
97 
98 // disk device/partition read access
99 // (read lock required)
100 disk_device_data *get_disk_device(partition_id partitionID);
101 partition_data *get_partition(partition_id partitionID);
102 partition_data *get_parent_partition(partition_id partitionID);
103 partition_data *get_child_partition(partition_id partitionID, int32 index);
104 
105 int open_partition(partition_id partitionID, int openMode);
106 
107 // partition write access
108 // (write lock required)
109 partition_data *create_child_partition(partition_id partitionID, int32 index,
110 		off_t offset, off_t size, partition_id childID);
111 	// childID is an optional input parameter -- -1 to be ignored
112 bool delete_partition(partition_id partitionID);
113 void partition_modified(partition_id partitionID);
114 	// tells the disk device manager, that the partition has been modified
115 
116 status_t scan_partition(partition_id partitionID);
117 	// Service method for disks systems: Synchronously scans the partition.
118 	// Device must not be locked.
119 
120 // partition support functions
121 // (no lock required)
122 status_t get_default_partition_content_name(partition_id partitionID,
123 		const char* fileSystemName, char* buffer, size_t bufferSize);
124 	// The partition_data::content_size field must already be initialized.
125 
126 // disk systems
127 disk_system_id find_disk_system(const char *name);
128 
129 // jobs
130 bool update_disk_device_job_progress(disk_job_id jobID, float progress);
131 bool update_disk_device_job_extra_progress(disk_job_id jobID, const char *info);
132 bool set_disk_device_job_error_message(disk_job_id jobID, const char *message);
133 uint32 update_disk_device_job_interrupt_properties(disk_job_id jobID,
134 		uint32 interruptProperties);
135 	// returns one of B_DISK_DEVICE_JOB_{CONTINUE,CANCEL,REVERSE}
136 
137 #ifdef __cplusplus
138 }
139 #endif
140 
141 #endif	// _DISK_DEVICE_MANAGER_H
142