static void backup_partition_table(struct sfdisk *sf, const char *devname) { const char *name; char *tpl; uint64_t offset = 0; size_t size = 0; int i = 0; assert(sf); if (!fdisk_has_label(sf->cxt)) return; if (!sf->backup_file) { /* initialize default backup filename */ const char *home = getenv ("HOME"); if (!home) errx(EXIT_FAILURE, _("failed to create a signature backup, $HOME undefined")); xasprintf(&tpl, "%s/sfdisk-%s-", home, basename(devname)); } else xasprintf(&tpl, "%s-%s-", sf->backup_file, basename(devname)); color_scheme_enable("header", UL_COLOR_BOLD); fdisk_info(sf->cxt, _("Backup files:")); color_disable(); while (fdisk_locate_disklabel(sf->cxt, i++, &name, &offset, &size) == 0 && size) backup_sectors(sf, tpl, name, devname, offset, size); if (!sf->quiet) fputc('\n', stdout); free(tpl); }
void dump_disklabel(struct fdisk_context *cxt) { int all = !isatty(STDOUT_FILENO); int i = 0; const char *name = NULL; off_t offset = 0; size_t size = 0; assert(cxt); assert(cxt->label); while (fdisk_locate_disklabel(cxt, i++, &name, &offset, &size) == 0 && size) dump_blkdev(cxt, name, offset, size, all); }