libparted 3.6
Loading...
Searching...
No Matches
Files | Data Structures | Functions
PedPartition

Partition access. More...

Files

file  disk.h
 
file  disk.h
 

Data Structures

struct  _PedPartition
 PedPartition structure represents a partition. More...
 

Functions

PedPartition_ped_partition_alloc (const PedDisk *disk, PedPartitionType type, const PedFileSystemType *fs_type, PedSector start, PedSector end)
 
int _ped_partition_attempt_align (PedPartition *part, const PedConstraint *external, PedConstraint *internal)
 
void _ped_partition_free (PedPartition *part)
 
void ped_partition_destroy (PedPartition *part)
 Destroy a PedPartition object.
 
PedPartitionFlag ped_partition_flag_get_by_name (const char *name)
 Returns the flag associated with name.
 
const char * ped_partition_flag_get_name (PedPartitionFlag flag)
 Returns a name for a flag, e.g.
 
PedPartitionFlag ped_partition_flag_next (PedPartitionFlag flag)
 Iterates through all flags.
 
int ped_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
 Get the state (1 or 0) of a flag on a partition.
 
const char * ped_partition_get_name (const PedPartition *part)
 Returns the name of a partition part.
 
char * ped_partition_get_path (const PedPartition *part)
 Return a path that can be used to address the partition in the operating system.
 
uint8_t ped_partition_get_type_id (const PedPartition *part)
 Get the type-id of the partition part.
 
uint8_t * ped_partition_get_type_uuid (const PedPartition *part)
 Get the type-uuid of the partition part.
 
uint8_t * ped_partition_get_uuid (const PedPartition *part)
 Get the uuid of the partition part.
 
int ped_partition_is_active (const PedPartition *part)
 Return whether or not the partition is "active".
 
int ped_partition_is_busy (const PedPartition *part)
 Check whether a partition is mounted or busy in some other way.
 
int ped_partition_is_flag_available (const PedPartition *part, PedPartitionFlag flag)
 Check whether a given flag is available on a partition.
 
PedPartitionped_partition_new (const PedDisk *disk, PedPartitionType type, const PedFileSystemType *fs_type, PedSector start, PedSector end)
 Create a new PedPartition on disk.
 
int ped_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
 Set the state (1 or 0) of a flag on a partition.
 
int ped_partition_set_name (PedPartition *part, const char *name)
 Sets the name of a partition.
 
int ped_partition_set_system (PedPartition *part, const PedFileSystemType *fs_type)
 Sets the system type on the partition to fs_type.
 
int ped_partition_set_type_id (PedPartition *part, uint8_t id)
 Set the type-id of the partition part.
 
int ped_partition_set_type_uuid (PedPartition *part, const uint8_t *uuid)
 Set the type-uuid of the partition part.
 
const char * ped_partition_type_get_name (PedPartitionType type)
 Returns a name that seems mildly appropriate for a partition type type.
 

Detailed Description

Partition access.

Function Documentation

◆ _ped_partition_alloc()

PedPartition * _ped_partition_alloc ( const PedDisk disk,
PedPartitionType  type,
const PedFileSystemType fs_type,
PedSector  start,
PedSector  end 
)

◆ _ped_partition_attempt_align()

int _ped_partition_attempt_align ( PedPartition part,
const PedConstraint external,
PedConstraint internal 
)

◆ _ped_partition_free()

void _ped_partition_free ( PedPartition part)

◆ ped_partition_destroy()

void ped_partition_destroy ( PedPartition part)

Destroy a PedPartition object.

Note
Should not be called on a partition that is in a partition table. Use ped_disk_delete_partition() instead.

◆ ped_partition_flag_get_by_name()

PedPartitionFlag ped_partition_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.

◆ ped_partition_flag_get_name()

const char * ped_partition_flag_get_name ( PedPartitionFlag  flag)

Returns a name for a flag, e.g.

PED_PARTITION_BOOT will return "boot".

Note
The returned string will be in English. However, translations are provided, so the caller can call dgettext("parted", RESULT) on the result.

◆ ped_partition_flag_next()

PedPartitionFlag ped_partition_flag_next ( PedPartitionFlag  flag)

Iterates through all flags.

ped_partition_flag_next(0) returns the first flag

Returns
the next flag, or 0 if there are no more flags

◆ ped_partition_get_flag()

int ped_partition_get_flag ( const PedPartition part,
PedPartitionFlag  flag 
)

Get the state (1 or 0) of a flag on a partition.

See ped_partition_set_flag() for conditions that must hold.

Todo:
Where's the check for flag availability?

◆ ped_partition_get_name()

const char * ped_partition_get_name ( const PedPartition part)

