libparted 3.6
Loading...
Searching...
No Matches
device.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
69 int heads;
71};
72
74struct _PedDevice {
76
77 char* model;
79 char* path;
82 long long sector_size;
83 long long phys_sector_size;
90 int dirty;
92
95 short host, did;
96
98};
99
100#include <parted/natmath.h>
101
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);
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)
135#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
136 __attribute ((__pure__))
137#endif
138;
139extern int ped_device_is_busy (PedDevice* dev);
140extern int ped_device_open (PedDevice* dev);
141extern int ped_device_close (PedDevice* dev);
142extern void ped_device_destroy (PedDevice* dev);
143extern void ped_device_cache_remove (PedDevice* dev);
144
147
148extern int ped_device_read (const PedDevice* dev, void* buffer,
149 PedSector start, PedSector count);
150extern int ped_device_write (PedDevice* dev, const void* buffer,
151 PedSector start, PedSector count);
152extern int ped_device_sync (PedDevice* dev);
153extern int ped_device_sync_fast (PedDevice* dev);
154extern PedSector ped_device_check (PedDevice* dev, void* buffer,
155 PedSector start, PedSector count);
157
159 const PedDevice *dev);
161 const PedDevice *dev);
162
165
166/* private stuff ;-) */
167
168extern void _ped_device_probe (const char* path);
169
170#endif /* PED_DEVICE_H_INCLUDED */
171
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.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.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.h:34
@ PED_DEVICE_DAC960
Definition: device.h:37
@ PED_DEVICE_MD
Definition: device.h:51
@ PED_DEVICE_RAM
Definition: device.h:54
@ PED_DEVICE_VIODASD
Definition: device.h:44
@ PED_DEVICE_SX8
Definition: device.h:45
@ PED_DEVICE_VIRTBLK
Definition: device.h:49
@ PED_DEVICE_FILE
Definition: device.h:39
@ PED_DEVICE_SDMMC
Definition: device.h:48
@ PED_DEVICE_DASD
Definition: device.h:43
@ PED_DEVICE_ATARAID
Definition: device.h:40
@ PED_DEVICE_UBD
Definition: device.h:42
@ PED_DEVICE_DM
Definition: device.h:46
@ PED_DEVICE_CPQARRAY
Definition: device.h:38
@ PED_DEVICE_NVME
Definition: device.h:53
@ PED_DEVICE_I2O
Definition: device.h:41
@ PED_DEVICE_PMEM
Definition: device.h:55
@ PED_DEVICE_IDE
Definition: device.h:36
@ PED_DEVICE_AOE
Definition: device.h:50
@ PED_DEVICE_XVD
Definition: device.h:47
@ PED_DEVICE_SCSI
Definition: device.h:35
@ PED_DEVICE_LOOP
Definition: device.h:52
#define __attribute(arg)
Definition: parted.h:32
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