Loading...
Searching...
No Matches
PedDevice

## Files

file | device.h

## Data Structures

struct | _PedCHSGeometry
| A cylinder-head-sector "old-style" geometry. More...
struct | _PedDevice
| A block device - for example, /dev/hda, not /dev/hda3. More...
struct | _PedDeviceArchOps
| List of functions implementing architecture-specific operations. More...

## Typedefs

typedef struct _PedCHSGeometry | PedCHSGeometry
typedef struct _PedCHSGeometry | PedCHSGeometry
typedef struct _PedDevice | PedDevice
typedef struct _PedDevice | PedDevice
typedef struct _PedDeviceArchOps | PedDeviceArchOps
typedef struct _PedDeviceArchOps | PedDeviceArchOps
typedef long long | PedSector
| We can address 2^63 sectors.
typedef long long | PedSector
| We can address 2^63 sectors.

## Enumerations

enum

PedDeviceType {
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
}

enum

PedDeviceType {
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
}

## Functions

void | _ped_device_probe (const char *path)
int | ped_device_begin_external_access (PedDevice *dev)
| Begins external access mode.
void | ped_device_cache_remove (PedDevice *dev)
PedSector | ped_device_check (PedDevice *dev, void *buffer, PedSector start, PedSector count)
int | ped_device_close (PedDevice *dev)
| Close dev.
void | ped_device_destroy (PedDevice *dev)
| Destroys a device and removes it from the device list, and frees all resources associated with the device (all resources allocated when the device was created).
int | ped_device_end_external_access (PedDevice *dev)
| Complementary function to ped_device_begin_external_access.
void | ped_device_free_all ()
| Close/free all devices.
PedDevice * | ped_device_get (const char *path)
| Gets the device "name", where name is usually the block device, e.g.
PedConstraint * | ped_device_get_constraint (const PedDevice *dev)
| Get a constraint that represents hardware requirements on geometry.
PedConstraint * | ped_device_get_minimal_aligned_constraint (const PedDevice *dev)
| Get a constraint that represents hardware requirements on geometry and alignment.
PedAlignment * | ped_device_get_minimum_alignment (const PedDevice *dev)
| Get an alignment that represents minimum hardware requirements on alignment.
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().
PedConstraint * | ped_device_get_optimal_aligned_constraint (const PedDevice *dev)
| Get a constraint that represents hardware requirements on geometry and alignment.
PedAlignment * | ped_device_get_optimum_alignment (const PedDevice *dev)
| Get an alignment that represents the hardware requirements for optimal performance.
int | ped_device_is_busy (PedDevice *dev)
int | ped_device_open (PedDevice *dev)
| Attempt to open a device to allow use of read, write and sync functions.
void | ped_device_probe_all ()
| Attempts to detect all devices.
int | ped_device_read (const PedDevice *dev, void *buffer, PedSector start, PedSector count)
int | ped_device_sync (PedDevice *dev)
int | ped_device_sync_fast (PedDevice *dev)
int | ped_device_write (PedDevice *dev, const void *buffer, PedSector start, PedSector count)

## Detailed Description

Device access.

When ped_device_probe_all() is called, libparted attempts to detect all devices. It constructs a list which can be accessed with ped_device_get_next().

If you want to use a device that isn't on the list, use ped_device_get(). Also, there may be OS-specific constructors, for creating devices from file descriptors, stores, etc. For example, ped_device_new_from_store().

## Typedef Documentation

## PedCHSGeometry [1/2]

typedef struct _PedCHSGeometry PedCHSGeometry

## PedCHSGeometry [2/2]

typedef struct _PedCHSGeometry PedCHSGeometry

## PedDevice [1/2]

typedef struct _PedDevice PedDevice

## PedDevice [2/2]

typedef struct _PedDevice PedDevice

## PedDeviceArchOps [1/2]

typedef struct _PedDeviceArchOps PedDeviceArchOps

## PedDeviceArchOps [2/2]

typedef struct _PedDeviceArchOps PedDeviceArchOps

## PedSector [1/2]

typedef long long PedSector

We can address 2^63 sectors.

## PedSector [2/2]

typedef long long PedSector

We can address 2^63 sectors.

