Partition types

Partition types — abstraction to partition types

Functions

Types and Values

Description

There are two basic types of parttypes, string based (e.g. GPT) and code/hex based (e.g. MBR).

Functions

fdisk_copy_parttype ()

struct fdisk_parttype *
fdisk_copy_parttype (const struct fdisk_parttype *type);

Use fdisk_unref_parttype() to deallocate.

Parameters

type

type to copy

 

Returns

newly allocated partition type, or NULL upon failure.


fdisk_new_parttype ()

struct fdisk_parttype *
fdisk_new_parttype (void);

It's recommended to use fdisk_label_get_parttype_from_code() or fdisk_label_get_parttype_from_string() for well known types rather than allocate a new instance.

Returns

new instance.


fdisk_new_unknown_parttype ()

struct fdisk_parttype *
fdisk_new_unknown_parttype (unsigned int code,
                            const char *typestr);

Allocates new 'unknown' partition type. Use fdisk_unref_parttype() to deallocate.

Parameters

code

type as number

 

typestr

type as string

 

Returns

newly allocated partition type, or NULL upon failure.


fdisk_parttype_get_code ()

unsigned int
fdisk_parttype_get_code (const struct fdisk_parttype *t);

Parameters

t

type

 

Returns

partition type code (e.g. for MBR)


fdisk_parttype_get_name ()

const char *
fdisk_parttype_get_name (const struct fdisk_parttype *t);

Parameters

t

type

 

Returns

partition type human readable name


fdisk_parttype_get_string ()

const char *
fdisk_parttype_get_string (const struct fdisk_parttype *t);

Parameters

t

type

 

Returns

partition type string (e.g. GUID for GPT)


fdisk_parttype_is_unknown ()

int
fdisk_parttype_is_unknown (const struct fdisk_parttype *t);

Checks for example result from fdisk_label_parse_parttype().

Parameters

t

type

 

Returns

1 is type is "unknown" or 0.


fdisk_parttype_set_code ()

int
fdisk_parttype_set_code (struct fdisk_parttype *t,
                         int code);

Sets type code to allocated partition type, for static types it returns -EINVAL. Don't use this function for GPT, see fdisk_parttype_set_typestr().

Return: 0 on success, <0 on error

Parameters

t

partition type

 

code

type identifier (e.g. MBR type codes)

 

fdisk_parttype_set_name ()

int
fdisk_parttype_set_name (struct fdisk_parttype *t,
                         const char *str);

Sets type name to allocated partition type, for static types it returns -EINVAL.

Return: 0 on success, <0 on error

Parameters

t

partition type

 

str

type name

 

fdisk_parttype_set_typestr ()

int
fdisk_parttype_set_typestr (struct fdisk_parttype *t,
                            const char *str);

Sets type string to allocated partition type, for static types it returns -EINVAL. Don't use this function for MBR, see fdisk_parttype_set_code().

Return: 0 on success, <0 on error

Parameters

t

partition type

 

str

type identifier (e.g. GUID for GPT)

 

fdisk_ref_parttype ()

void
fdisk_ref_parttype (struct fdisk_parttype *t);

Increments reference counter for allocated types

Parameters

t

partition type

 

fdisk_unref_parttype ()

void
fdisk_unref_parttype (struct fdisk_parttype *t);

Decrements reference counter, on zero the t is automatically deallocated.

Parameters

t

partition pointer

 

Types and Values

struct fdisk_parttype

struct fdisk_parttype;

Partition type.


enum fdisk_parttype_parser_flags

Members

FDISK_PARTTYPE_PARSE_DATA

parse hex or UUID from string

 

FDISK_PARTTYPE_PARSE_DATALAST

try hex or UUID as the last possibility (don't use!)

 

FDISK_PARTTYPE_PARSE_SHORTCUT

try input as type shortcut (e.g 'L' for linux partition)

 

FDISK_PARTTYPE_PARSE_ALIAS

try input as type alias (e.g. 'linux' for linux partition)

 

FDISK_PARTTYPE_PARSE_DEPRECATED

accept also deprecated aliases and shortcuts

 

FDISK_PARTTYPE_PARSE_NOUNKNOWN

ignore unknown types

 

FDISK_PARTTYPE_PARSE_SEQNUM

use input as sequntial number of type (e.g. list-types fdisk dialog)

 

FDISK_PARTTYPE_PARSE_DEFAULT

recommended flags for new code