void list_disk_geometry(struct fdisk_context *cxt)
{
char *id = NULL;
+ struct fdisk_label *lb = fdisk_get_label(cxt, NULL);
uint64_t bytes = cxt->total_sectors * cxt->sector_size;
char *strsz = size_to_human_string(SIZE_SUFFIX_SPACE
| SIZE_SUFFIX_3LETTER, bytes);
bytes, (uintmax_t) cxt->total_sectors);
free(strsz);
- if (fdisk_require_geometry(cxt) || fdisk_use_cylinders(cxt))
+ if (fdisk_label_require_geometry(lb) || fdisk_use_cylinders(cxt))
fdisk_info(cxt, _("Geometry: %d heads, %llu sectors/track, %llu cylinders"),
cxt->geom.heads, cxt->geom.sectors, cxt->geom.cylinders);
}
+int fdisk_missing_geometry(struct fdisk_context *cxt)
+{
+ int rc;
+
+ assert(cxt);
+
+ if (!cxt || !cxt->label)
+ return 0;
+
+ rc = (fdisk_label_require_geometry(cxt->label) &&
+ (!cxt->geom.heads || !cxt->geom.sectors
+ || !cxt->geom.cylinders));
+
+ if (rc && !fdisk_is_listonly(cxt))
+ fdisk_warnx(cxt, _("Incomplete geometry setting."));
+
+ return rc;
+}
/* context.c */
extern int __fdisk_switch_label(struct fdisk_context *cxt,
struct fdisk_label *lb);
+extern int fdisk_missing_geometry(struct fdisk_context *cxt);
/* alignment.c */
sector_t fdisk_scround(struct fdisk_context *cxt, sector_t num);
return lb ? lb->name : NULL;
}
+/**
+ * fdisk_label_require_geometry:
+ * @lb: label
+ *
+ * Returns: 1 if label requires CHS geometry
+ */
+int fdisk_label_require_geometry(struct fdisk_label *lb)
+{
+ assert(lb);
+
+ return lb->flags & FDISK_LABEL_FL_REQUIRE_GEOMETRY ? 1 : 0;
+}
+
/**
* fdisk_write_disklabel:
return cxt->label->op->write(cxt);
}
-int fdisk_require_geometry(struct fdisk_context *cxt)
-{
- assert(cxt);
-
- return cxt->label
- && cxt->label->flags & FDISK_LABEL_FL_REQUIRE_GEOMETRY ? 1 : 0;
-}
-
-int fdisk_missing_geometry(struct fdisk_context *cxt)
-{
- int rc;
-
- assert(cxt);
-
- rc = (fdisk_require_geometry(cxt) &&
- (!cxt->geom.heads || !cxt->geom.sectors
- || !cxt->geom.cylinders));
-
- if (rc && !fdisk_is_listonly(cxt))
- fdisk_warnx(cxt, _("Incomplete geometry setting."));
-
- return rc;
-}
/**
* fdisk_get_fields:
};
const char *fdisk_label_get_name(struct fdisk_label *lb);
-
-extern int fdisk_require_geometry(struct fdisk_context *cxt);
-extern int fdisk_missing_geometry(struct fdisk_context *cxt);
+int fdisk_label_require_geometry(struct fdisk_label *lb);
extern int fdisk_write_disklabel(struct fdisk_context *cxt);