## Enumeration Type Documentation

## PedDeviceType [1/2]

enum PedDeviceType

Enumerator
PED_DEVICE_UNKNOWN |
PED_DEVICE_SCSI |
PED_DEVICE_IDE |
PED_DEVICE_DAC960 |
PED_DEVICE_CPQARRAY |
PED_DEVICE_FILE |
PED_DEVICE_ATARAID |
PED_DEVICE_I2O |
PED_DEVICE_UBD |
PED_DEVICE_DASD |
PED_DEVICE_VIODASD |
PED_DEVICE_SX8 |
PED_DEVICE_DM |
PED_DEVICE_XVD |
PED_DEVICE_SDMMC |
PED_DEVICE_VIRTBLK |
PED_DEVICE_AOE |
PED_DEVICE_MD |
PED_DEVICE_LOOP |
PED_DEVICE_NVME |
PED_DEVICE_RAM |
PED_DEVICE_PMEM |

## PedDeviceType [2/2]

enum PedDeviceType

Enumerator
PED_DEVICE_UNKNOWN |
PED_DEVICE_SCSI |
PED_DEVICE_IDE |
PED_DEVICE_DAC960 |
PED_DEVICE_CPQARRAY |
PED_DEVICE_FILE |
PED_DEVICE_ATARAID |
PED_DEVICE_I2O |
PED_DEVICE_UBD |
PED_DEVICE_DASD |
PED_DEVICE_VIODASD |
PED_DEVICE_SX8 |
PED_DEVICE_DM |
PED_DEVICE_XVD |
PED_DEVICE_SDMMC |
PED_DEVICE_VIRTBLK |
PED_DEVICE_AOE |
PED_DEVICE_MD |
PED_DEVICE_LOOP |
PED_DEVICE_NVME |
PED_DEVICE_RAM |
PED_DEVICE_PMEM |

## Function Documentation

## _ped_device_probe()

void _ped_device_probe | ( | const char * | path | ) |

extern

## ped_device_begin_external_access()

int ped_device_begin_external_access | ( | PedDevice * | dev | ) |

extern

Begins external access mode.

External access mode allows you to safely do IO on the device. If a PedDevice is open, then you should not do any IO on that device, e.g. by calling an external program like e2fsck, unless you put it in external access mode. You should not use any libparted commands that do IO to a device, e.g. ped_file_system_{open|resize|copy}, ped_disk_{read|write}), while a device is in external access mode. Also, you should not ped_device_close() a device, while it is in external access mode. Note: ped_device_begin_external_access_mode() does things like tell the kernel to flush its caches.

Close a device while pretending it is still open. This is useful for temporarily suspending libparted access to the device in order for an external program to access it. (Running external programs while the device is open can cause cache coherency problems.)

In particular, this function keeps track of dev->open_count, so that reference counting isn't screwed up.

Returns
  zero on failure.

## ped_device_cache_remove()

void ped_device_cache_remove | ( | PedDevice * | dev | ) |

extern

## ped_device_check()

PedSector ped_device_check | ( | PedDevice * | dev,
|  | void * | buffer,
|  | PedSector | start,
|  | PedSector | count )

extern

## ped_device_close()

int ped_device_close | ( | PedDevice * | dev | ) |

extern

Close dev.

If this is the final close, then resources allocated by ped_device_open() are freed.

Returns
  zero on failure

## ped_device_destroy()

void ped_device_destroy | ( | PedDevice * | dev | ) |

extern

Destroys a device and removes it from the device list, and frees all resources associated with the device (all resources allocated when the device was created).

## ped_device_end_external_access()

int ped_device_end_external_access | ( | PedDevice * | dev | ) |

extern

Complementary function to ped_device_begin_external_access.

Note
  does things like tell the kernel to flush the device's cache.

Returns
  zero on failure.

## ped_device_free_all()

void ped_device_free_all | ( |  | ) |

extern

Close/free all devices.

Called by ped_done(), so you do not need to worry about it.

## ped_device_get()

PedDevice * ped_device_get | ( | const char * | path | ) |

extern

Gets the device "name", where name is usually the block device, e.g.

/dev/sdb. If the device wasn't detected with ped_device_probe_all(), an attempt will be made to detect it again. If it is found, it will be added to the list.

