]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: add fdisk_locate_disklabel()
authorKarel Zak <kzak@redhat.com>
Tue, 3 Sep 2013 15:35:15 +0000 (17:35 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Sep 2013 14:47:09 +0000 (16:47 +0200)
The function returns offset and size of disklabel elements.

Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/fdiskP.h
libfdisk/src/label.c
libfdisk/src/libfdisk.h

index 8c9fc71e07928e5611d431baf738fdb4873984fe..45a93c8c3d31f71696240e656f834ad305e579a9 100644 (file)
@@ -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 */
index 147918e032de710fae8bed039520209cc156b203..95a0abfb95ba9aa8620928b58c6e8dca989ccac4 100644 (file)
@@ -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
index 0175a8d0f412a321bb53439fb38800b0a6b7df06..7ad3560679cd5de85c047555a694dd42a313d0b1 100644 (file)
@@ -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);