Files | |
file | disk.h |
Modules | |
PedPartition | |
Partition access. | |
Data Structures | |
struct | _PedDisk |
Represents a disk label (partition table). More... | |
struct | _PedDiskArchOps |
Architecture-specific operations. More... | |
struct | _PedDiskOps |
struct | _PedDiskType |
Defines | |
#define | _(String) (String) |
#define | N_(String) (String) |
#define | PED_DISK_TYPE_FIRST_FEATURE PED_DISK_TYPE_EXTENDED |
#define | PED_DISK_TYPE_LAST_FEATURE PED_DISK_TYPE_PARTITION_NAME |
#define | PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT |
#define | PED_PARTITION_LAST_FLAG PED_PARTITION_MSFT_RESERVED |
Typedefs | |
typedef _PedDisk | PedDisk |
typedef _PedDiskArchOps | PedDiskArchOps |
typedef _PedDiskOps | PedDiskOps |
typedef _PedDiskType | PedDiskType |
typedef enum _PedDiskTypeFeature | PedDiskTypeFeature |
typedef _PedPartition | PedPartition |
typedef enum _PedPartitionFlag | PedPartitionFlag |
typedef enum _PedPartitionType | PedPartitionType |
Enumerations | |
enum | _PedDiskTypeFeature { PED_DISK_TYPE_EXTENDED = 1, PED_DISK_TYPE_PARTITION_NAME = 2 } |
enum | _PedPartitionFlag { PED_PARTITION_BOOT = 1, PED_PARTITION_ROOT = 2, PED_PARTITION_SWAP = 3, PED_PARTITION_HIDDEN = 4, PED_PARTITION_RAID = 5, PED_PARTITION_LVM = 6, PED_PARTITION_LBA = 7, PED_PARTITION_HPSERVICE = 8, PED_PARTITION_PALO = 9, PED_PARTITION_PREP = 10, PED_PARTITION_MSFT_RESERVED = 11 } |
Partition flags. | |
enum | _PedPartitionType { PED_PARTITION_NORMAL = 0x00, PED_PARTITION_LOGICAL = 0x01, PED_PARTITION_EXTENDED = 0x02, PED_PARTITION_FREESPACE = 0x04, PED_PARTITION_METADATA = 0x08, PED_PARTITION_PROTECTED = 0x10 } |
Partition types. | |
Functions | |
__attribute__ ((deprecated)) extern void ped_register_disk_type(PedDiskType *type) | |
Deprecated: use ped_disk_type_register. | |
PedDisk * | _ped_disk_alloc (const PedDevice *dev, const PedDiskType *disk_type) |
void | _ped_disk_free (PedDisk *disk) |
int | ped_disk_add_partition (PedDisk *disk, PedPartition *part, const PedConstraint *constraint) |
Adds PedPartition part to PedPartition disk . | |
int | ped_disk_check (const PedDisk *disk) |
Perform a sanity check on a partition table. | |
int | ped_disk_clobber (PedDevice *dev) |
Remove all identifying signatures of a partition table,. | |
int | ped_disk_clobber_exclude (PedDevice *dev, const PedDiskType *exclude) |
Remove all identifying signatures of a partition table, except for partition tables of a given type. | |
int | ped_disk_commit (PedDisk *disk) |
int | ped_disk_commit_to_dev (PedDisk *disk) |
Write the changes made to the in-memory description of a partition table to the device. | |
int | ped_disk_commit_to_os (PedDisk *disk) |
Tell the operating system kernel about the partition table layout of disk . | |
int | ped_disk_delete_all (PedDisk *disk) |
Removes and destroys all partitions on disk . | |
int | ped_disk_delete_partition (PedDisk *disk, PedPartition *part) |
Removes part from disk , and destroys part . | |
void | ped_disk_destroy (PedDisk *disk) |
Close disk . | |
PedDisk * | ped_disk_duplicate (const PedDisk *old_disk) |
Clone a PedDisk object. | |
PedPartition * | ped_disk_extended_partition (const PedDisk *disk) |
int | ped_disk_get_last_partition_num (const PedDisk *disk) |
Get the highest partition number on disk . | |
PedGeometry * | ped_disk_get_max_partition_geometry (PedDisk *disk, PedPartition *part, const PedConstraint *constraint) |
Get the maximum geometry part can be grown to, subject to constraint . | |
int | ped_disk_get_max_primary_partition_count (const PedDisk *disk) |
Get the maximum number of (primary) partitions the disk label supports. | |
PedPartition * | ped_disk_get_partition (const PedDisk *disk, int num) |
Returns the partition numbered num . | |
PedPartition * | ped_disk_get_partition_by_sector (const PedDisk *disk, PedSector sect) |
Returns the partition that contains sect. | |
int | ped_disk_get_primary_partition_count (const PedDisk *disk) |
Get the number of primary partitions. | |
int | ped_disk_maximize_partition (PedDisk *disk, PedPartition *part, const PedConstraint *constraint) |
Grow PedPartition part geometry to the maximum possible subject to constraint . | |
int | ped_disk_minimize_extended_partition (PedDisk *disk) |
Reduce the size of the extended partition to a minimum while still wrapping its logical partitions. | |
PedDisk * | ped_disk_new (PedDevice *dev) |
Read the partition table off a device (if one is found). | |
PedDisk * | ped_disk_new_fresh (PedDevice *dev, const PedDiskType *type) |
Create a new partition table on dev . | |
PedPartition * | ped_disk_next_partition (const PedDisk *disk, const PedPartition *part) |
Return the next partition after part on disk . | |
void | ped_disk_print (const PedDisk *disk) |
Prints a summary of disk's partitions. | |
PedDiskType * | ped_disk_probe (PedDevice *dev) |
Return the type of partition table detected on "dev". | |
int | ped_disk_remove_partition (PedDisk *disk, PedPartition *part) |
Removes PedPartition part from PedDisk disk . | |
int | ped_disk_set_partition_geom (PedDisk *disk, PedPartition *part, const PedConstraint *constraint, PedSector start, PedSector end) |
Sets the geometry of part (i.e. | |
int | ped_disk_type_check_feature (const PedDiskType *disk_type, PedDiskTypeFeature feature) |
This function checks if a particular type of partition table supports a feature. | |
PedDiskType * | ped_disk_type_get (const char *name) |
Return the disk type with a name of "name". | |
PedDiskType * | ped_disk_type_get_next (PedDiskType *type) |
Return the next disk type registers, after "type". | |
void | ped_disk_type_register (PedDiskType *disk_type) |
void | ped_disk_type_unregister (PedDiskType *disk_type) |
void | ped_register_disk_type (PedDiskType *disk_type) |
Deprecated: use ped_disk_type_regiser. | |
void | ped_unregister_disk_type (PedDiskType *disk_type) |
Deprecated: use ped_disk_type_unregiser. |
Most programs will need to use ped_disk_new() or ped_disk_new_fresh() to get anything done. A PedDisk is always associated with a device and has a partition table. There are different types of partition tables (or disk labels). These are represented by the PedDiskType enumeration.
enum _PedDiskTypeFeature |
int ped_disk_add_partition | ( | PedDisk * | disk, | |
PedPartition * | part, | |||
const PedConstraint * | constraint | |||
) |
Adds PedPartition part
to PedPartition disk
.
constraint
. You could set constraint
to ped_constraint_exact(&part->geom)
, but many partition table schemes have special requirements on the start and end of partitions. Therefore, having an overly strict constraint will probably mean that this function will fail (in which case part
will be left unmodified) part
is assigned a number (part->num
) in this process.0
on failure. int ped_disk_check | ( | const PedDisk * | disk | ) |
Perform a sanity check on a partition table.
PED_EXCEPTION_WARNING | if a partition type ID does not match the file system on it. |
int ped_disk_clobber | ( | PedDevice * | dev | ) |
Remove all identifying signatures of a partition table,.
int ped_disk_clobber_exclude | ( | PedDevice * | dev, | |
const PedDiskType * | exclude | |||
) |
Remove all identifying signatures of a partition table, except for partition tables of a given type.
int ped_disk_commit_to_dev | ( | PedDisk * | disk | ) |
Write the changes made to the in-memory description of a partition table to the device.
int ped_disk_commit_to_os | ( | PedDisk * | disk | ) |
Tell the operating system kernel about the partition table layout of disk
.
This is rather loosely defined: for example, on old versions of Linux, it simply calls the BLKRRPART ioctl, which tells the kernel to reread the partition table. On newer versions (2.4.x), it will use the new blkpg interface to tell Linux where each partition starts/ends, etc. In this case, Linux does not need to have support for a specific type of partition table.
int ped_disk_delete_all | ( | PedDisk * | disk | ) |
Removes and destroys all partitions on disk
.
0
on failure. int ped_disk_delete_partition | ( | PedDisk * | disk, | |
PedPartition * | part | |||
) |
Removes part
from disk
, and destroys part
.
0
on failure. void ped_disk_destroy | ( | PedDisk * | disk | ) |
Close disk
.
What this function does depends on the PedDiskType of disk
, but you can generally assume that outstanding writes are flushed (this mainly means that _ped_disk_free is called).
PedGeometry * ped_disk_get_max_partition_geometry | ( | PedDisk * | disk, | |
PedPartition * | part, | |||
const PedConstraint * | constraint | |||
) |
Get the maximum geometry part
can be grown to, subject to constraint
.
NULL
on failure. int ped_disk_get_max_primary_partition_count | ( | const PedDisk * | disk | ) |
Get the maximum number of (primary) partitions the disk label supports.
For example, MacIntosh partition maps can have different sizes, and accordingly support a different number of partitions.
PedPartition * ped_disk_get_partition | ( | const PedDisk * | disk, | |
int | num | |||
) |
Returns the partition numbered num
.
NULL
if the specified partition does not exist. PedPartition * ped_disk_get_partition_by_sector | ( | const PedDisk * | disk, | |
PedSector | sect | |||
) |
Returns the partition that contains sect.
If sect lies within a logical partition, then the logical partition is returned (not the extended partition).
int ped_disk_maximize_partition | ( | PedDisk * | disk, | |
PedPartition * | part, | |||
const PedConstraint * | constraint | |||
) |
Grow PedPartition part
geometry to the maximum possible subject to constraint
.
The new geometry will be a superset of the old geometry.
int ped_disk_minimize_extended_partition | ( | PedDisk * | disk | ) |
Reduce the size of the extended partition to a minimum while still wrapping its logical partitions.
If there are no logical partitions, remove the extended partition.
Read the partition table off a device (if one is found).
dev->cylinders
, dev->heads
and dev->sectors
if the partition table indicates that the existing values are incorrect.
Create a new partition table on dev
.
This new partition table is only created in-memory, and nothing is written to disk until ped_disk_commit_to_dev() is called.
PedPartition * ped_disk_next_partition | ( | const PedDisk * | disk, | |
const PedPartition * | part | |||
) |
Return the next partition after part
on disk
.
If part
is NULL
, return the first partition. If part
is the last partition, returns NULL
. If part
is an extended partition, returns the first logical partition. If this is called repeatedly passing the return value as part
, a depth-first traversal is executed.
NULL
if no more partitions left. void ped_disk_print | ( | const PedDisk * | disk | ) |
Prints a summary of disk's partitions.
Useful for debugging.
PedDiskType * ped_disk_probe | ( | PedDevice * | dev | ) |
Return the type of partition table detected on "dev".
int ped_disk_remove_partition | ( | PedDisk * | disk, | |
PedPartition * | part | |||
) |
Removes PedPartition part
from PedDisk disk
.
If part
is an extended partition, it must not contain any logical partitions. part
is *NOT* destroyed. The caller must call ped_partition_destroy(), or use ped_disk_delete_partition() instead.
0
on error. int ped_disk_set_partition_geom | ( | PedDisk * | disk, | |
PedPartition * | part, | |||
const PedConstraint * | constraint, | |||
PedSector | start, | |||
PedSector | end | |||
) |
Sets the geometry of part
(i.e.
change a partitions location). This can fail for many reasons, e.g. can't overlap with other partitions. If it does fail, part
will remain unchanged. Returns 0
on failure. part's
geometry may be set to something different from start
and end
subject to constraint
.
int ped_disk_type_check_feature | ( | const PedDiskType * | disk_type, | |
PedDiskTypeFeature | feature | |||
) |
This function checks if a particular type of partition table supports a feature.
disk_type
supports feature
, 0 otherwise. PedDiskType * ped_disk_type_get | ( | const char * | name | ) |
Return the disk type with a name of "name".
PedDiskType * ped_disk_type_get_next | ( | PedDiskType * | type | ) |
Return the next disk type registers, after "type".
If "type" is NULL, returns the first disk type.