2
libparted - a library for manipulating disk partitions
3
Copyright (C) 1998-2001, 2005, 2007-2008, 2011-2012 Free Software
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 3 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
21
* \addtogroup PedDevice
27
#ifndef PED_DEVICE_H_INCLUDED
28
#define PED_DEVICE_H_INCLUDED
30
/** We can address 2^63 sectors */
31
typedef long long PedSector;
34
PED_DEVICE_UNKNOWN = 0,
37
PED_DEVICE_DAC960 = 3,
38
PED_DEVICE_CPQARRAY = 4,
40
PED_DEVICE_ATARAID = 6,
44
PED_DEVICE_VIODASD = 10,
48
PED_DEVICE_SDMMC = 14,
49
PED_DEVICE_VIRTBLK = 15,
55
typedef struct _PedDevice PedDevice;
56
typedef struct _PedDeviceArchOps PedDeviceArchOps;
57
typedef struct _PedCHSGeometry PedCHSGeometry;
60
* A cylinder-head-sector "old-style" geometry.
62
* A device addressed in this way has C*H*S sectors.
64
struct _PedCHSGeometry {
70
/** A block device - for example, /dev/hda, not /dev/hda3 */
74
char* model; /**< \brief description of hardware
75
(manufacturer, model) */
76
char* path; /**< device /dev entry */
78
PedDeviceType type; /**< SCSI, IDE, etc. \sa PedDeviceType */
79
long long sector_size; /**< logical sector size */
80
long long phys_sector_size; /**< physical sector size */
81
PedSector length; /**< device length (LBA) */
83
int open_count; /**< the number of times this device has
84
been opened with ped_device_open(). */
90
PedCHSGeometry hw_geom;
91
PedCHSGeometry bios_geom;
97
#include <parted/natmath.h>
100
* List of functions implementing architecture-specific operations.
102
struct _PedDeviceArchOps {
103
PedDevice* (*_new) (const char* path);
104
void (*destroy) (PedDevice* dev);
105
int (*is_busy) (PedDevice* dev);
106
int (*open) (PedDevice* dev);
107
int (*refresh_open) (PedDevice* dev);
108
int (*close) (PedDevice* dev);
109
int (*refresh_close) (PedDevice* dev);
110
int (*read) (const PedDevice* dev, void* buffer,
111
PedSector start, PedSector count);
112
int (*write) (PedDevice* dev, const void* buffer,
113
PedSector start, PedSector count);
114
int (*sync) (PedDevice* dev);
115
int (*sync_fast) (PedDevice* dev);
116
PedSector (*check) (PedDevice* dev, void* buffer,
117
PedSector start, PedSector count);
118
void (*probe_all) ();
119
/* These functions are optional */
120
PedAlignment *(*get_minimum_alignment)(const PedDevice *dev);
121
PedAlignment *(*get_optimum_alignment)(const PedDevice *dev);
124
#include <parted/constraint.h>
125
#include <parted/timer.h>
127
extern void ped_device_probe_all ();
128
extern void ped_device_free_all ();
130
extern PedDevice* ped_device_get (const char* name);
131
extern PedDevice* ped_device_get_next (const PedDevice* dev) _GL_ATTRIBUTE_PURE;
132
extern int ped_device_is_busy (PedDevice* dev);
133
extern int ped_device_open (PedDevice* dev);
134
extern int ped_device_close (PedDevice* dev);
135
extern void ped_device_destroy (PedDevice* dev);
136
extern void ped_device_cache_remove (PedDevice* dev);
138
extern int ped_device_begin_external_access (PedDevice* dev);
139
extern int ped_device_end_external_access (PedDevice* dev);
141
extern int ped_device_read (const PedDevice* dev, void* buffer,
142
PedSector start, PedSector count);
143
extern int ped_device_write (PedDevice* dev, const void* buffer,
144
PedSector start, PedSector count);
145
extern int ped_device_sync (PedDevice* dev);
146
extern int ped_device_sync_fast (PedDevice* dev);
147
extern PedSector ped_device_check (PedDevice* dev, void* buffer,
148
PedSector start, PedSector count);
149
extern PedConstraint* ped_device_get_constraint (const PedDevice* dev);
151
extern PedConstraint *ped_device_get_minimal_aligned_constraint(
152
const PedDevice *dev);
153
extern PedConstraint *ped_device_get_optimal_aligned_constraint(
154
const PedDevice *dev);
156
extern PedAlignment *ped_device_get_minimum_alignment(const PedDevice *dev);
157
extern PedAlignment *ped_device_get_optimum_alignment(const PedDevice *dev);
159
/* private stuff ;-) */
161
extern void _ped_device_probe (const char* path);
163
#endif /* PED_DEVICE_H_INCLUDED */