libfdisk: add fdisk_locate_disklabel()
The function returns offset and size of disklabel elements. Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
513d546289
commit
c0d20aae6f
|
@ -148,6 +148,9 @@ struct fdisk_label_operations {
|
|||
int (*create)(struct fdisk_context *cxt);
|
||||
/* list partition table */
|
||||
int (*list)(struct fdisk_context *cxt);
|
||||
/* returns offset and size of the 'n' part of the PT */
|
||||
int (*locate)(struct fdisk_context *cxt, int n, const char **name, off_t *offset, size_t *size);
|
||||
|
||||
/* get disk label ID */
|
||||
int (*get_id)(struct fdisk_context *cxt, char **id);
|
||||
/* set disk label ID */
|
||||
|
|
|
@ -245,6 +245,20 @@ int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name)
|
|||
return cxt->label->op->create(cxt);
|
||||
}
|
||||
|
||||
|
||||
int fdisk_locate_disklabel(struct fdisk_context *cxt, int n, const char **name,
|
||||
off_t *offset, size_t *size)
|
||||
{
|
||||
if (!cxt || !cxt->label)
|
||||
return -EINVAL;
|
||||
if (!cxt->label->op->locate)
|
||||
return -ENOSYS;
|
||||
|
||||
DBG(LABEL, dbgprint("locating %d chunk of %s.", n, cxt->label->name));
|
||||
return cxt->label->op->locate(cxt, n, name, offset, size);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* fdisk_get_disklabel_id:
|
||||
* @cxt: fdisk context
|
||||
|
|
|
@ -127,6 +127,7 @@ extern int fdisk_write_disklabel(struct fdisk_context *cxt);
|
|||
extern int fdisk_verify_disklabel(struct fdisk_context *cxt);
|
||||
extern int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name);
|
||||
extern int fdisk_list_disklabel(struct fdisk_context *cxt);
|
||||
extern int fdisk_locate_disklabel(struct fdisk_context *cxt, int n, const char **name, off_t *offset, size_t *size);
|
||||
|
||||
extern int fdisk_get_disklabel_id(struct fdisk_context *cxt, char **id);
|
||||
extern int fdisk_set_disklabel_id(struct fdisk_context *cxt);
|
||||
|
|
Loading…
Reference in New Issue