Loading...
Searching...
No Matches
device.h
Go to the documentation of this file.
/*
libparted - a library for manipulating disk partitions
Copyright (C) 1998-2001, 2005, 2007-2008, 2011-2014, 2019-2023, 2026 Free
Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PED_DEVICE_H_INCLUDED
#define PED_DEVICE_H_INCLUDED
typedef long long PedSector;
typedef enum {
PED_DEVICE_UNKNOWN = 0,
PED_DEVICE_SCSI = 1,
PED_DEVICE_IDE = 2,
PED_DEVICE_DAC960 = 3,
PED_DEVICE_CPQARRAY = 4,
PED_DEVICE_FILE = 5,
PED_DEVICE_ATARAID = 6,
PED_DEVICE_I2O = 7,
PED_DEVICE_UBD = 8,
PED_DEVICE_DASD = 9,
PED_DEVICE_VIODASD = 10,
PED_DEVICE_SX8 = 11,
PED_DEVICE_DM = 12,
PED_DEVICE_XVD = 13,
PED_DEVICE_SDMMC = 14,
PED_DEVICE_VIRTBLK = 15,
PED_DEVICE_AOE = 16,
PED_DEVICE_MD = 17,
PED_DEVICE_LOOP = 18,
PED_DEVICE_NVME = 19,
PED_DEVICE_RAM = 20,
PED_DEVICE_PMEM = 21
} PedDeviceType;
typedef struct _PedDevice PedDevice;
typedef struct _PedDeviceArchOps PedDeviceArchOps;
typedef struct _PedCHSGeometry PedCHSGeometry;
struct _PedCHSGeometry {
int cylinders;
int heads;
int sectors;
};
struct _PedDevice {
PedDevice* next;
char* model;
char* path;
PedDeviceType type;
long long sector_size;
long long phys_sector_size;
PedSector length;
int open_count;
int read_only;
int external_mode;
int dirty;
int boot_dirty;
PedCHSGeometry hw_geom;
PedCHSGeometry bios_geom;
short host, did;
void* arch_specific;
};
#include <parted/natmath.h>
struct _PedDeviceArchOps {
PedDevice* (*_new) (const char* path);
void (*destroy) (PedDevice* dev);
int (*is_busy) (PedDevice* dev);
int (*open) (PedDevice* dev);
int (*refresh_open) (PedDevice* dev);
int (*close) (PedDevice* dev);
int (*refresh_close) (PedDevice* dev);
int (*read) (const PedDevice* dev, void* buffer,
PedSector start, PedSector count);
int (*write) (PedDevice* dev, const void* buffer,
PedSector start, PedSector count);
int (*sync) (PedDevice* dev);
int (*sync_fast) (PedDevice* dev);
PedSector (*check) (PedDevice* dev, void* buffer,
PedSector start, PedSector count);
void (*probe_all) ();
/* These functions are optional */
PedAlignment *(*get_minimum_alignment)(const PedDevice *dev);
PedAlignment *(*get_optimum_alignment)(const PedDevice *dev);
};
#include <parted/constraint.h>
#include <parted/timer.h>
extern void ped_device_probe_all ();
extern void ped_device_free_all ();
extern PedDevice* ped_device_get (const char* name);
extern PedDevice* ped_device_get_next (const PedDevice* dev)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
__attribute ((__pure__))
#endif
;
extern int ped_device_is_busy (PedDevice* dev);
extern int ped_device_open (PedDevice* dev);
extern int ped_device_close (PedDevice* dev);
extern void ped_device_destroy (PedDevice* dev);
extern void ped_device_cache_remove (PedDevice* dev);
extern int ped_device_begin_external_access (PedDevice* dev);
extern int ped_device_end_external_access (PedDevice* dev);
extern int ped_device_read (const PedDevice* dev, void* buffer,
PedSector start, PedSector count);
extern int ped_device_write (PedDevice* dev, const void* buffer,
PedSector start, PedSector count);
extern int ped_device_sync (PedDevice* dev);
extern int ped_device_sync_fast (PedDevice* dev);
extern PedSector ped_device_check (PedDevice* dev, void* buffer,
PedSector start, PedSector count);
extern PedConstraint* ped_device_get_constraint (const PedDevice* dev);
extern PedConstraint *ped_device_get_minimal_aligned_constraint(
const PedDevice *dev);
extern PedConstraint *ped_device_get_optimal_aligned_constraint(
const PedDevice *dev);
extern PedAlignment *ped_device_get_minimum_alignment(const PedDevice *dev);
extern PedAlignment *ped_device_get_optimum_alignment(const PedDevice *dev);
/* private stuff ;-) */
extern void _ped_device_probe (const char* path);
#endif /* PED_DEVICE_H_INCLUDED */
constraint.h
PedConstraint
struct _PedConstraint PedConstraint
Definition constraint.h:23
start
uint32_t start
Definition dos.c:4
PedAlignment
struct _PedAlignment PedAlignment
Definition natmath.h:31
ped_device_destroy
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
ped_device_cache_remove
void ped_device_cache_remove(PedDevice *dev)
Definition device.c:202
ped_device_read
int ped_device_read(const PedDevice *dev, void *buffer, PedSector start, PedSector count)
Definition device.c:326
ped_device_is_busy
int ped_device_is_busy(PedDevice *dev)
Definition device.c:208
PedSector
long long PedSector
We can address 2^63 sectors.
Definition device.h:31
ped_device_close
int ped_device_close(PedDevice *dev)
Close dev.
Definition device.c:250
ped_device_probe_all
void ped_device_probe_all()
Attempts to detect all devices.
Definition device.c:126
_ped_device_probe
void _ped_device_probe(const char *path)
Definition device.c:109
ped_device_free_all
void ped_device_free_all()
Close/free all devices.
Definition device.c:136
ped_device_sync
int ped_device_sync(PedDevice *dev)
Definition device.c:377
PedCHSGeometry
struct _PedCHSGeometry PedCHSGeometry
Definition device.h:60
PedDeviceType
PedDeviceType
Definition device.h:33
ped_device_write
int ped_device_write(PedDevice *dev, const void *buffer, PedSector start, PedSector count)
Definition device.c:347
ped_device_check
PedSector ped_device_check(PedDevice *dev, void *buffer, PedSector start, PedSector count)
Definition device.c:359
PedDevice
struct _PedDevice PedDevice
Definition device.h:58
ped_device_get_optimal_aligned_constraint
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
ped_device_get
PedDevice * ped_device_get(const char *name)
Gets the device "name", where name is usually the block device, e.g.
Definition device.c:149
ped_device_get_minimum_alignment
PedAlignment * ped_device_get_minimum_alignment(const PedDevice *dev)
Get an alignment that represents minimum hardware requirements on alignment.
Definition device.c:517
ped_device_begin_external_access
int ped_device_begin_external_access(PedDevice *dev)
Begins external access mode.
Definition device.c:287
ped_device_get_minimal_aligned_constraint
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
ped_device_get_constraint
PedConstraint * ped_device_get_constraint(const PedDevice *dev)
Get a constraint that represents hardware requirements on geometry.
Definition device.c:419
ped_device_get_next
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
ped_device_open
int ped_device_open(PedDevice *dev)
Attempt to open a device to allow use of read, write and sync functions.
Definition device.c:226
ped_device_get_optimum_alignment
PedAlignment * ped_device_get_optimum_alignment(const PedDevice *dev)
Get an alignment that represents the hardware requirements for optimal performance.
Definition device.c:543
ped_device_end_external_access
int ped_device_end_external_access(PedDevice *dev)
Complementary function to ped_device_begin_external_access.
Definition device.c:307
ped_device_sync_fast
int ped_device_sync_fast(PedDevice *dev)
Definition device.c:394
PedDeviceArchOps
struct _PedDeviceArchOps PedDeviceArchOps
Definition device.h:59
PED_DEVICE_UNKNOWN
@ PED_DEVICE_UNKNOWN
Definition device.h:34
PED_DEVICE_DAC960
@ PED_DEVICE_DAC960
Definition device.h:37
PED_DEVICE_MD
@ PED_DEVICE_MD
Definition device.h:51
PED_DEVICE_RAM
@ PED_DEVICE_RAM
Definition device.h:54
PED_DEVICE_VIODASD
@ PED_DEVICE_VIODASD
Definition device.h:44
PED_DEVICE_SX8
@ PED_DEVICE_SX8
Definition device.h:45
PED_DEVICE_VIRTBLK
@ PED_DEVICE_VIRTBLK
Definition device.h:49
PED_DEVICE_FILE
@ PED_DEVICE_FILE
Definition device.h:39
PED_DEVICE_SDMMC
@ PED_DEVICE_SDMMC
Definition device.h:48
PED_DEVICE_DASD
@ PED_DEVICE_DASD
Definition device.h:43
PED_DEVICE_ATARAID
@ PED_DEVICE_ATARAID
Definition device.h:40
PED_DEVICE_UBD
@ PED_DEVICE_UBD
Definition device.h:42
PED_DEVICE_DM
@ PED_DEVICE_DM
Definition device.h:46
PED_DEVICE_CPQARRAY
@ PED_DEVICE_CPQARRAY
Definition device.h:38
PED_DEVICE_NVME
@ PED_DEVICE_NVME
Definition device.h:53
PED_DEVICE_I2O
@ PED_DEVICE_I2O
Definition device.h:41
PED_DEVICE_PMEM
@ PED_DEVICE_PMEM
Definition device.h:55
PED_DEVICE_IDE
@ PED_DEVICE_IDE
Definition device.h:36
PED_DEVICE_AOE
@ PED_DEVICE_AOE
Definition device.h:50
PED_DEVICE_XVD
@ PED_DEVICE_XVD
Definition device.h:47
PED_DEVICE_SCSI
@ PED_DEVICE_SCSI
Definition device.h:35
PED_DEVICE_LOOP
@ PED_DEVICE_LOOP
Definition device.h:52
natmath.h
__attribute
#define __attribute(arg)
Definition parted.h:32
name
char name[16]
Definition pc98.c:13
_PedCHSGeometry
A cylinder-head-sector "old-style" geometry.
Definition device.h:67
_PedCHSGeometry::sectors
int sectors
Definition device.h:70
_PedCHSGeometry::cylinders
int cylinders
Definition device.h:68
_PedCHSGeometry::heads
int heads
Definition device.h:69
_PedDeviceArchOps
List of functions implementing architecture-specific operations.
Definition device.h:105
_PedDeviceArchOps::probe_all
void(* probe_all)()
Definition device.h:121
_PedDeviceArchOps::write
int(* write)(PedDevice *dev, const void *buffer, PedSector start, PedSector count)
Definition device.h:115
_PedDeviceArchOps::close
int(* close)(PedDevice *dev)
Definition device.h:111
_PedDeviceArchOps::refresh_open
int(* refresh_open)(PedDevice *dev)
Definition device.h:110
_PedDeviceArchOps::read
int(* read)(const PedDevice *dev, void *buffer, PedSector start, PedSector count)
Definition device.h:113
_PedDeviceArchOps::open
int(* open)(PedDevice *dev)
Definition device.h:109
_PedDeviceArchOps::destroy
void(* destroy)(PedDevice *dev)
Definition device.h:107
_PedDeviceArchOps::sync_fast
int(* sync_fast)(PedDevice *dev)
Definition device.h:118
_PedDeviceArchOps::refresh_close
int(* refresh_close)(PedDevice *dev)
Definition device.h:112
_PedDeviceArchOps::is_busy
int(* is_busy)(PedDevice *dev)
Definition device.h:108
_PedDeviceArchOps::check
PedSector(* check)(PedDevice *dev, void *buffer, PedSector start, PedSector count)
Definition device.h:119
_PedDeviceArchOps::sync
int(* sync)(PedDevice *dev)
Definition device.h:117
_PedDevice
A block device - for example, /dev/hda, not /dev/hda3.
Definition device.h:74
_PedDevice::model
char * model
description of hardware (manufacturer, model)
Definition device.h:77
_PedDevice::path
char * path
device /dev entry
Definition device.h:79
_PedDevice::dirty
int dirty
Definition device.h:90
_PedDevice::bios_geom
PedCHSGeometry bios_geom
Definition device.h:94
_PedDevice::external_mode
int external_mode
Definition device.h:89
_PedDevice::read_only
int read_only
Definition device.h:88
_PedDevice::host
short host
Definition device.h:95
_PedDevice::hw_geom
PedCHSGeometry hw_geom
Definition device.h:93
_PedDevice::boot_dirty
int boot_dirty
Definition device.h:91
_PedDevice::type
PedDeviceType type
SCSI, IDE, etc.
Definition device.h:81
_PedDevice::sector_size
long long sector_size
logical sector size
Definition device.h:82
_PedDevice::phys_sector_size
long long phys_sector_size
physical sector size
Definition device.h:83
_PedDevice::length
PedSector length
device length (LBA)
Definition device.h:84
_PedDevice::did
short did
Definition device.h:95
_PedDevice::open_count
int open_count
the number of times this device has been opened with ped_device_open().
Definition device.h:86
_PedDevice::arch_specific
void * arch_specific
Definition device.h:97
_PedDevice::next
PedDevice * next
Definition device.h:75
timer.h