int print_device_pt(struct fdisk_context *cxt, char *device, int warnme, int verify) { if (fdisk_assign_device(cxt, device, 1) != 0) { /* read-only */ if (warnme || errno == EACCES) warn(_("cannot open %s"), device); return -1; } list_disk_geometry(cxt); if (fdisk_has_label(cxt)) { list_disklabel(cxt); if (verify) fdisk_verify_disklabel(cxt); } fdisk_deassign_device(cxt, 1); return 0; }
static int verify_device(struct sfdisk *sf, const char *devname) { int rc = 1; fdisk_enable_listonly(sf->cxt, 1); if (fdisk_assign_device(sf->cxt, devname, 1)) { warn(_("cannot open %s"), devname); return 1; } color_scheme_enable("header", UL_COLOR_BOLD); fdisk_info(sf->cxt, "%s:", devname); color_disable(); if (!fdisk_has_label(sf->cxt)) fdisk_info(sf->cxt, _("unrecognized partition table type")); else rc = fdisk_verify_disklabel(sf->cxt); fdisk_deassign_device(sf->cxt, 1); return rc; }