libparted 3.6
Loading...
Searching...
No Matches
device.in.h
Go to the documentation of this file.
1/*
2 libparted - a library for manipulating disk partitions
3 Copyright (C) 1998-2001, 2005, 2007-2008, 2011-2014, 2019-2023 Free
4 Software Foundation, Inc.
5
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.
10
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.
15
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/>.
18*/
19
27#ifndef PED_DEVICE_H_INCLUDED
28#define PED_DEVICE_H_INCLUDED
29
31typedef long long PedSector;
32
33typedef enum {
57
58typedef struct _PedDevice PedDevice;
61
67struct _PedCHSGeometry {
68 int cylinders;
69 int heads;
70 int sectors;
71};
72
74struct _PedDevice {
76
77 char* model;
79 char* path;
82 long long sector_size;
83 long long phys_sector_size;
86 int open_count;
88 int read_only;
89 int external_mode;
90 int dirty;
91 int boot_dirty;
92
95 short host, did;
96
97 void* arch_specific;
98};
99
100#include <parted/natmath.h>
101
105struct _PedDeviceArchOps {
106 PedDevice* (*_new) (const char* path);
107 void (*destroy) (PedDevice* dev);
108 int (*is_busy) (PedDevice* dev);
109 int (*open) (PedDevice* dev);
110 int (*refresh_open) (PedDevice* dev);
111 int (*close) (PedDevice* dev);
112 int (*refresh_close) (PedDevice* dev);
113 int (*read) (const PedDevice* dev, void* buffer,
114 PedSector start, PedSector count);
115 int (*write) (PedDevice* dev, const void* buffer,
116 PedSector start, PedSector count);
117 int (*sync) (PedDevice* dev);
118 int (*sync_fast) (PedDevice* dev);
119 PedSector (*check) (PedDevice* dev, void* buffer,
120 PedSector start, PedSector count);
121 void (*probe_all) ();
122 /* These functions are optional */
123 PedAlignment *(*get_minimum_alignment)(const PedDevice *dev);
124 PedAlignment *(*get_optimum_alignment)(const PedDevice *dev);
125};
126
127#include <parted/constraint.h>
128#include <parted/timer.h>
129
130extern void ped_device_probe_all ();
131extern void ped_device_free_all ();
132
133extern PedDevice* ped_device_get (const char* name);
134extern PedDevice* ped_device_get_next (const PedDevice* dev) _GL_ATTRIBUTE_PURE;
135extern int ped_device_is_busy (PedDevice* dev);
136extern int ped_device_open (PedDevice* dev);
137extern int ped_device_close (PedDevice* dev);
138extern void ped_device_destroy (PedDevice* dev);
139extern void ped_device_cache_remove (PedDevice* dev);
140
143
144extern int ped_device_read (const PedDevice* dev, void* buffer,
145 PedSector start, PedSector count);
146extern int ped_device_write (PedDevice* dev, const void* buffer,
147 PedSector start, PedSector count);
148extern int ped_device_sync (PedDevice* dev);
149extern int ped_device_sync_fast (PedDevice* dev);
150extern PedSector ped_device_check (PedDevice* dev, void* buffer,
151 PedSector start, PedSector count);
153
155 const PedDevice *dev);
157 const PedDevice *dev);
158
161
162/* private stuff ;-) */
163
164extern void _ped_device_probe (const char* path);
165
166#endif /* PED_DEVICE_H_INCLUDED */
167
uint32_t start
Definition: dos.c:4
void ped_device_destroy(PedDevice *dev)
Destroys a device and removes it from the device list, and frees all resources associated with the de...
Definition: device.c:189
void ped_device_cache_remove(PedDevice *dev)
Definition: device.c:202
int ped_device_read(const PedDevice *dev, void *buffer, PedSector start, PedSector count)
Definition: device.c:326
int ped_device_is_busy(PedDevice *dev)
Definition: device.c:208
long long PedSector
We can address 2^63 sectors.
Definition: device.in.h:31
int ped_device_close(PedDevice *dev)
Close dev.
Definition: device.c:250
void ped_device_probe_all()
Attempts to detect all devices.
Definition: device.c:126
void _ped_device_probe(const char *path)
Definition: device.c:109
void ped_device_free_all()
Close/free all devices.
Definition: device.c:136
int ped_device_sync(PedDevice *dev)
Definition: device.c:377
PedDeviceType
Definition: device.in.h:33
int ped_device_write(PedDevice *dev, const void *buffer, PedSector start, PedSector count)
Definition: device.c:347
PedSector ped_device_check(PedDevice *dev, void *buffer, PedSector start, PedSector count)
Definition: device.c:359
PedConstraint * ped_device_get_optimal_aligned_constraint(const PedDevice *dev)
Get a constraint that represents hardware requirements on geometry and alignment.
Definition: device.c:496
PedDevice * ped_device_get(const char *name)
Gets the device "name", where name is usually the block device, e.g.
Definition: device.c:149
PedAlignment * ped_device_get_minimum_alignment(const PedDevice *dev)
Get an alignment that represents minimum hardware requirements on alignment.
Definition: device.c:517
int ped_device_begin_external_access(PedDevice *dev)
Begins external access mode.
Definition: device.c:287
PedConstraint * ped_device_get_minimal_aligned_constraint(const PedDevice *dev)
Get a constraint that represents hardware requirements on geometry and alignment.
Definition: device.c:478
PedConstraint * ped_device_get_constraint(const PedDevice *dev)
Get a constraint that represents hardware requirements on geometry.
Definition: device.c:419
PedDevice * ped_device_get_next(const PedDevice *dev)
Returns the next device that was detected by ped_device_probe_all(), or calls to ped_device_get_next(...
Definition: device.c:100
int ped_device_open(PedDevice *dev)
Attempt to open a device to allow use of read, write and sync functions.
Definition: device.c:226
PedAlignment * ped_device_get_optimum_alignment(const PedDevice *dev)
Get an alignment that represents the hardware requirements for optimal performance.
Definition: device.c:543
int ped_device_end_external_access(PedDevice *dev)
Complementary function to ped_device_begin_external_access.
Definition: device.c:307
int ped_device_sync_fast(PedDevice *dev)
Definition: device.c:394
@ PED_DEVICE_UNKNOWN
Definition: device.in.h:34
@ PED_DEVICE_DAC960
Definition: device.in.h:37
@ PED_DEVICE_MD
Definition: device.in.h:51
@ PED_DEVICE_RAM
Definition: device.in.h:54
@ PED_DEVICE_VIODASD
Definition: device.in.h:44
@ PED_DEVICE_SX8
Definition: device.in.h:45
@ PED_DEVICE_VIRTBLK
Definition: device.in.h:49
@ PED_DEVICE_FILE
Definition: device.in.h:39
@ PED_DEVICE_SDMMC
Definition: device.in.h:48
@ PED_DEVICE_DASD
Definition: device.in.h:43
@ PED_DEVICE_ATARAID
Definition: device.in.h:40
@ PED_DEVICE_UBD
Definition: device.in.h:42
@ PED_DEVICE_DM
Definition: device.in.h:46
@ PED_DEVICE_CPQARRAY
Definition: device.in.h:38
@ PED_DEVICE_NVME
Definition: device.in.h:53
@ PED_DEVICE_I2O
Definition: device.in.h:41
@ PED_DEVICE_PMEM
Definition: device.in.h:55
@ PED_DEVICE_IDE
Definition: device.in.h:36
@ PED_DEVICE_AOE
Definition: device.in.h:50
@ PED_DEVICE_XVD
Definition: device.in.h:47
@ PED_DEVICE_SCSI
Definition: device.in.h:35
@ PED_DEVICE_LOOP
Definition: device.in.h:52
char name[16]
Definition: pc98.c:13
Definition: natmath.h:56
A cylinder-head-sector "old-style" geometry.
Definition: device.h:67
int sectors
Definition: device.h:70
int cylinders
Definition: device.h:68
int heads
Definition: device.h:69
Definition: constraint.h:29
List of functions implementing architecture-specific operations.
Definition: device.h:105
void(* probe_all)()
Definition: device.h:121
int(* write)(PedDevice *dev, const void *buffer, PedSector start, PedSector count)
Definition: device.h:115
int(* close)(PedDevice *dev)
Definition: device.h:111
int(* refresh_open)(PedDevice *dev)
Definition: device.h:110
int(* read)(const PedDevice *dev, void *buffer, PedSector start, PedSector count)
Definition: device.h:113
int(* open)(PedDevice *dev)
Definition: device.h:109
void(* destroy)(PedDevice *dev)
Definition: device.h:107
int(* sync_fast)(PedDevice *dev)
Definition: device.h:118
int(* refresh_close)(PedDevice *dev)
Definition: device.h:112
int(* is_busy)(PedDevice *dev)
Definition: device.h:108
PedSector(* check)(PedDevice *dev, void *buffer, PedSector start, PedSector count)
Definition: device.h:119
int(* sync)(PedDevice *dev)
Definition: device.h:117
A block device - for example, /dev/hda, not /dev/hda3.
Definition: device.h:74
char * model
description of hardware (manufacturer, model)
Definition: device.h:77
char * path
device /dev entry
Definition: device.h:79
int dirty
Definition: device.h:90
PedCHSGeometry bios_geom
Definition: device.h:94
int external_mode
Definition: device.h:89
int read_only
Definition: device.h:88
short host
Definition: device.h:95
PedCHSGeometry hw_geom
Definition: device.h:93
int boot_dirty
Definition: device.h:91
PedDeviceType type
SCSI, IDE, etc.
Definition: device.h:81
long long sector_size
logical sector size
Definition: device.h:82
long long phys_sector_size
physical sector size
Definition: device.h:83
PedSector length
device length (LBA)
Definition: device.h:84
short did
Definition: device.h:95
int open_count
the number of times this device has been opened with ped_device_open().
Definition: device.h:86
void * arch_specific
Definition: device.h:97
PedDevice * next
Definition: device.h:75