xref: /haiku/headers/private/kernel/disk_device_manager/KPartitioningSystem.h (revision d86af8ce27128b44563a6e7f97d2ed2b94511aab)
1 /*
2  * Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Ingo Weinhold <bonefish@cs.tu-berlin.de>
7  */
8 #ifndef _K_PARTITIONING_DISK_DEVICE_SYSTEM_H
9 #define _K_PARTITIONING_DISK_DEVICE_SYSTEM_H
10 
11 #include "KDiskSystem.h"
12 
13 struct partition_module_info;
14 
15 namespace BPrivate {
16 namespace DiskDevice {
17 
18 /**
19  * 	\brief Wrapper for the C interface of a partitioning system add-on.
20  *
21  * 	See \ref ddm_modules.h for better description of the interface.
22  */
23 class KPartitioningSystem : public KDiskSystem {
24 public:
25 	KPartitioningSystem(const char *name);
26 	virtual ~KPartitioningSystem();
27 
28 	virtual status_t Init();
29 
30 	// Scanning
31 
32 	//! Try to identify a given partition
33 	virtual float Identify(KPartition *partition, void **cookie);
34 	//! Scan the partition
35 	virtual status_t Scan(KPartition *partition, void *cookie);
36 	virtual void FreeIdentifyCookie(KPartition *partition, void *cookie);
37 	virtual void FreeCookie(KPartition *partition);
38 	virtual void FreeContentCookie(KPartition *partition);
39 
40 	// Querying
41 
42 	//! Check whether the add-on supports repairing this partition.
43 	virtual bool SupportsRepairing(KPartition *partition, bool checkOnly,
44 								   bool *whileMounted);
45 	//! Check whether the add-on supports resizing this partition.
46 	virtual bool SupportsResizing(KPartition *partition, bool *whileMounted);
47 	//! Check whether the add-on supports resizing children of this partition.
48 	virtual bool SupportsResizingChild(KPartition *child);
49 	//! Check whether the add-on supports moving this partition.
50 	virtual bool SupportsMoving(KPartition *partition, bool *isNoOp);
51 	//! Check whether the add-on supports moving children of this partition.
52 	virtual bool SupportsMovingChild(KPartition *child);
53 	//! Check whether the add-on supports setting name of this partition.
54 	virtual bool SupportsSettingName(KPartition *partition);
55 	//! Check whether the add-on supports setting name to content of this partition.
56 	virtual bool SupportsSettingContentName(KPartition *partition,
57 											bool *whileMounted);
58 	//! Check whether the add-on supports setting type of this partition.
59 	virtual bool SupportsSettingType(KPartition *partition);
60 	//! Check whether the add-on supports setting parameters of this partition.
61 	virtual bool SupportsSettingParameters(KPartition *partition);
62 	//! Check whether the add-on supports setting parameters to content of this partition.
63 	virtual bool SupportsSettingContentParameters(KPartition *partition,
64 												  bool *whileMounted);
65 	//! Check whether the add-on supports initializing this partition.
66 	virtual bool SupportsInitializing(KPartition *partition);
67 	//! Check whether the add-on supports initializing a child of this partition.
68 	virtual bool SupportsInitializingChild(KPartition *child,
69 										   const char *diskSystem);
70 	//! Check whether the add-on supports creating children of this partition.
71 	virtual bool SupportsCreatingChild(KPartition *partition);
72 	//! Check whether the add-on supports deleting children of this partition.
73 	virtual bool SupportsDeletingChild(KPartition *child);
74 	//! Check whether the add-on is a subsystem for a given partition.
75 	virtual bool IsSubSystemFor(KPartition *partition);
76 
77 	//! Validates parameters for resizing a partition
78 	virtual bool ValidateResize(KPartition *partition, off_t *size);
79 	//! Validates parameters for resizing a child partition
80 	virtual bool ValidateResizeChild(KPartition *child, off_t *size);
81 	//! Validates parameters for moving a partition
82 	virtual bool ValidateMove(KPartition *partition, off_t *start);
83 	//! Validates parameters for moving a child partition
84 	virtual bool ValidateMoveChild(KPartition *child, off_t *start);
85 	//! Validates parameters for setting name of a partition
86 	virtual bool ValidateSetName(KPartition *partition, char *name);
87 	//! Validates parameters for setting name to content of a partition
88 	virtual bool ValidateSetContentName(KPartition *partition, char *name);
89 	//! Validates parameters for setting type of a partition
90 	virtual bool ValidateSetType(KPartition *partition, const char *type);
91 	//! Validates parameters for setting parameters of a partition
92 	virtual bool ValidateSetParameters(KPartition *partition,
93 									   const char *parameters);
94 	//! Validates parameters for setting parameters to content of a partition
95 	virtual bool ValidateSetContentParameters(KPartition *parameters,
96 											  const char *parameters);
97 	//! Validates parameters for initializing a partition
98 	virtual bool ValidateInitialize(KPartition *partition, char *name,
99 									const char *parameters);
100 	//! Validates parameters for creating child of a partition
101 	virtual bool ValidateCreateChild(KPartition *partition, off_t *start,
102 									 off_t *size, const char *type,
103 									 const char *parameters, int32 *index);
104 	//! Counts partitionable spaces on a partition
105 	virtual int32 CountPartitionableSpaces(KPartition *partition);
106 	//! Retrieves a list of partitionable spaces on a partition
107 	virtual status_t GetPartitionableSpaces(KPartition *partition,
108 											partitionable_space_data *buffer,
109 											int32 count,
110 											int32 *actualCount = NULL);
111 
112 	//! Iterates through supported partition types
113 	virtual status_t GetNextSupportedType(KPartition *partition, int32 *cookie,
114 										  char *type);
115 	//! Translates the "pretty" content type to an internal type
116 	virtual status_t GetTypeForContentType(const char *contentType,
117 										   char *type);
118 
119 	// Shadow partition modification
120 
121 	//! Calls for additional modifications when shadow partition is changed
122 	virtual status_t ShadowPartitionChanged(KPartition *partition,
123 											uint32 operation);
124 
125 	// Writing
126 
127 	//! Repairs a partition
128 	virtual status_t Repair(KPartition *partition, bool checkOnly,
129 							KDiskDeviceJob *job);
130 	//! Resizes a partition
131 	virtual status_t Resize(KPartition *partition, off_t size,
132 							KDiskDeviceJob *job);
133 	//! Resizes child of a partition
134 	virtual status_t ResizeChild(KPartition *child, off_t size,
135 								 KDiskDeviceJob *job);
136 	//! Moves a partition
137 	virtual status_t Move(KPartition *partition, off_t offset,
138 						  KDiskDeviceJob *job);
139 	//! Moves child of a partition
140 	virtual status_t MoveChild(KPartition *child, off_t offset,
141 							   KDiskDeviceJob *job);
142 	//! Sets name of a partition
143 	virtual status_t SetName(KPartition *partition, char *name,
144 							 KDiskDeviceJob *job);
145 	//! Sets name of the content of a partition
146 	virtual status_t SetContentName(KPartition *partition, char *name,
147 									KDiskDeviceJob *job);
148 	//! Sets type of a partition
149 	virtual status_t SetType(KPartition *partition, char *type,
150 							 KDiskDeviceJob *job);
151 	//! Sets parameters of a partition
152 	virtual status_t SetParameters(KPartition *partition,
153 								   const char *parameters,
154 								   KDiskDeviceJob *job);
155 	//! Sets parameters to content of a partition
156 	virtual status_t SetContentParameters(KPartition *partition,
157 										  const char *parameters,
158 										  KDiskDeviceJob *job);
159 	//! Creates a child partition
160 	virtual status_t CreateChild(KPartition *partition, off_t offset,
161 								 off_t size, const char *type,
162 								 const char *parameters, KDiskDeviceJob *job,
163 								 KPartition **child = NULL,
164 								 partition_id childID = -1);
165 	//! Deletes a child partition
166 	virtual status_t DeleteChild(KPartition *child, KDiskDeviceJob *job);
167 	//! Initializes a partition with this partitioning system
168 	virtual status_t Initialize(KPartition *partition, const char *name,
169 								const char *parameters, KDiskDeviceJob *job);
170 
171 protected:
172 	virtual status_t LoadModule();
173 	virtual void UnloadModule();
174 
175 private:
176 	partition_module_info	*fModule;
177 };
178 
179 } // namespace DiskDevice
180 } // namespace BPrivate
181 
182 using BPrivate::DiskDevice::KPartitioningSystem;
183 
184 #endif	// _K_PARTITIONING_DISK_DEVICE_SYSTEM_H
185