int fdisk_missing_geometry(struct fdisk_context *cxt) { int rc; 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; }
void list_disk_geometry(struct fdisk_context *cxt) { char *id = NULL; struct fdisk_label *lb = fdisk_get_label(cxt, NULL); uint64_t bytes = fdisk_get_nsectors(cxt) * fdisk_get_sector_size(cxt); char *strsz = size_to_human_string(SIZE_SUFFIX_SPACE | SIZE_SUFFIX_3LETTER, bytes); color_scheme_enable("header", UL_COLOR_BOLD); fdisk_info(cxt, _("Disk %s: %s, %ju bytes, %ju sectors"), fdisk_get_devname(cxt), strsz, bytes, (uintmax_t) fdisk_get_nsectors(cxt)); color_disable(); free(strsz); if (lb && (fdisk_label_require_geometry(lb) || fdisk_use_cylinders(cxt))) fdisk_info(cxt, _("Geometry: %d heads, %llu sectors/track, %llu cylinders"), fdisk_get_geom_heads(cxt), fdisk_get_geom_sectors(cxt), fdisk_get_geom_cylinders(cxt)); fdisk_info(cxt, _("Units: %s of %d * %ld = %ld bytes"), fdisk_get_unit(cxt, FDISK_PLURAL), fdisk_get_units_per_sector(cxt), fdisk_get_sector_size(cxt), fdisk_get_units_per_sector(cxt) * fdisk_get_sector_size(cxt)); fdisk_info(cxt, _("Sector size (logical/physical): %lu bytes / %lu bytes"), fdisk_get_sector_size(cxt), fdisk_get_physector_size(cxt)); fdisk_info(cxt, _("I/O size (minimum/optimal): %lu bytes / %lu bytes"), fdisk_get_minimal_iosize(cxt), fdisk_get_optimal_iosize(cxt)); if (fdisk_get_alignment_offset(cxt)) fdisk_info(cxt, _("Alignment offset: %lu bytes"), fdisk_get_alignment_offset(cxt)); if (fdisk_has_label(cxt)) fdisk_info(cxt, _("Disklabel type: %s"), fdisk_label_get_name(lb)); if (fdisk_get_disklabel_id(cxt, &id) == 0 && id) fdisk_info(cxt, _("Disk identifier: %s"), id); }