libparted 3.6
|
Disk label access. More...
Modules | |
PedPartition | |
Partition access. | |
Files | |
file | disk.h |
file | disk.h |
Data Structures | |
struct | _PedDisk |
Represents a disk label (partition table). More... | |
struct | _PedDiskArchOps |
Architecture-specific operations. More... | |
struct | _PedDiskOps |
struct | _PedDiskType |
Macros | |
#define | _(String) (String) |
#define | N_(String) (String) |
#define | PED_DISK_FIRST_FLAG 1 |
#define | PED_DISK_FIRST_FLAG 1 |
#define | PED_DISK_LAST_FLAG 2 |
#define | PED_DISK_LAST_FLAG 2 |
#define | PED_DISK_TYPE_FIRST_FEATURE 1 |
#define | PED_DISK_TYPE_FIRST_FEATURE 1 |
#define | PED_DISK_TYPE_LAST_FEATURE 32 |
#define | PED_DISK_TYPE_LAST_FEATURE 32 |
#define | PED_PARTITION_FIRST_FLAG 1 |
#define | PED_PARTITION_FIRST_FLAG 1 |
#define | PED_PARTITION_LAST_FLAG 22 |
#define | PED_PARTITION_LAST_FLAG 22 |
Typedefs | |
typedef struct _PedDisk | PedDisk |
typedef struct _PedDisk | PedDisk |
typedef const struct _PedDiskArchOps | PedDiskArchOps |
typedef const struct _PedDiskArchOps | PedDiskArchOps |
typedef enum _PedDiskFlag | PedDiskFlag |
typedef enum _PedDiskFlag | PedDiskFlag |
typedef const struct _PedDiskOps | PedDiskOps |
typedef const struct _PedDiskOps | PedDiskOps |
typedef struct _PedDiskType | PedDiskType |
typedef struct _PedDiskType | PedDiskType |
typedef enum _PedDiskTypeFeature | PedDiskTypeFeature |
typedef enum _PedDiskTypeFeature | PedDiskTypeFeature |
typedef struct _PedPartition | PedPartition |
typedef struct _PedPartition | PedPartition |
typedef enum _PedPartitionFlag | PedPartitionFlag |
typedef enum _PedPartitionFlag | PedPartitionFlag |
typedef enum _PedPartitionType | PedPartitionType |
typedef enum _PedPartitionType | PedPartitionType |
Functions | |
PedDisk * | _ped_disk_alloc (const PedDevice *dev, const PedDiskType *type) |
void | _ped_disk_free (PedDisk *disk) |
int | ped_disk_add_partition (PedDisk *disk, PedPartition *part, const PedConstraint *constraint) |
Adds PedPartition part to PedDisk 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_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) |
PedDiskFlag | ped_disk_flag_get_by_name (const char *name) |
Returns the flag associated with name . | |
const char * | ped_disk_flag_get_name (PedDiskFlag flag) |
Returns a name for a flag , e.g. | |
PedDiskFlag | ped_disk_flag_next (PedDiskFlag flag) |
Iterates through all disk flags. | |
int | ped_disk_get_flag (const PedDisk *disk, PedDiskFlag flag) |
Get the state (1 or 0 ) of a flag on a disk. | |
int | ped_disk_get_last_partition_num (const PedDisk *disk) |
Get the highest available 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. | |
bool | ped_disk_get_max_supported_partition_count (const PedDisk *disk, int *supported) |
Get the highest supported partition number on disk . | |
PedPartition * | ped_disk_get_partition (const PedDisk *disk, int num) |
Returns the partition numbered num . | |
PedAlignment * | ped_disk_get_partition_alignment (const PedDisk *disk) |
Get the alignment needed for partition boundaries on this disk. | |
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. | |
uint8_t * | ped_disk_get_uuid (const PedDisk *disk) |
Get the uuid of the disk disk . | |
int | ped_disk_is_flag_available (const PedDisk *disk, PedDiskFlag flag) |
Check whether a given flag is available on a disk. | |
PedSector | ped_disk_max_partition_length (const PedDisk *disk) |
Return the maximum representable length (in sectors) of a partition on disk \disk. | |
PedSector | ped_disk_max_partition_start_sector (const PedDisk *disk) |
Return the maximum representable start sector of a partition on disk \disk. | |
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_flag (PedDisk *disk, PedDiskFlag flag, int state) |
Set the state (1 or 0 ) of a flag on a 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 const *type) |
Return the next disk type registers, after "type". | |
void | ped_disk_type_register (PedDiskType *type) |
void | ped_disk_type_unregister (PedDiskType *type) |
Disk label access.
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.
#define _ | ( | String | ) | (String) |
#define N_ | ( | String | ) | (String) |
#define PED_DISK_FIRST_FLAG 1 |
#define PED_DISK_FIRST_FLAG 1 |
#define PED_DISK_LAST_FLAG 2 |
#define PED_DISK_LAST_FLAG 2 |
#define PED_DISK_TYPE_FIRST_FEATURE 1 |
#define PED_DISK_TYPE_FIRST_FEATURE 1 |
#define PED_DISK_TYPE_LAST_FEATURE 32 |
#define PED_DISK_TYPE_LAST_FEATURE 32 |
#define PED_PARTITION_FIRST_FLAG 1 |
#define PED_PARTITION_FIRST_FLAG 1 |
#define PED_PARTITION_LAST_FLAG 22 |
#define PED_PARTITION_LAST_FLAG 22 |
typedef const struct _PedDiskArchOps PedDiskArchOps |
typedef const struct _PedDiskArchOps PedDiskArchOps |
typedef enum _PedDiskFlag PedDiskFlag |
typedef enum _PedDiskFlag PedDiskFlag |
typedef const struct _PedDiskOps PedDiskOps |
typedef const struct _PedDiskOps PedDiskOps |
typedef struct _PedDiskType PedDiskType |
typedef struct _PedDiskType PedDiskType |
typedef enum _PedDiskTypeFeature PedDiskTypeFeature |
typedef enum _PedDiskTypeFeature PedDiskTypeFeature |
typedef struct _PedPartition PedPartition |
typedef struct _PedPartition PedPartition |
typedef enum _PedPartitionFlag PedPartitionFlag |
typedef enum _PedPartitionFlag PedPartitionFlag |
typedef enum _PedPartitionType PedPartitionType |
typedef enum _PedPartitionType PedPartitionType |
enum _PedDiskFlag |
enum _PedDiskFlag |
enum _PedDiskTypeFeature |
enum _PedDiskTypeFeature |
enum _PedPartitionFlag |
Partition flags.
enum _PedPartitionFlag |
Partition flags.
enum _PedPartitionType |
Partition types.
enum _PedPartitionType |
Partition types.
PedDisk * _ped_disk_alloc | ( | const PedDevice * | dev, |
const PedDiskType * | type | ||
) |
void _ped_disk_free | ( | PedDisk * | disk | ) |
int ped_disk_add_partition | ( | PedDisk * | disk, |
PedPartition * | part, | ||
const PedConstraint * | constraint | ||
) |
Adds PedPartition part
to PedDisk 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_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
.
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).
Clone a PedDisk object.
old_disk
, NULL on failure. PedPartition * ped_disk_extended_partition | ( | const PedDisk * | disk | ) |
PedDiskFlag ped_disk_flag_get_by_name | ( | const char * | name | ) |
Returns the flag associated with name
.
name
can be the English string, or the translation for the native language.
const char * ped_disk_flag_get_name | ( | PedDiskFlag | flag | ) |
Returns a name for a flag
, e.g.
PED_DISK_CYLINDER_ALIGNMENT will return "cylinder_alignment".
PedDiskFlag ped_disk_flag_next | ( | PedDiskFlag | flag | ) |
Iterates through all disk flags.
ped_disk_flag_next(0) returns the first flag
int ped_disk_get_flag | ( | const PedDisk * | disk, |
PedDiskFlag | flag | ||
) |
Get the state (1
or 0
) of a flag on a disk.
int ped_disk_get_last_partition_num | ( | const PedDisk * | disk | ) |
Get the highest available 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
.
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.
bool ped_disk_get_max_supported_partition_count | ( | const PedDisk * | disk, |
int * | supported | ||
) |
Get the highest supported partition number on disk
.
PedPartition * ped_disk_get_partition | ( | const PedDisk * | disk, |
int | num | ||
) |
Returns the partition numbered num
.
NULL
if the specified partition does not exist. PedAlignment * ped_disk_get_partition_alignment | ( | const PedDisk * | disk | ) |
Get the alignment needed for partition boundaries on this disk.
The returned alignment describes the alignment for the start sector of the partition, for all disklabel types which require alignment, except Sun disklabels, the end sector must be aligned too. To get the end sector alignment decrease the PedAlignment offset by 1.
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_get_primary_partition_count | ( | const PedDisk * | disk | ) |
Get the number of primary partitions.
uint8_t * ped_disk_get_uuid | ( | const PedDisk * | disk | ) |
Get the uuid of the disk disk
.
This will only work if the disk label supports it.
int ped_disk_is_flag_available | ( | const PedDisk * | disk, |
PedDiskFlag | flag | ||
) |
Check whether a given flag is available on a disk.
1
if the flag is available. Return the maximum representable length (in sectors) of a partition on disk \disk.
Return the maximum representable start sector of a partition on disk \disk.
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.PedDisk * ped_disk_new_fresh | ( | PedDevice * | dev, |
const PedDiskType * | type | ||
) |
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_flag | ( | PedDisk * | disk, |
PedDiskFlag | flag, | ||
int | state | ||
) |
Set the state (1
or 0
) of a flag on a disk.
PED_EXCEPTION_ERROR | if the requested flag is not available for this label. |
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 const * | type | ) |
Return the next disk type registers, after "type".
If "type" is NULL, returns the first disk type.
void ped_disk_type_register | ( | PedDiskType * | type | ) |
void ped_disk_type_unregister | ( | PedDiskType * | type | ) |