Field

Field — description of the partition fields

Functions

Types and Values

Description

The fdisk fields are static user-friendly descriptions of the partition. The fields are used to avoid label specific stuff in the functions that list disk partitions (e.g. fdisk -l). The field Id is the same as Id for fdisk_partition_to_string().

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int *ids;
size_t nids;
struct fdisk_partition *pa = NULL;
struct fdisk_label *lb = fdisk_get_label(cxt, NULL);

fdisk_label_get_fields_ids(lb, cxt, &ids, &nids);

fdisk_get_partition(cxt, 0, &pa);

for (i = 0; i < nids; i++) {
const struct fdisk_field *field = fdisk_label_get_field(lb, ids[i]);

int id = fdisk_field_get_id(fl);
const char *name = fdisk_field_get_name(fl);
char *data;

fdisk_partition_to_string(pa, id, &data);
printf("%s: %s\n", name, data);
free(data);
}
free(ids);

This example lists all information about the first partition. It will work for MBR as well as for GPT because fields are not hardcoded in the example.

See also fdisk_label_get_field_by_name(), fdisk_label_get_fields_ids_all() and fdisk_label_get_fields_ids().

Functions

fdisk_field_get_id ()

int
fdisk_field_get_id (const struct fdisk_field *field);

Parameters

field

field instance

 

Returns

field Id (FDISK_FIELD_*)


fdisk_field_get_name ()

const char *
fdisk_field_get_name (const struct fdisk_field *field);

Parameters

field

field instance

 

Returns

field name


fdisk_field_get_width ()

double
fdisk_field_get_width (const struct fdisk_field *field);

Parameters

field

field instance

 

Returns

libsmartcols compatible width.


fdisk_field_is_number ()

int
fdisk_field_is_number (const struct fdisk_field *field);

Parameters

field

field instance

 

Returns

1 if field represent number

Types and Values

struct fdisk_field

struct fdisk_field;

Output field description.


enum fdisk_fieldtype

Types of fdisk_field. The fields describe a partition.

Members

FDISK_FIELD_NONE

unspecified item

 

FDISK_FIELD_DEVICE

partition device name

 

FDISK_FIELD_START

start offset of the partition

 

FDISK_FIELD_END

end offset of the partition

 

FDISK_FIELD_SECTORS

number of sectors

 

FDISK_FIELD_CYLINDERS

number of cylinders (deprecated)

 

FDISK_FIELD_SIZE

partition size

 

FDISK_FIELD_TYPE

partition type

 

FDISK_FIELD_TYPEID

partition type ID

 

FDISK_FIELD_ATTR

partition attribute (GPT)

 

FDISK_FIELD_BOOT

partition boot flag

 

FDISK_FIELD_BSIZE

size of the boot area (BSD)

 

FDISK_FIELD_CPG

BSD

 

FDISK_FIELD_EADDR

End-C/H/S (MBR)

 

FDISK_FIELD_FSIZE

BSD

 

FDISK_FIELD_NAME

partition label/name

 

FDISK_FIELD_SADDR

Start-C/H/S (MBR)

 

FDISK_FIELD_UUID

partition UUID (GPT)

 

FDISK_FIELD_FSUUID

Filesystem UUID

 

FDISK_FIELD_FSLABEL

Filesystem LABEL

 

FDISK_FIELD_FSTYPE

Filesystem type

 

FDISK_NFIELDS

Don't use, counter.