## ped_device_get_constraint()

PedConstraint * ped_device_get_constraint | ( | const PedDevice * | dev | ) |

extern

Get a constraint that represents hardware requirements on geometry.

This function will return a constraint representing the limits imposed by the size of the disk, it will not provide any alignment constraints.

Alignment constraints may be desirable when using media that have a physical sector size that is a multiple of the logical sector size, as in this case proper partition alignment can benefit disk performance signigicantly. When you want a constraint with alignment info, use ped_device_get_minimal_aligned_constraint() or ped_device_get_optimal_aligned_constraint().

Returns
  NULL on error, otherwise a pointer to a dynamically allocated constraint.

## ped_device_get_minimal_aligned_constraint()

PedConstraint * ped_device_get_minimal_aligned_constraint | ( | const PedDevice * | dev | ) |

extern

Get a constraint that represents hardware requirements on geometry and alignment.

This function will return a constraint representing the limits imposed by the size of the disk and the minimal alignment requirements for proper performance of the disk.

Returns
  NULL on error, otherwise a pointer to a dynamically allocated constraint.

## ped_device_get_minimum_alignment()

PedAlignment * ped_device_get_minimum_alignment | ( | const PedDevice * | dev | ) |

extern

Get an alignment that represents minimum hardware requirements on alignment.

When for example using media that has a physical sector size that is a multiple of the logical sector size, it is desirable to have disk accesses (and thus partitions) properly aligned. Having partitions not aligned to the minimum hardware requirements may lead to a performance penalty.

The returned alignment describes the alignment for the start sector of the partition, the end sector should be aligned too, to get the end sector alignment decrease the returned alignment's offset by 1.

Returns
  the minimum alignment of partition start sectors, or NULL if this information is not available.

## ped_device_get_next()

PedDevice * ped_device_get_next | ( | const PedDevice * | dev | ) |

extern

Returns the next device that was detected by ped_device_probe_all(), or calls to ped_device_get_next().

If dev is NULL, returns the first device.

Returns
  NULL if dev is the last device.

## ped_device_get_optimal_aligned_constraint()

PedConstraint * ped_device_get_optimal_aligned_constraint | ( | const PedDevice * | dev | ) |

extern

Get a constraint that represents hardware requirements on geometry and alignment.

This function will return a constraint representing the limits imposed by the size of the disk and the alignment requirements for optimal performance of the disk.

Returns
  NULL on error, otherwise a pointer to a dynamically allocated constraint.

## ped_device_get_optimum_alignment()

PedAlignment * ped_device_get_optimum_alignment | ( | const PedDevice * | dev | ) |

extern

Get an alignment that represents the hardware requirements for optimal performance.

The returned alignment describes the alignment for the start sector of the partition, the end sector should be aligned too, to get the end sector alignment decrease the returned alignment's offset by 1.

Returns
  the optimal alignment of partition start sectors, or NULL if this information is not available.

## ped_device_is_busy()

int ped_device_is_busy | ( | PedDevice * | dev | ) |

extern

## ped_device_open()

int ped_device_open | ( | PedDevice * | dev | ) |

extern

Attempt to open a device to allow use of read, write and sync functions.

The meaning of "open" is architecture-dependent. Apart from requesting access to the device from the operating system, it does things like flushing caches.

Note
  May allocate resources. Any resources allocated here will be freed by a final ped_device_close(). (ped_device_open() may be called multiple times – it's a ref-count-like mechanism)

Returns
  zero on failure

## ped_device_probe_all()

void ped_device_probe_all | ( |  | ) |

extern

Attempts to detect all devices.

## ped_device_read()

int ped_device_read | ( | const PedDevice * | dev,
|  | void * | buffer,
|  | PedSector | start,
|  | PedSector | count )

extern

## ped_device_sync()

int ped_device_sync | ( | PedDevice * | dev | ) |

extern

## ped_device_sync_fast()

int ped_device_sync_fast | ( | PedDevice * | dev | ) |

extern

## ped_device_write()

int ped_device_write | ( | PedDevice * | dev,
|  | const void * | buffer,
|  | PedSector | start,
|  | PedSector | count )

extern