diff options
author | Karel Zak | 2014-08-13 22:26:53 +0200 |
---|---|---|
committer | Karel Zak | 2014-08-13 22:26:53 +0200 |
commit | 6a6321360deaf2661d3a826e3e077d1fced416db (patch) | |
tree | debb5653ea6e4791fba9510570966a1667ab4691 /disk-utils | |
parent | cfdisk: add libfdisk independent debug stuff (diff) | |
download | kernel-qcow2-util-linux-6a6321360deaf2661d3a826e3e077d1fced416db.tar.gz kernel-qcow2-util-linux-6a6321360deaf2661d3a826e3e077d1fced416db.tar.xz kernel-qcow2-util-linux-6a6321360deaf2661d3a826e3e077d1fced416db.zip |
libfdisk: clean up API (context.c)
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils')
-rw-r--r-- | disk-utils/cfdisk.c | 20 | ||||
-rw-r--r-- | disk-utils/fdisk-menu.c | 30 | ||||
-rw-r--r-- | disk-utils/fdisk.c | 28 |
3 files changed, 39 insertions, 39 deletions
diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c index 144479857..584ea9fdb 100644 --- a/disk-utils/cfdisk.c +++ b/disk-utils/cfdisk.c @@ -276,7 +276,7 @@ static char *table_to_string(struct cfdisk *cf, struct fdisk_table *tb) assert(cf->fields); assert(tb); - lb = fdisk_context_get_label(cf->cxt, NULL); + lb = fdisk_get_label(cf->cxt, NULL); assert(lb); itr = fdisk_new_iter(FDISK_ITER_FORWARD); @@ -1600,10 +1600,10 @@ static int ui_create_label(struct cfdisk *cf) /* create cfdisk menu according to libfdisk labels, note that the * last cm[] item has to be empty -- so nitems + 1 */ - nitems = fdisk_context_get_nlabels(cf->cxt); + nitems = fdisk_get_nlabels(cf->cxt); cm = xcalloc(nitems + 1, sizeof(struct cfdisk_menuitem)); - while (fdisk_context_next_label(cf->cxt, &lb) == 0) { + while (fdisk_next_label(cf->cxt, &lb) == 0) { if (fdisk_label_is_disabled(lb) || strcmp(lb->name, "bsd") == 0) continue; cm[i++].name = lb->name; @@ -1721,7 +1721,7 @@ static int main_menu_ignore_keys(struct cfdisk *cf, char *ignore, if (!cf->wrong_order) ignore[i++] = 's'; - if (fdisk_context_is_readonly(cf->cxt)) + if (fdisk_is_readonly(cf->cxt)) ignore[i++] = 'W'; return i; } @@ -1849,7 +1849,7 @@ static int main_menu_action(struct cfdisk *cf, int key) char buf[64] = { 0 }; int rc; - if (fdisk_context_is_readonly(cf->cxt)) { + if (fdisk_is_readonly(cf->cxt)) { warn = _("Device open in read-only mode"); break; } @@ -1931,7 +1931,7 @@ static int ui_run(struct cfdisk *cf) if (rc) return rc; - if (fdisk_context_is_readonly(cf->cxt)) + if (fdisk_is_readonly(cf->cxt)) ui_warnx(_("Device open in read-only mode.")); do { @@ -2066,7 +2066,7 @@ int main(int argc, char *argv[]) if (!cf->cxt) err(EXIT_FAILURE, _("failed to allocate libfdisk context")); - fdisk_context_set_ask(cf->cxt, ask_callback, (void *) cf); + fdisk_set_ask(cf->cxt, ask_callback, (void *) cf); if (optind == argc) diskpath = access(DEFAULT_DEVICE, F_OK) == 0 ? @@ -2074,9 +2074,9 @@ int main(int argc, char *argv[]) else diskpath = argv[optind]; - rc = fdisk_context_assign_device(cf->cxt, diskpath, 0); + rc = fdisk_assign_device(cf->cxt, diskpath, 0); if (rc == -EACCES) - rc = fdisk_context_assign_device(cf->cxt, diskpath, 1); + rc = fdisk_assign_device(cf->cxt, diskpath, 1); if (rc != 0) err(EXIT_FAILURE, _("cannot open %s"), optind == argc ? DEFAULT_DEVICE : diskpath); @@ -2090,7 +2090,7 @@ int main(int argc, char *argv[]) free(cf->linesbuf); fdisk_unref_table(cf->table); - rc = fdisk_context_deassign_device(cf->cxt, cf->nwrites == 0); + rc = fdisk_deassign_device(cf->cxt, cf->nwrites == 0); fdisk_free_context(cf->cxt); DBG(MISC, ul_debug("bye! [rc=%d]", rc)); return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/disk-utils/fdisk-menu.c b/disk-utils/fdisk-menu.c index f8ae95de2..72f8bbb08 100644 --- a/disk-utils/fdisk-menu.c +++ b/disk-utils/fdisk-menu.c @@ -277,11 +277,11 @@ static const struct menu_entry *next_menu_entry( /* entry wanted for specified labels only */ (e->label && cxt->label && !(e->label & cxt->label->id)) || /* exclude non-expert entries in expect mode */ - (e->expert == 0 && fdisk_context_display_details(cxt)) || + (e->expert == 0 && fdisk_is_details(cxt)) || /* nested only */ (e->parent && (!cxt->parent || cxt->parent->label->id != e->parent)) || /* exclude non-normal entries in normal mode */ - (e->normal == 0 && !fdisk_context_display_details(cxt))) { + (e->normal == 0 && !fdisk_is_details(cxt))) { mc->entry_idx++; continue; @@ -348,7 +348,7 @@ static int print_fdisk_menu(struct fdisk_context *cxt) ON_DBG(FRONTEND, menu_detect_collisions(cxt)); - if (fdisk_context_display_details(cxt)) + if (fdisk_is_details(cxt)) printf(_("\nHelp (expert commands):\n")); else printf(_("\nHelp:\n")); @@ -396,7 +396,7 @@ int process_fdisk_menu(struct fdisk_context **cxt0) const char *prompt; char buf[BUFSIZ]; - if (fdisk_context_display_details(cxt)) + if (fdisk_is_details(cxt)) prompt = _("Expert command (m for help): "); else prompt = _("Command (m for help): "); @@ -447,7 +447,7 @@ static int generic_menu_cb(struct fdisk_context **cxt0, list_disklabel(cxt); break; case 'w': - if (fdisk_context_is_readonly(cxt)) { + if (fdisk_is_readonly(cxt)) { fdisk_warnx(cxt, _("Device open in read-only mode.")); break; } @@ -459,7 +459,7 @@ static int generic_menu_cb(struct fdisk_context **cxt0, fdisk_info(cxt, _("The partition table has been altered.")); rc = fdisk_reread_partition_table(cxt); if (!rc) - rc = fdisk_context_deassign_device(cxt, 0); + rc = fdisk_deassign_device(cxt, 0); /* fallthrough */ case 'q': fdisk_free_context(cxt); @@ -486,7 +486,7 @@ static int generic_menu_cb(struct fdisk_context **cxt0, rc = fdisk_reorder_partitions(cxt); break; case 'r': - rc = fdisk_context_enable_details(cxt, 0); + rc = fdisk_enable_details(cxt, 0); break; } return rc; @@ -513,16 +513,16 @@ static int generic_menu_cb(struct fdisk_context **cxt0, change_partition_type(cxt); break; case 'u': - fdisk_context_set_unit(cxt, - fdisk_context_use_cylinders(cxt) ? "sectors" : + fdisk_set_unit(cxt, + fdisk_use_cylinders(cxt) ? "sectors" : "cylinders"); - if (fdisk_context_use_cylinders(cxt)) + if (fdisk_use_cylinders(cxt)) fdisk_info(cxt, _("Changing display/entry units to cylinders (DEPRECATED!).")); else fdisk_info(cxt, _("Changing display/entry units to sectors.")); break; case 'x': - fdisk_context_enable_details(cxt, 1); + fdisk_enable_details(cxt, 1); break; case 'r': /* return from nested BSD to DOS */ @@ -568,7 +568,7 @@ static int gpt_menu_cb(struct fdisk_context **cxt0, if (!mbr) return -ENOMEM; *cxt0 = cxt = mbr; - fdisk_context_enable_details(cxt, 1); /* keep us in expert mode */ + fdisk_enable_details(cxt, 1); /* keep us in expert mode */ fdisk_sinfo(cxt, FDISK_INFO_SUCCESS, _("Entering protective/hybrid MBR disklabel.")); return 0; @@ -796,11 +796,11 @@ static int bsd_menu_cb(struct fdisk_context **cxt0, rc = fdisk_bsd_write_bootstrap(cxt); break; case 's': - org = fdisk_context_display_details(cxt); + org = fdisk_is_details(cxt); - fdisk_context_enable_details(cxt, 1); + fdisk_enable_details(cxt, 1); list_disklabel(cxt); - fdisk_context_enable_details(cxt, org); + fdisk_enable_details(cxt, org); break; case 'x': rc = fdisk_bsd_link_partition(cxt); diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index 1dd7ed8a9..1af07234d 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -446,7 +446,7 @@ void list_partition_types(struct fdisk_context *cxt) void toggle_dos_compatibility_flag(struct fdisk_context *cxt) { - struct fdisk_label *lb = fdisk_context_get_label(cxt, "dos"); + struct fdisk_label *lb = fdisk_get_label(cxt, "dos"); int flag; if (!lb) @@ -512,15 +512,15 @@ void list_disk_geometry(struct fdisk_context *cxt) bytes, (uintmax_t) cxt->total_sectors); free(strsz); - if (fdisk_require_geometry(cxt) || fdisk_context_use_cylinders(cxt)) + if (fdisk_require_geometry(cxt) || fdisk_use_cylinders(cxt)) fdisk_info(cxt, _("Geometry: %d heads, %llu sectors/track, %llu cylinders"), cxt->geom.heads, cxt->geom.sectors, cxt->geom.cylinders); fdisk_info(cxt, _("Units: %s of %d * %ld = %ld bytes"), - fdisk_context_get_unit(cxt, PLURAL), - fdisk_context_get_units_per_sector(cxt), + fdisk_get_unit(cxt, PLURAL), + fdisk_get_units_per_sector(cxt), cxt->sector_size, - fdisk_context_get_units_per_sector(cxt) * cxt->sector_size); + fdisk_get_units_per_sector(cxt) * cxt->sector_size); fdisk_info(cxt, _("Sector size (logical/physical): %lu bytes / %lu bytes"), cxt->sector_size, cxt->phy_sector_size); @@ -738,7 +738,7 @@ static int is_ide_cdrom_or_tape(char *device) static void print_device_pt(struct fdisk_context *cxt, char *device, int warnme) { - if (fdisk_context_assign_device(cxt, device, 1) != 0) { /* read-only */ + if (fdisk_assign_device(cxt, device, 1) != 0) { /* read-only */ if (warnme || errno == EACCES) warn(_("cannot open %s"), device); return; @@ -875,7 +875,7 @@ int main(int argc, char **argv) if (!cxt) err(EXIT_FAILURE, _("failed to allocate libfdisk context")); - fdisk_context_set_ask(cxt, ask_callback, NULL); + fdisk_set_ask(cxt, ask_callback, NULL); while ((c = getopt_long(argc, argv, "b:c::C:hH:lL::sS:t:u::vV", longopts, NULL)) != -1) { @@ -901,7 +901,7 @@ int main(int argc, char **argv) * actively used label */ char *p = *optarg == '=' ? optarg + 1 : optarg; - struct fdisk_label *lb = fdisk_context_get_label(cxt, "dos"); + struct fdisk_label *lb = fdisk_get_label(cxt, "dos"); if (!lb) err(EXIT_FAILURE, _("not found DOS label driver")); @@ -942,10 +942,10 @@ int main(int argc, char **argv) { struct fdisk_label *lb = NULL; - while (fdisk_context_next_label(cxt, &lb) == 0) + while (fdisk_next_label(cxt, &lb) == 0) fdisk_label_set_disabled(lb, 1); - lb = fdisk_context_get_label(cxt, optarg); + lb = fdisk_get_label(cxt, optarg); if (!lb) errx(EXIT_FAILURE, _("unsupported disklabel: %s"), optarg); fdisk_label_set_disabled(lb, 0); @@ -953,7 +953,7 @@ int main(int argc, char **argv) case 'u': if (optarg && *optarg == '=') optarg++; - if (fdisk_context_set_unit(cxt, optarg) != 0) + if (fdisk_set_unit(cxt, optarg) != 0) usage(stderr); break; case 'V': /* preferred for util-linux */ @@ -975,7 +975,7 @@ int main(int argc, char **argv) switch (act) { case ACT_LIST: - fdisk_context_enable_listonly(cxt, 1); + fdisk_enable_listonly(cxt, 1); if (argc > optind) { int k; @@ -1009,9 +1009,9 @@ int main(int argc, char **argv) fdisk_info(cxt, _("Changes will remain in memory only, until you decide to write them.\n" "Be careful before using the write command.\n")); - rc = fdisk_context_assign_device(cxt, argv[optind], 0); + rc = fdisk_assign_device(cxt, argv[optind], 0); if (rc == -EACCES) { - rc = fdisk_context_assign_device(cxt, argv[optind], 1); + rc = fdisk_assign_device(cxt, argv[optind], 1); if (rc == 0) fdisk_warnx(cxt, _("Device open in read-only mode.")); } |