xref: /haiku/headers/private/kernel/disk_device_manager/KPartitioningSystem.h (revision d9cebac2b77547b7064f22497514eecd2d047160)
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 	virtual float Identify(KPartition *partition, void **cookie);
33 	virtual status_t Scan(KPartition *partition, void *cookie);
34 	virtual void FreeIdentifyCookie(KPartition *partition, void *cookie);
35 	virtual void FreeCookie(KPartition *partition);
36 	virtual void FreeContentCookie(KPartition *partition);
37 
38 	// Querying
39 
40 	virtual uint32 GetSupportedOperations(KPartition* partition, uint32 mask);
41 	virtual uint32 GetSupportedChildOperations(KPartition* child, uint32 mask);
42 
43 	virtual bool SupportsInitializingChild(KPartition *child,
44 		const char *diskSystem);
45 	virtual bool IsSubSystemFor(KPartition *partition);
46 
47 	virtual bool ValidateResize(KPartition *partition, off_t *size);
48 	virtual bool ValidateResizeChild(KPartition *child, off_t *size);
49 	virtual bool ValidateMove(KPartition *partition, off_t *start);
50 	virtual bool ValidateMoveChild(KPartition *child, off_t *start);
51 	virtual bool ValidateSetName(KPartition *partition, char *name);
52 	virtual bool ValidateSetContentName(KPartition *partition, char *name);
53 	virtual bool ValidateSetType(KPartition *partition, const char *type);
54 	virtual bool ValidateSetParameters(KPartition *partition,
55 									   const char *parameters);
56 	virtual bool ValidateSetContentParameters(KPartition *parameters,
57 											  const char *parameters);
58 	virtual bool ValidateInitialize(KPartition *partition, char *name,
59 									const char *parameters);
60 	virtual bool ValidateCreateChild(KPartition *partition, off_t *start,
61 									 off_t *size, const char *type,
62 									 const char *parameters, int32 *index);
63 	virtual int32 CountPartitionableSpaces(KPartition *partition);
64 	virtual status_t GetPartitionableSpaces(KPartition *partition,
65 											partitionable_space_data *buffer,
66 											int32 count,
67 											int32 *actualCount = NULL);
68 
69 	virtual status_t GetNextSupportedType(KPartition *partition, int32 *cookie,
70 										  char *type);
71 	virtual status_t GetTypeForContentType(const char *contentType,
72 										   char *type);
73 
74 	// Shadow partition modification
75 
76 	virtual status_t ShadowPartitionChanged(KPartition *partition,
77 		KPartition *child, uint32 operation);
78 
79 	// Writing
80 
81 	virtual status_t Repair(KPartition *partition, bool checkOnly,
82 							KDiskDeviceJob *job);
83 	virtual status_t Resize(KPartition *partition, off_t size,
84 							KDiskDeviceJob *job);
85 	virtual status_t ResizeChild(KPartition *child, off_t size,
86 								 KDiskDeviceJob *job);
87 	virtual status_t Move(KPartition *partition, off_t offset,
88 						  KDiskDeviceJob *job);
89 	virtual status_t MoveChild(KPartition *child, off_t offset,
90 							   KDiskDeviceJob *job);
91 	virtual status_t SetName(KPartition *partition, char *name,
92 							 KDiskDeviceJob *job);
93 	virtual status_t SetContentName(KPartition *partition, char *name,
94 									KDiskDeviceJob *job);
95 	virtual status_t SetType(KPartition *partition, char *type,
96 							 KDiskDeviceJob *job);
97 	virtual status_t SetParameters(KPartition *partition,
98 								   const char *parameters,
99 								   KDiskDeviceJob *job);
100 	virtual status_t SetContentParameters(KPartition *partition,
101 										  const char *parameters,
102 										  KDiskDeviceJob *job);
103 	virtual status_t CreateChild(KPartition *partition, off_t offset,
104 								 off_t size, const char *type,
105 								 const char *parameters, KDiskDeviceJob *job,
106 								 KPartition **child = NULL,
107 								 partition_id childID = -1);
108 	virtual status_t DeleteChild(KPartition *child, KDiskDeviceJob *job);
109 	virtual status_t Initialize(KPartition *partition, const char *name,
110 								const char *parameters, KDiskDeviceJob *job);
111 
112 protected:
113 	virtual status_t LoadModule();
114 	virtual void UnloadModule();
115 
116 private:
117 	partition_module_info	*fModule;
118 };
119 
120 } // namespace DiskDevice
121 } // namespace BPrivate
122 
123 using BPrivate::DiskDevice::KPartitioningSystem;
124 
125 #endif	// _K_PARTITIONING_DISK_DEVICE_SYSTEM_H
126