summaryrefslogtreecommitdiffstats
path: root/fdisks/fdiskdoslabel.c
diff options
context:
space:
mode:
authorKarel Zak2013-06-25 14:40:34 +0200
committerKarel Zak2013-09-16 16:47:03 +0200
commit21fe3dde849c59a54641f43cbea2eafdf4d07acf (patch)
tree8837f15625af39295e75e6a2b006e7d881717fcb /fdisks/fdiskdoslabel.c
parentfdisk: (gpt) enlarge columns in list output (diff)
downloadkernel-qcow2-util-linux-21fe3dde849c59a54641f43cbea2eafdf4d07acf.tar.gz
kernel-qcow2-util-linux-21fe3dde849c59a54641f43cbea2eafdf4d07acf.tar.xz
kernel-qcow2-util-linux-21fe3dde849c59a54641f43cbea2eafdf4d07acf.zip
libfdisk: add generic function to get disklabel ID
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/fdiskdoslabel.c')
-rw-r--r--fdisks/fdiskdoslabel.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/fdisks/fdiskdoslabel.c b/fdisks/fdiskdoslabel.c
index 40656c4dc..023fbbdb1 100644
--- a/fdisks/fdiskdoslabel.c
+++ b/fdisks/fdiskdoslabel.c
@@ -438,10 +438,20 @@ static void read_extended(struct fdisk_context *cxt, int ext)
}
}
-void dos_print_mbr_id(struct fdisk_context *cxt)
+static int dos_get_disklabel_id(struct fdisk_context *cxt, char **id)
{
- fdisk_info(cxt, _("Disk identifier: 0x%08x"),
- mbr_get_id(cxt->firstsector));
+ unsigned int num;
+
+ assert(cxt);
+ assert(id);
+ assert(cxt->label);
+ assert(fdisk_is_disklabel(cxt, DOS));
+
+ num = mbr_get_id(cxt->firstsector);
+ if (asprintf(id, "0x%08x", num) > 0)
+ return 0;
+
+ return -ENOMEM;
}
static int dos_create_disklabel(struct fdisk_context *cxt)
@@ -1797,6 +1807,7 @@ static const struct fdisk_label_operations dos_operations =
.verify = dos_verify_disklabel,
.create = dos_create_disklabel,
.list = dos_list_disklabel,
+ .get_id = dos_get_disklabel_id,
.part_add = dos_add_partition,
.part_delete = dos_delete_partition,