xref: /haiku/headers/private/fs_shell/fssh_disk_device_manager.h (revision ed24eb5ff12640d052171c6a7feba37fab8a75d1)
1 /*
2  * Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _FSSH_DISK_DEVICE_MANAGER_H
6 #define _FSSH_DISK_DEVICE_MANAGER_H
7 
8 
9 #include "fssh_disk_device_defs.h"
10 #include "fssh_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 fssh_partition_data {
21 	fssh_partition_id	id;				// [sys]
22 	fssh_off_t			offset;
23 	fssh_off_t			size;
24 	fssh_off_t			content_size;
25 	uint32_t			block_size;
26 	int32_t				child_count;
27 	int32_t				index;			// [sys]
28 	uint32_t			status;
29 	uint32_t			flags;
30 	fssh_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 } fssh_partition_data;
41 
42 // C API disk device representation
43 typedef struct fssh_disk_device_data {
44 	fssh_partition_id		id;				// equal to that of the root partition
45 	uint32_t				flags;
46 	char					*path;
47 	fssh_device_geometry	geometry;
48 } fssh_disk_device_data;
49 
50 // C API partitionable space representation
51 typedef struct fssh_partitionable_space_data {
52 	fssh_off_t	offset;
53 	fssh_off_t	size;
54 } fssh_partitionable_space_data;
55 
56 // operations on partitions
57 enum {
58 	FSSH_B_PARTITION_DEFRAGMENT,
59 	FSSH_B_PARTITION_REPAIR,
60 	FSSH_B_PARTITION_RESIZE,
61 	FSSH_B_PARTITION_RESIZE_CHILD,
62 	FSSH_B_PARTITION_MOVE,
63 	FSSH_B_PARTITION_MOVE_CHILD,
64 	FSSH_B_PARTITION_SET_NAME,
65 	FSSH_B_PARTITION_SET_CONTENT_NAME,
66 	FSSH_B_PARTITION_SET_TYPE,
67 	FSSH_B_PARTITION_SET_PARAMETERS,
68 	FSSH_B_PARTITION_SET_CONTENT_PARAMETERS,
69 	FSSH_B_PARTITION_INITIALIZE,
70 	FSSH_B_PARTITION_CREATE_CHILD,
71 	FSSH_B_PARTITION_DELETE_CHILD,
72 };
73 
74 // disk device job cancel status
75 enum {
76 	FSSH_B_DISK_DEVICE_JOB_CONTINUE,
77 	FSSH_B_DISK_DEVICE_JOB_CANCEL,
78 	FSSH_B_DISK_DEVICE_JOB_REVERSE,
79 };
80 
81 // disk device locking
82 fssh_disk_device_data*	fssh_write_lock_disk_device(
83 								fssh_partition_id partitionID);
84 void					fssh_write_unlock_disk_device(
85 								fssh_partition_id partitionID);
86 fssh_disk_device_data*	fssh_read_lock_disk_device(
87 								fssh_partition_id partitionID);
88 void					fssh_read_unlock_disk_device(
89 								fssh_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_t	fssh_find_disk_device(const char *path);
95 int32_t	fssh_find_partition(const char *path);
96 
97 // disk device/partition read access
98 // (read lock required)
99 fssh_disk_device_data*	fssh_get_disk_device(fssh_partition_id partitionID);
100 fssh_partition_data*	fssh_get_partition(fssh_partition_id partitionID);
101 fssh_partition_data*	fssh_get_parent_partition(
102 								fssh_partition_id partitionID);
103 fssh_partition_data*	fssh_get_child_partition(fssh_partition_id partitionID,
104 								int32_t index);
105 
106 // partition write access
107 // (write lock required)
108 fssh_partition_data* 	fssh_create_child_partition(
109 								fssh_partition_id partitionID, int32_t index,
110 								fssh_partition_id childID);
111 	// childID is an optional input parameter -- -1 to be ignored
112 bool					fssh_delete_partition(fssh_partition_id partitionID);
113 void					fssh_partition_modified(fssh_partition_id partitionID);
114 	// tells the disk device manager, that the parition has been modified
115 
116 fssh_status_t fssh_scan_partition(fssh_partition_id partitionID);
117 	// Service method for disks systems: Synchronously scans the partition.
118 	// Device must not be locked.
119 
120 // disk systems
121 fssh_disk_system_id		fssh_find_disk_system(const char *name);
122 
123 // jobs
124 bool		fssh_update_disk_device_job_progress(fssh_disk_job_id jobID,
125 					float progress);
126 bool		fssh_update_disk_device_job_extra_progress(fssh_disk_job_id jobID,
127 					const char *info);
128 bool		fssh_set_disk_device_job_error_message(fssh_disk_job_id jobID,
129 					const char *message);
130 uint32_t	fssh_update_disk_device_job_interrupt_properties(
131 					fssh_disk_job_id jobID, uint32_t interruptProperties);
132 	// returns one of B_DISK_DEVICE_JOB_{CONTINUE,CANCEL,REVERSE}
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif	// _FSSH_DISK_DEVICE_MANAGER_H
139