libfdisk: add geometry to API, cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
57c83d63e4
commit
1753a234a1
|
@ -252,15 +252,30 @@ int fdisk_has_label(struct fdisk_context *cxt)
|
|||
/**
|
||||
* fdisk_is_labeltype:
|
||||
* @cxt: fdisk context
|
||||
* @l: FDISK_DISKLABEL_*
|
||||
* @id: FDISK_DISKLABEL_*
|
||||
*
|
||||
* See also fdisk_is_label() macro in libfdisk.h.
|
||||
*
|
||||
* Returns: return 1 if the current label is @l
|
||||
*/
|
||||
int fdisk_is_labeltype(struct fdisk_context *cxt, enum fdisk_labeltype l)
|
||||
int fdisk_is_labeltype(struct fdisk_context *cxt, enum fdisk_labeltype id)
|
||||
{
|
||||
return cxt && fdisk_label_is_labeltype(cxt->label, l);
|
||||
assert(cxt);
|
||||
assert(cxt->label);
|
||||
|
||||
return fdisk_label_get_type(cxt->label) == id;
|
||||
}
|
||||
|
||||
/**
|
||||
* fdisk_get_parent:
|
||||
* @cxt: nested fdisk context
|
||||
*
|
||||
* Returns: pointer to parental context, or NULL
|
||||
*/
|
||||
struct fdisk_context *fdisk_get_parent(struct fdisk_context *cxt)
|
||||
{
|
||||
assert(cxt);
|
||||
return cxt->parent;
|
||||
}
|
||||
|
||||
static void reset_context(struct fdisk_context *cxt)
|
||||
|
@ -644,7 +659,7 @@ unsigned long fdisk_get_optimal_iosize(struct fdisk_context *cxt)
|
|||
*
|
||||
* Returns: minimal I/O size
|
||||
*/
|
||||
unsigned long fdisk_get_minimal_size(struct fdisk_context *cxt)
|
||||
unsigned long fdisk_get_minimal_iosize(struct fdisk_context *cxt)
|
||||
{
|
||||
assert(cxt);
|
||||
return cxt->min_io_size;
|
||||
|
@ -734,6 +749,53 @@ const char *fdisk_get_devname(struct fdisk_context *cxt)
|
|||
return cxt->dev_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* fdisk_get_devfd:
|
||||
* @cxt: context
|
||||
*
|
||||
* Retruns: device file descriptor.
|
||||
*/
|
||||
int fdisk_get_devfd(struct fdisk_context *cxt)
|
||||
{
|
||||
assert(cxt);
|
||||
return cxt->dev_fd;
|
||||
}
|
||||
|
||||
/**
|
||||
* fdisk_get_geom_heads:
|
||||
* @cxt: context
|
||||
*
|
||||
* Returns: number of geometry heads.
|
||||
*/
|
||||
unsigned int fdisk_get_geom_heads(struct fdisk_context *cxt)
|
||||
{
|
||||
assert(cxt);
|
||||
return cxt->geom.heads;
|
||||
}
|
||||
/**
|
||||
* fdisk_get_geom_sectors:
|
||||
* @cxt: context
|
||||
*
|
||||
* Returns: number of geometry sectors.
|
||||
*/
|
||||
sector_t fdisk_get_geom_sectors(struct fdisk_context *cxt)
|
||||
{
|
||||
assert(cxt);
|
||||
return cxt->geom.sectors;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* fdisk_get_geom_cylinders:
|
||||
* @cxt: context
|
||||
*
|
||||
* Returns: number of geometry cylinders
|
||||
*/
|
||||
sector_t fdisk_get_geom_cylinders(struct fdisk_context *cxt)
|
||||
{
|
||||
assert(cxt);
|
||||
return cxt->geom.cylinders;
|
||||
}
|
||||
|
||||
int fdisk_missing_geometry(struct fdisk_context *cxt)
|
||||
{
|
||||
|
|
|
@ -73,13 +73,12 @@ const char *fdisk_label_get_name(struct fdisk_label *lb)
|
|||
/**
|
||||
* fdisk_label_is_labeltype:
|
||||
* @lb: label
|
||||
* @id: FDISK_DISKLABEL_*
|
||||
*
|
||||
* Returns: 1 if the label type matches with id.
|
||||
* Returns: FDISK_DISKLABEL_*.
|
||||
*/
|
||||
int fdisk_label_is_labeltype(struct fdisk_label *lb, enum fdisk_labeltype id)
|
||||
int fdisk_label_get_type(struct fdisk_label *lb)
|
||||
{
|
||||
return lb && lb->id == id;
|
||||
return lb->id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -80,6 +80,8 @@ struct fdisk_context *fdisk_new_context(void);
|
|||
struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent, const char *name);
|
||||
void fdisk_free_context(struct fdisk_context *cxt);
|
||||
|
||||
struct fdisk_context *fdisk_get_parent(struct fdisk_context *cxt);
|
||||
|
||||
struct fdisk_label *fdisk_get_label(struct fdisk_context *cxt, const char *name);
|
||||
int fdisk_next_label(struct fdisk_context *cxt, struct fdisk_label **lb);
|
||||
size_t fdisk_get_nlabels(struct fdisk_context *cxt);
|
||||
|
@ -111,7 +113,7 @@ int fdisk_use_cylinders(struct fdisk_context *cxt);
|
|||
unsigned int fdisk_get_units_per_sector(struct fdisk_context *cxt);
|
||||
|
||||
unsigned long fdisk_get_optimal_iosize(struct fdisk_context *cxt);
|
||||
unsigned long fdisk_get_minimal_size(struct fdisk_context *cxt);
|
||||
unsigned long fdisk_get_minimal_iosize(struct fdisk_context *cxt);
|
||||
unsigned long fdisk_get_physector_size(struct fdisk_context *cxt);
|
||||
unsigned long fdisk_get_sector_size(struct fdisk_context *cxt);
|
||||
unsigned long fdisk_get_alignment_offset(struct fdisk_context *cxt);
|
||||
|
@ -119,6 +121,11 @@ unsigned long fdisk_get_grain_size(struct fdisk_context *cxt);
|
|||
sector_t fdisk_get_first_lba(struct fdisk_context *cxt);
|
||||
sector_t fdisk_get_nsectors(struct fdisk_context *cxt);
|
||||
const char *fdisk_get_devname(struct fdisk_context *cxt);
|
||||
int fdisk_get_devfd(struct fdisk_context *cxt);
|
||||
|
||||
unsigned int fdisk_get_geom_heads(struct fdisk_context *cxt);
|
||||
sector_t fdisk_get_geom_sectors(struct fdisk_context *cxt);
|
||||
sector_t fdisk_get_geom_cylinders(struct fdisk_context *cxt);
|
||||
|
||||
/* parttype.c */
|
||||
const struct fdisk_parttype *fdisk_label_get_parttype(struct fdisk_label *lb, size_t n);
|
||||
|
@ -169,7 +176,7 @@ enum {
|
|||
FDISK_FIELD_UUID,
|
||||
};
|
||||
|
||||
int fdisk_label_is_labeltype(struct fdisk_label *lb, enum fdisk_labeltype id);
|
||||
int fdisk_label_get_type(struct fdisk_label *lb);
|
||||
const char *fdisk_label_get_name(struct fdisk_label *lb);
|
||||
int fdisk_label_require_geometry(struct fdisk_label *lb);
|
||||
|
||||
|
|
Loading…
Reference in New Issue