Part

Part — plugin for operations with partition tables

Functions

Types and Values

Includes

#include <part.h>

Description

A plugin for operations with partition tables. Currently supported table (disk label) types are MBR and GPT. See the functions below to get an overview of which operations are supported. If there's anything missing, please don't hesitate to report it as this plugin (just like all the others) is subject to future development and enhancements.

This particular implementation of the part plugin uses libparted for manipulations of both the MBR and GPT disk label types together with the sgdisk utility for some extra GPT-specific features libparted doesn't support. In the future, there's likely to be another implementation of this plugin based on libfdisk which provides full support for both MBR and GPT tables (and possibly some others).

Functions

bd_part_create_table ()

gboolean
bd_part_create_table (gchar *disk,
                      BDPartTableType type,
                      gboolean ignore_existing,
                      GError **error);

Parameters

disk

path of the disk block device to create partition table on

 

type

type of the partition table to create

 

ignore_existing

whether to ignore/overwrite the existing table or not (reports an error if FALSE and there's some table on disk )

 

error

place to store error (if any).

[out]

Returns

whether the partition table was successfully created or not


bd_part_create_part ()

BDPartSpec *
bd_part_create_part (gchar *disk,
                     BDPartTypeReq type,
                     guint64 start,
                     guint64 size,
                     BDPartAlign align,
                     GError **error);

Parameters

disk

disk to create partition on

 

type

type of the partition to create (if BD_PART_TYPE_REQ_NEXT, the partition type will be determined automatically based on the existing partitions)

 

start

where the partition should start (i.e. offset from the disk start)

 

size

desired size of the partition (if 0, a max-sized partition is created)

 

align

alignment to use for the partition

 

error

place to store error (if any).

[out]

Returns

specification of the created partition or NULL in case of error

NOTE: The resulting partition may start at a different position than given by start and can have different size than size due to alignment.

[transfer full]


bd_part_delete_part ()

gboolean
bd_part_delete_part (gchar *disk,
                     gchar *part,
                     GError **error);

Parameters

disk

disk to remove the partition from

 

part

partition to remove

 

error

place to store error (if any).

[out]

Returns

whether the part partition was successfully deleted from disk


bd_part_get_disk_parts ()

BDPartSpec **
bd_part_get_disk_parts (gchar *disk,
                        GError **error);

Parameters

disk

disk to get information about partitions for

 

error

place to store error (if any).

[out]

Returns

specs of the partitions from disk or NULL in case of error.

[transfer full][array zero-terminated=1]


bd_part_get_part_spec ()

BDPartSpec *
bd_part_get_part_spec (gchar *disk,
                       gchar *part,
                       GError **error);

Parameters

disk

disk to remove the partition from

 

part

partition to get spec for

 

error

place to store error (if any).

[out]

Returns

spec of the part partition from disk or NULL in case of error.

[transfer full]


bd_part_set_part_flag ()

gboolean
bd_part_set_part_flag (gchar *disk,
                       gchar *part,
                       BDPartFlag flag,
                       gboolean state,
                       GError **error);

Parameters

disk

disk the partition belongs to

 

part

partition to set the flag on

 

flag

flag to set

 

state

state to set for the flag (TRUE = enabled)

 

error

place to store error (if any).

[out]

Returns

whether the flag flag was successfully set on the part partition or not.


bd_part_spec_copy ()

BDPartSpec *
bd_part_spec_copy (BDPartSpec *data);

bd_part_spec_free ()

void
bd_part_spec_free (BDPartSpec *data);

bd_part_spec_get_type ()

GType
bd_part_spec_get_type ();

bd_part_get_flag_str ()

const gchar *
bd_part_get_flag_str (BDPartFlag flag,
                      GError **error);

Parameters

flag

flag to get string representation for

 

error

place to store error (if any).

[out]

Returns

string representation of flag .

[transfer none]


bd_part_get_part_table_type_str ()

const gchar *
bd_part_get_part_table_type_str (BDPartTableType type,
                                 GError **error);

Parameters

type

table type to get string representation for

 

error

place to store error (if any).

[out]

Returns

string representation of table_type .

[transfer none]


bd_part_get_type_str ()

const gchar *
bd_part_get_type_str (BDPartType type,
                      GError **error);

Parameters

type

type to get string representation for

 

error

place to store error (if any).

[out]

Returns

string representation of type .

[transfer none]


bd_part_error_quark ()

GQuark
bd_part_error_quark (void);

[skip]

Types and Values

BD_PART_ERROR

#define             BD_PART_ERROR

BD_PART_TYPE_SPEC

#define BD_PART_TYPE_SPEC (bd_part_spec_get_type ())

enum BDPartAlign

Members

BD_PART_ALIGN_MINIMAL

   

BD_PART_ALIGN_OPTIMAL

   

BD_PART_ALIGN_NONE

   

enum BDPartFlag

Members

BD_PART_FLAG_BOOT

   

BD_PART_FLAG_ROOT

   

BD_PART_FLAG_SWAP

   

BD_PART_FLAG_HIDDEN

   

BD_PART_FLAG_RAID

   

BD_PART_FLAG_LVM

   

BD_PART_FLAG_LBA

   

BD_PART_FLAG_HPSERVICE

   

BD_PART_FLAG_CPALO

   

BD_PART_FLAG_PREP

   

BD_PART_FLAG_MSFT_RESERVED

   

BD_PART_FLAG_BIOS_GRUB

   

BD_PART_FLAG_APPLE_TV_RECOVERY

   

BD_PART_FLAG_DIAG

   

BD_PART_FLAG_LEGACY_BOOT

   

BD_PART_FLAG_MSFT_DATA

   

BD_PART_FLAG_IRST

   

BD_PART_FLAG_ESP

   

BD_PART_FLAG_BASIC_LAST

   

BD_PART_FLAG_GPT_SYSTEM_PART

   

BD_PART_FLAG_GPT_READ_ONLY

   

BD_PART_FLAG_GPT_HIDDEN

   

BD_PART_FLAG_GPT_NO_AUTOMOUNT

   

BDPartSpec

typedef struct {
    gchar *path;
    gchar *name;
    gchar *type_guid;
    guint64 type;
    guint64 start;
    guint64 size;
    guint64 flags;
} BDPartSpec;

enum BDPartType

Members

BD_PART_TYPE_NORMAL

   

BD_PART_TYPE_LOGICAL

   

BD_PART_TYPE_EXTENDED

   

BD_PART_TYPE_FREESPACE

   

BD_PART_TYPE_METADATA

   

BD_PART_TYPE_PROTECTED

   

enum BDPartTypeReq

Members

BD_PART_TYPE_REQ_NORMAL

   

BD_PART_TYPE_REQ_LOGICAL

   

BD_PART_TYPE_REQ_EXTENDED

   

BD_PART_TYPE_REQ_NEXT

   

enum BDPartError

Members

BD_PART_ERROR_EXISTS

   

BD_PART_ERROR_INVAL

   

BD_PART_ERROR_FAIL

   

enum BDPartTableType

Members

BD_PART_TABLE_MSDOS

   

BD_PART_TABLE_GPT

   

BD_PART_TABLE_UNDEF