Top |
int | fdisk_get_freespaces () |
int | fdisk_get_partitions () |
int | fdisk_apply_table () |
struct fdisk_table * | fdisk_new_table () |
void | fdisk_ref_table () |
int | fdisk_reset_table () |
int | fdisk_table_add_partition () |
size_t | fdisk_table_get_nents () |
struct fdisk_partition * | fdisk_table_get_partition () |
struct fdisk_partition * | fdisk_table_get_partition_by_partno () |
int | fdisk_table_is_empty () |
int | fdisk_table_next_partition () |
int | fdisk_table_remove_partition () |
int | fdisk_table_sort_partitions () |
int | fdisk_table_wrong_order () |
void | fdisk_unref_table () |
The fdisk_table is simple container for fdisk_partitions. The table is no directly connected to label data (partition table), and table changes don't affect in-memory or on-disk data.
int fdisk_get_freespaces (struct fdisk_context *cxt
,struct fdisk_table **tb
);
This function adds freespace (described by fdisk_partition) to table
, it
allocates a new table if the table
points to NULL.
Note that free space smaller than grain (see fdisk_get_grain_size()
) is
ignored.
int fdisk_get_partitions (struct fdisk_context *cxt
,struct fdisk_table **tb
);
This function adds partitions from disklabel to table
, it allocates a new
table if if table
points to NULL.
int fdisk_apply_table (struct fdisk_context *cxt
,struct fdisk_table *tb
);
Add partitions from table tb
to the in-memory disk label. See
fdisk_add_partition()
, fdisk_delete_all_partitions()
. The partitions
that does not define start (or does not follow the default start)
are ignored.
struct fdisk_table *
fdisk_new_table (void
);
The table is a container for struct fdisk_partition entries. The container does not have any real connection with label (partition table) and with real on-disk data.
int
fdisk_reset_table (struct fdisk_table *tb
);
Removes all entries (partitions) from the table. The partitions with zero reference count will be deallocated. This function does not modify partition table.
int fdisk_table_add_partition (struct fdisk_table *tb
,struct fdisk_partition *pa
);
Adds a new entry to table and increment pa
reference counter. Don't forget to
use fdisk_unref_partition()
after fdisk_table_add_partition()
if you want to keep
the pa
referenced by the table only.
struct fdisk_partition * fdisk_table_get_partition (struct fdisk_table *tb
,size_t n
);
struct fdisk_partition * fdisk_table_get_partition_by_partno (struct fdisk_table *tb
,size_t partno
);
int fdisk_table_next_partition (struct fdisk_table *tb
,struct fdisk_iter *itr
,struct fdisk_partition **pa
);
0 on success, negative number in case of error or 1 at the end of list.
Example:
1 2 3 |
while(fdisk_table_next_partition(tb, itr, &pa) == 0) { ... } |
int fdisk_table_remove_partition (struct fdisk_table *tb
,struct fdisk_partition *pa
);
Removes the pa
from the table and de-increment reference counter of the pa
. The
partition with zero reference counter will be deallocated. Don't forget to use
fdisk_ref_partition()
before call fdisk_table_remove_partition()
if you want
to use pa
later.
int fdisk_table_sort_partitions (struct fdisk_table *tb
,int (*cmp) (struct fdisk_partition *, struct fdisk_partition *)
);
Sort partition in the table.