Returns the name of a partition part.

This will only work if the disk label supports it.

Note
The returned string should not be modified. It should not be referenced after the partition is destroyed.

◆ ped_partition_get_path()

char * ped_partition_get_path ( const PedPartition part)

Return a path that can be used to address the partition in the operating system.

◆ ped_partition_get_type_id()

uint8_t ped_partition_get_type_id ( const PedPartition part)

Get the type-id of the partition part.

This will only work if the disk label supports it.

◆ ped_partition_get_type_uuid()

uint8_t * ped_partition_get_type_uuid ( const PedPartition part)

Get the type-uuid of the partition part.

This will only work if the disk label supports it.

◆ ped_partition_get_uuid()

uint8_t * ped_partition_get_uuid ( const PedPartition part)

Get the uuid of the partition part.

This will only work if the disk label supports it.

◆ ped_partition_is_active()

int ped_partition_is_active ( const PedPartition part)

Return whether or not the partition is "active".

A partition is active if part->type is neither PED_PARTITION_METADATA nor PED_PARTITION_FREE.

◆ ped_partition_is_busy()

int ped_partition_is_busy ( const PedPartition part)

Check whether a partition is mounted or busy in some other way.

Note
An extended partition is busy if any logical partitions are mounted.
Returns
1 if busy.

◆ ped_partition_is_flag_available()

int ped_partition_is_flag_available ( const PedPartition part,
PedPartitionFlag  flag 
)

Check whether a given flag is available on a partition.

Returns
1 if the flag is available.

◆ ped_partition_new()

PedPartition * ped_partition_new ( const PedDisk disk,
PedPartitionType  type,
const PedFileSystemType fs_type,
PedSector  start,
PedSector  end 
)

Create a new PedPartition on disk.

Parameters
typeOne of PED_PARTITION_NORMAL, PED_PARTITION_EXTENDED, PED_PARTITION_LOGICAL.
Note
The constructed partition is not added to disk's partition table. Use ped_disk_add_partition() to do this.
Returns
A new PedPartition object, NULL on failure.
Exceptions
PED_EXCEPTION_ERRORif type is EXTENDED or LOGICAL but the label does not support this concept.

◆ ped_partition_set_flag()

int ped_partition_set_flag ( PedPartition part,
PedPartitionFlag  flag,
int  state 
)

Set the state (1 or 0) of a flag on a partition.

Flags are disk label specific, although they have a global "namespace": the flag PED_PARTITION_BOOT, for example, roughly means "this" partition is bootable". But this means different things on different disk labels (and may not be defined on some disk labels). For example, on MS-DOS disk labels, there can only be one boot partition, and this refers to the partition that will be booted from on startup. On PC98 disk labels, the user can choose from any bootable partition on startup.

Note
It is an error to call this on an unavailable flag – use ped_partition_is_flag_available() to determine which flags are available for a given disk label.
Exceptions
PED_EXCEPTION_ERRORif the requested flag is not available for this label.

◆ ped_partition_set_name()

int ped_partition_set_name ( PedPartition part,
const char *  name 
)

Sets the name of a partition.

Note
This will only work if the disk label supports it. You can use
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.
Definition: disk.c:657
@ PED_DISK_TYPE_PARTITION_NAME
supports partition names
Definition: disk.h:99
to check whether this feature is enabled for a label.
name will not be modified by libparted. It can be freed by the caller immediately after ped_partition_set_name() is called.
Returns
1 on success, 0 otherwise.

◆ ped_partition_set_system()

int ped_partition_set_system ( PedPartition part,
const PedFileSystemType fs_type 
)

Sets the system type on the partition to fs_type.

Note
The file system may be opened, to get more information about the file system, e.g. to determine if it's FAT16 or FAT32.
Returns
0 on failure.

◆ ped_partition_set_type_id()

int ped_partition_set_type_id ( PedPartition part,
uint8_t  id 
)

Set the type-id of the partition part.

This will only work if the disk label supports it.

◆ ped_partition_set_type_uuid()

int ped_partition_set_type_uuid ( PedPartition part,
const uint8_t *  uuid 
)

Set the type-uuid of the partition part.

This will only work if the disk label supports it.

◆ ped_partition_type_get_name()

const char * ped_partition_type_get_name ( PedPartitionType  type)

Returns a name that seems mildly appropriate for a partition type type.

Eg, if you pass (PED_PARTITION_LOGICAL & PED_PARTITION_FREESPACE), it will return "free". This isn't to be taken too seriously - it's just useful for user interfaces, so you can show the user something ;-)

Note
The returned string will be in English. However, translations are provided, so the caller can call dgettext("parted", RESULT) on the result.