1/*
2 * Copyright 2003-2011, Haiku, Inc.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _K_DISK_DEVICE_MODULES_H
6#define _K_DISK_DEVICE_MODULES_H
7
8//! Interface to be implemented by partitioning modules.
9
10#include <disk_device_manager.h>
11#include <module.h>
12#include <SupportDefs.h>
13
14
15typedef struct partition_module_info {
16	module_info									module;
17	const char*									short_name;
18	const char*									pretty_name;
19	uint32										flags;
20
21	// scanning
22	// (the device is write locked)
23	float (*identify_partition)(int fd, partition_data* partition,
24				void** cookie);
25	status_t (*scan_partition)(int fd, partition_data* partition,
26				void* identifyCookie);
27	void (*free_identify_partition_cookie)(partition_data* partition,
28				void* cookie);
29	void (*free_partition_cookie)(partition_data* partition);
30	void (*free_partition_content_cookie)(partition_data* partition);
31
32
33	// querying
34	// (the device is read locked)
35	uint32 (*get_supported_operations)(partition_data* partition, uint32 mask);
36	uint32 (*get_supported_child_operations)(partition_data* partition,
37				partition_data* child, uint32 mask);
38
39	bool (*supports_initializing_child)(partition_data* partition,
40				const char* system);
41	bool (*is_sub_system_for)(partition_data* partition);
42
43	bool (*validate_resize)(partition_data* partition, off_t* size);
44	bool (*validate_resize_child)(partition_data* partition,
45				partition_data* child, off_t* size);
46	bool (*validate_move)(partition_data* partition, off_t* start);
47	bool (*validate_move_child)(partition_data* partition,
48				partition_data* child, off_t* start);
49	bool (*validate_set_name)(partition_data* partition, char* name);
50	bool (*validate_set_content_name)(partition_data* partition, char* name);
51	bool (*validate_set_type)(partition_data* partition, const char* type);
52	bool (*validate_set_parameters)(partition_data* partition,
53				const char* parameters);
54
55	bool (*validate_set_content_parameters)(partition_data* partition,
56				const char* parameters);
57	bool (*validate_initialize)(partition_data* partition, char* name,
58				const char* parameters);
59	bool (*validate_create_child)(partition_data* partition, off_t* start,
60				off_t* size, const char* type, const char* name,
61				const char* parameters, int32* index);
62	status_t (*get_partitionable_spaces)(partition_data* partition,
63				partitionable_space_data* buffer, int32 count,
64				int32* actualCount);
65		// When not implemented, a standard algorithm is used.
66
67	status_t (*get_next_supported_type)(partition_data* partition,
68				int32* cookie, char* type);
69	status_t (*get_type_for_content_type)(const char* contentType, char* type);
70
71
72	// shadow partition modification
73	// (device is write locked)
74	status_t (*shadow_changed)(partition_data* partition,
75				partition_data *child, uint32 operation);
76
77
78	// writing
79	// (device is NOT locked)
80	status_t (*repair)(int fd, partition_id partition, bool checkOnly,
81				disk_job_id job);
82	status_t (*resize)(int fd, partition_id partition, off_t size,
83				disk_job_id job);
84	status_t (*resize_child)(int fd, partition_id partition, off_t size,
85				disk_job_id job);
86	status_t (*move)(int fd, partition_id partition, off_t offset,
87				disk_job_id job);
88	status_t (*move_child)(int fd, partition_id partition, partition_id child,
89				off_t offset, disk_job_id job);
90	status_t (*set_name)(int fd, partition_id partition, const char* name,
91				disk_job_id job);
92	status_t (*set_content_name)(int fd, partition_id partition,
93				const char* name, disk_job_id job);
94	status_t (*set_type)(int fd, partition_id partition, const char* type,
95				disk_job_id job);
96	status_t (*set_parameters)(int fd, partition_id partition,
97				const char* parameters, disk_job_id job);
98	status_t (*set_content_parameters)(int fd, partition_id partition,
99				const char* parameters, disk_job_id job);
100	status_t (*initialize)(int fd, partition_id partition, const char* name,
101				const char *parameters, off_t partitionSize, disk_job_id job);
102	status_t (*uninitialize)(int fd, partition_id partition,
103				off_t partitionSize, uint32 blockSize, disk_job_id job);
104	status_t (*create_child)(int fd, partition_id partition, off_t offset,
105				off_t size, const char* type, const char* name,
106				const char* parameters, disk_job_id job,
107				partition_id* childID);
108		// childID is used for the return value, but is also an optional input
109		// parameter -- -1 to be ignored
110	status_t (*delete_child)(int fd, partition_id partition, partition_id child,
111				disk_job_id job);
112} partition_module_info;
113
114#endif	// _K_DISK_DEVICE_MODULES_H
115