+static int
+get_mbr_id (const char *dev, const char *parent_name)
+{
+ char *parttype = NULL;
+ int mbr_id = -1, partnum;
+
+ DISABLE_GUESTFS_ERRORS_FOR (
+ parttype = guestfs_part_get_parttype (g, parent_name);
+ );
+
+ if (parttype && STREQ (parttype, "msdos")) {
+ DISABLE_GUESTFS_ERRORS_FOR (
+ partnum = guestfs_part_to_partnum (g, dev);
+ );
+ if (partnum >= 0) {
+ DISABLE_GUESTFS_ERRORS_FOR (
+ mbr_id = guestfs_part_get_mbr_id (g, parent_name, partnum);
+ );
+ }
+ }
+
+ free (parttype);
+
+ return mbr_id;
+}
+