Welcome to NYCU CSIT Mirror site

UEFI GPT: libfdisk Reference Manual

UEFI GPT

UEFI GPT — specific functionality

Types and Values

Description

Functions

fdisk_gpt_is_hybrid ()

int
fdisk_gpt_is_hybrid (struct fdisk_context *cxt);

The regular GPT contains PMBR (dummy protective MBR) where the protective MBR does not address any partitions.

Hybrid GPT contains regular MBR where this partition table addresses the same partitions as GPT. It's recommended to not use hybrid GPT due to MBR limits.

The libfdisk does not provide functionality to sync GPT and MBR, you have to directly access and modify (P)MBR (see fdisk_new_nested_context()).

Parameters

cxt

context

 

Returns

1 if partition table detected as hybrid otherwise return 0


fdisk_gpt_get_partition_attrs ()

int
fdisk_gpt_get_partition_attrs (struct fdisk_context *cxt,
                               size_t partnum,
                               uint64_t *attrs);

Sets attrs for the given partition

Parameters

cxt

context

 

partnum

partition number

 

attrs

GPT partition attributes

 

Returns

0 on success, <0 on error.


fdisk_gpt_set_partition_attrs ()

int
fdisk_gpt_set_partition_attrs (struct fdisk_context *cxt,
                               size_t partnum,
                               uint64_t attrs);

Sets the GPT partition attributes field to attrs .

Parameters

cxt

context

 

partnum

partition number

 

attrs

GPT partition attributes

 

Returns

0 on success, <0 on error.


fdisk_gpt_set_npartitions ()

int
fdisk_gpt_set_npartitions (struct fdisk_context *cxt,
                           uint32_t nents);

Elarge GPT entries array if possible. The function check if an existing partition does not overlap the entries array area. If yes, then it report warning and returns -EINVAL.

Parameters

cxt

context

 

nents

number of wanted entries

 

Returns

0 on success, < 0 on error.

Since: 2.29


fdisk_gpt_disable_relocation ()

void
fdisk_gpt_disable_relocation (struct fdisk_label *lb,
                              int disable);

Disable automatic backup header relocation to the end of the device. The header position is recalculated during libfdisk probing stage by fdisk_assign_device() and later written by fdisk_write_disklabel(), so you need to call it before fdisk_assign_device().

Parameters

lb

label

 

disable

0 or 1

 

Since: 2.36


fdisk_gpt_enable_minimize ()

void
fdisk_gpt_enable_minimize (struct fdisk_label *lb,
                           int enable);

Force libfdisk to write backup header to behind last partition. The header position is recalculated on fdisk_write_disklabel().

Parameters

lb

label

 

enable

0 or 1

 

Since: 2.36

Types and Values

GPT_FLAG_REQUIRED

#define GPT_FLAG_REQUIRED 1

GPT attribute; marks a partition as system partition (disk partitioning utilities must preserve the partition as is)


GPT_FLAG_NOBLOCK

#define GPT_FLAG_NOBLOCK 2

GPT attribute; EFI firmware should ignore the content of the partition and not try to read from it


GPT_FLAG_LEGACYBOOT

#define GPT_FLAG_LEGACYBOOT 3

GPT attribute; use the partition for legacy boot method


GPT_FLAG_GUIDSPECIFIC

#define GPT_FLAG_GUIDSPECIFIC 4

GPT attribute; for bites 48-63, defined and used by the individual partition type.

The flag GPT_FLAG_GUIDSPECIFIC forces libfdisk to ask (by ask API) for a bit number. If you want to toggle specific bit and avoid any dialog, then use the bit number (in range 48..63). For example:

// start dialog to ask for bit number fdisk_toggle_partition_flag(cxt, n, GPT_FLAG_GUIDSPECIFIC);

// toggle bit 60 fdisk_toggle_partition_flag(cxt, n, 60);