struct fdisk_parttype;
struct fdisk_partition;
struct fdisk_ask;
-struct libfdisk_iter;
-struct tt;
+struct fdisk_iter;
+struct fdisk_table;
/*
* Supported partition table types (labels)
extern int fdisk_reset_table(struct fdisk_table *tb);
extern void fdisk_ref_table(struct fdisk_table *tb);
extern void fdisk_unref_table(struct fdisk_table *tb);
+extern int fdisk_table_get_nents(struct fdisk_table *tb);
extern int fdisk_table_is_empty(struct fdisk_table *tb);
extern int fdisk_table_add_partition(struct fdisk_table *tb, struct fdisk_partition *pa);
extern int fdisk_table_remove_partition(struct fdisk_table *tb, struct fdisk_partition *pa);
struct fdisk_context *cxt,
int *cols, size_t ncols, char **data);
+extern int fdisk_table_next_partition(
+ struct fdisk_table *tb,
+ struct fdisk_iter *itr,
+ struct fdisk_partition **pa);
/* alignment.c */
extern int fdisk_reset_alignment(struct fdisk_context *cxt);
extern int fdisk_reset_device_properties(struct fdisk_context *cxt);
fdisk_table_remove_partition(tb, pa);
}
+ tb->nents = 0;
return 0;
}
return tb == NULL || list_empty(&tb->parts) ? 1 : 0;
}
+/**
+ * fdisk_table_get_nents:
+ * @tb: pointer to tab
+ *
+ * Returns: number of entries in table.
+ */
+int fdisk_table_get_nents(struct fdisk_table *tb)
+{
+ return tb ? tb->nents : 0;
+}
/**
* fdisk_table_next_partition:
fdisk_ref_partition(pa);
list_add_tail(&pa->parts, &tb->parts);
+ tb->nents++;
DBG(TAB, dbgprint("add entry %p [start=%ju, size=%ju, freespace=%s]",
pa, pa->start, pa->size,
INIT_LIST_HEAD(&pa->parts);
fdisk_unref_partition(pa);
+ tb->nents--;
+
return 0;
}