summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--disk-utils/cfdisk.c20
-rw-r--r--disk-utils/fdisk-menu.c30
-rw-r--r--disk-utils/fdisk.c28
-rw-r--r--libfdisk/src/alignment.c6
-rw-r--r--libfdisk/src/bsd.c20
-rw-r--r--libfdisk/src/context.c278
-rw-r--r--libfdisk/src/dos.c28
-rw-r--r--libfdisk/src/fdiskP.h10
-rw-r--r--libfdisk/src/gpt.c2
-rw-r--r--libfdisk/src/label.c20
-rw-r--r--libfdisk/src/libfdisk.h66
-rw-r--r--libfdisk/src/partition.c2
-rw-r--r--libfdisk/src/sgi.c20
-rw-r--r--libfdisk/src/sun.c26
14 files changed, 380 insertions, 176 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."));
}
diff --git a/libfdisk/src/alignment.c b/libfdisk/src/alignment.c
index 5c13027c2..8334e2ea5 100644
--- a/libfdisk/src/alignment.c
+++ b/libfdisk/src/alignment.c
@@ -496,14 +496,14 @@ int fdisk_reset_alignment(struct fdisk_context *cxt)
sector_t fdisk_scround(struct fdisk_context *cxt, sector_t num)
{
- sector_t un = fdisk_context_get_units_per_sector(cxt);
+ sector_t un = fdisk_get_units_per_sector(cxt);
return (num + un - 1) / un;
}
sector_t fdisk_cround(struct fdisk_context *cxt, sector_t num)
{
- return fdisk_context_use_cylinders(cxt) ?
- (num / fdisk_context_get_units_per_sector(cxt)) + 1 : num;
+ return fdisk_use_cylinders(cxt) ?
+ (num / fdisk_get_units_per_sector(cxt)) + 1 : num;
}
int fdisk_reread_partition_table(struct fdisk_context *cxt)
diff --git a/libfdisk/src/bsd.c b/libfdisk/src/bsd.c
index e00cec5fd..8df5707fd 100644
--- a/libfdisk/src/bsd.c
+++ b/libfdisk/src/bsd.c
@@ -228,7 +228,7 @@ static int bsd_add_partition(struct fdisk_context *cxt,
if (!ask)
return -ENOMEM;
fdisk_ask_set_query(ask,
- fdisk_context_use_cylinders(cxt) ?
+ fdisk_use_cylinders(cxt) ?
_("First cylinder") : _("First sector"));
fdisk_ask_set_type(ask, FDISK_ASKTYPE_NUMBER);
fdisk_ask_number_set_low(ask, fdisk_cround(cxt, begin));
@@ -240,7 +240,7 @@ static int bsd_add_partition(struct fdisk_context *cxt,
fdisk_free_ask(ask);
if (rc)
return rc;
- if (fdisk_context_use_cylinders(cxt))
+ if (fdisk_use_cylinders(cxt))
begin = (begin - 1) * d->d_secpercyl;
}
@@ -261,11 +261,11 @@ static int bsd_add_partition(struct fdisk_context *cxt,
return -ENOMEM;
fdisk_ask_set_type(ask, FDISK_ASKTYPE_OFFSET);
- if (fdisk_context_use_cylinders(cxt)) {
+ if (fdisk_use_cylinders(cxt)) {
fdisk_ask_set_query(ask, _("Last cylinder, +cylinders or +size{K,M,G,T,P}"));
fdisk_ask_number_set_unit(ask,
cxt->sector_size *
- fdisk_context_get_units_per_sector(cxt));
+ fdisk_get_units_per_sector(cxt));
} else {
fdisk_ask_set_query(ask, _("Last sector, +sectors or +size{K,M,G,T,P}"));
fdisk_ask_number_set_unit(ask,cxt->sector_size);
@@ -281,7 +281,7 @@ static int bsd_add_partition(struct fdisk_context *cxt,
fdisk_free_ask(ask);
if (rc)
return rc;
- if (fdisk_context_use_cylinders(cxt))
+ if (fdisk_use_cylinders(cxt))
end = end * d->d_secpercyl - 1;
}
@@ -325,14 +325,14 @@ static int bsd_create_disklabel(struct fdisk_context *cxt)
rc = bsd_initlabel(cxt);
if (!rc) {
- int org = fdisk_context_display_details(cxt);
+ int org = fdisk_is_details(cxt);
cxt->label->nparts_cur = d->d_npartitions;
cxt->label->nparts_max = BSD_MAXPARTITIONS;
- fdisk_context_enable_details(cxt, 1);
+ fdisk_enable_details(cxt, 1);
bsd_list_disklabel(cxt);
- fdisk_context_enable_details(cxt, org);
+ fdisk_enable_details(cxt, org);
}
return rc;
@@ -365,7 +365,7 @@ static int bsd_list_disklabel(struct fdisk_context *cxt)
assert(cxt->label);
assert(fdisk_is_disklabel(cxt, BSD));
- if (fdisk_context_display_details(cxt)) {
+ if (fdisk_is_details(cxt)) {
fdisk_info(cxt, "# %s:", cxt->dev_path);
if ((unsigned) d->d_type < BSD_DKMAXTYPES)
@@ -420,7 +420,7 @@ static int bsd_get_partition(struct fdisk_context *cxt, size_t n,
if (!pa->used)
return 0;
- if (fdisk_context_use_cylinders(cxt) && d->d_secpercyl) {
+ if (fdisk_use_cylinders(cxt) && d->d_secpercyl) {
pa->start_post = p->p_offset % d->d_secpercyl ? '*' : ' ';
pa->end_post = (p->p_offset + p->p_size) % d->d_secpercyl ? '*' : ' ';
}
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c
index 61a6ce30a..46f5866fe 100644
--- a/libfdisk/src/context.c
+++ b/libfdisk/src/context.c
@@ -4,6 +4,11 @@
#include "fdiskP.h"
+/**
+ * fdisk_new_context:
+ *
+ * Returns: newly allocated libfdisk handler
+ */
struct fdisk_context *fdisk_new_context(void)
{
struct fdisk_context *cxt;
@@ -30,6 +35,15 @@ struct fdisk_context *fdisk_new_context(void)
return cxt;
}
+/**
+ * fdisk_new_nested_context:
+ * @parent: parental context
+ * @name: optional label name (e.g. "bsd")
+ *
+ * This is supported for MBR+BSD and GPT+pMBR only.
+ *
+ * Returns: new context for nested partiton table.
+ */
struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent,
const char *name)
{
@@ -75,7 +89,7 @@ struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent,
cxt->label = lb;
if (lb->op->probe(cxt) == 1)
- __fdisk_context_switch_label(cxt, lb);
+ __fdisk_switch_label(cxt, lb);
else {
DBG(CXT, ul_debugobj(cxt, "not found %s label", lb->name));
if (lb->op->deinit)
@@ -88,10 +102,16 @@ struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent,
}
-/*
- * Returns the current label if no name specified.
+/**
+ * fdisk_get_label:
+ * @cxt: context instance
+ * @name: label name (e.g. "gpt")
+ *
+ * If no @name specified then returns the current context label.
+ *
+ * Returns: label struct or NULL in case of error.
*/
-struct fdisk_label *fdisk_context_get_label(struct fdisk_context *cxt, const char *name)
+struct fdisk_label *fdisk_get_label(struct fdisk_context *cxt, const char *name)
{
size_t i;
@@ -109,7 +129,26 @@ struct fdisk_label *fdisk_context_get_label(struct fdisk_context *cxt, const cha
return NULL;
}
-int fdisk_context_next_label(struct fdisk_context *cxt, struct fdisk_label **lb)
+/**
+ * fdisk_next_label:
+ * @cxt: context instance
+ * @lb: returns pointer to the next label
+ *
+ * <informalexample>
+ * <programlisting>
+ * // print all supported labels
+ * struct fdisk_context *cxt = fdisk_new_context();
+ * struct fdisk_label *lb = NULL;
+ *
+ * while (fdisk_next_label(cxt, &lb) == 0)
+ * print("label name: %s\n", fdisk_label_get_name(lb));
+ * fdisk_free_context(cxt);
+ * </programlisting>
+ * </informalexample>
+ *
+ * Returns: <0 in case of error, 0 on success, 1 at the end.
+ */
+int fdisk_next_label(struct fdisk_context *cxt, struct fdisk_label **lb)
{
size_t i;
struct fdisk_label *res = NULL;
@@ -132,13 +171,18 @@ int fdisk_context_next_label(struct fdisk_context *cxt, struct fdisk_label **lb)
return res ? 0 : 1;
}
-size_t fdisk_context_get_nlabels(struct fdisk_context *cxt)
+/**
+ * fdisk_get_nlabels:
+ * @cxt: context
+ *
+ * Returns: number of supported label types
+ */
+size_t fdisk_get_nlabels(struct fdisk_context *cxt)
{
return cxt ? cxt->nlabels : 0;
}
-int __fdisk_context_switch_label(struct fdisk_context *cxt,
- struct fdisk_label *lb)
+int __fdisk_switch_label(struct fdisk_context *cxt, struct fdisk_label *lb)
{
if (!lb || !cxt)
return -EINVAL;
@@ -151,10 +195,18 @@ int __fdisk_context_switch_label(struct fdisk_context *cxt,
return 0;
}
-int fdisk_context_switch_label(struct fdisk_context *cxt, const char *name)
+/**
+ * fdisk_switch_label:
+ * @cxt: context
+ * @name: label name (e.g. "gpt")
+ *
+ * Forces libfdisk to use the label driver.
+ *
+ * Returns: 0 on succes, <0 in case of error.
+ */
+int fdisk_switch_label(struct fdisk_context *cxt, const char *name)
{
- return __fdisk_context_switch_label(cxt,
- fdisk_context_get_label(cxt, name));
+ return __fdisk_switch_label(cxt, fdisk_get_label(cxt, name));
}
@@ -241,14 +293,16 @@ static int warn_wipe(struct fdisk_context *cxt)
}
/**
- * fdisk_context_assign_device:
+ * fdisk_assign_device:
* @fname: path to the device to be handled
* @readonly: how to open the device
*
+ * Open the device, discovery topology, geometry, and detect disklabel.
+ *
* Returns: 0 on success, < 0 on error.
*/
-int fdisk_context_assign_device(struct fdisk_context *cxt,
- const char *fname, int readonly)
+int fdisk_assign_device(struct fdisk_context *cxt,
+ const char *fname, int readonly)
{
int fd;
@@ -283,7 +337,7 @@ int fdisk_context_assign_device(struct fdisk_context *cxt,
/* warn about obsolete stuff on the device if we aren't in
* list-only mode and there is not PT yet */
- if (!fdisk_context_listonly(cxt) && !fdisk_dev_has_disklabel(cxt))
+ if (!fdisk_is_listonly(cxt) && !fdisk_dev_has_disklabel(cxt))
warn_wipe(cxt);
DBG(CXT, ul_debugobj(cxt, "initialized for %s [%s]",
@@ -294,7 +348,7 @@ fail:
return -errno;
}
-int fdisk_context_deassign_device(struct fdisk_context *cxt, int nosync)
+int fdisk_deassign_device(struct fdisk_context *cxt, int nosync)
{
assert(cxt);
assert(cxt->dev_fd >= 0);
@@ -316,7 +370,7 @@ int fdisk_context_deassign_device(struct fdisk_context *cxt, int nosync)
return 0;
}
-int fdisk_context_is_readonly(struct fdisk_context *cxt)
+int fdisk_is_readonly(struct fdisk_context *cxt)
{
assert(cxt);
return cxt->readonly;
@@ -352,14 +406,16 @@ void fdisk_free_context(struct fdisk_context *cxt)
}
/**
- * fdisk_context_set_ask:
+ * fdisk_set_ask:
* @cxt: context
* @ask_cb: callback
* @data: callback data
*
+ * Set callbacks for dialog driven partitioning and library warnings/errors.
+ *
* Returns: 0 on success, < 0 on error.
*/
-int fdisk_context_set_ask(struct fdisk_context *cxt,
+int fdisk_set_ask(struct fdisk_context *cxt,
int (*ask_cb)(struct fdisk_context *, struct fdisk_ask *, void *),
void *data)
{
@@ -371,57 +427,74 @@ int fdisk_context_set_ask(struct fdisk_context *cxt,
}
/**
- * fdisk_context_enable_details:
- * cxt: context
- * enable: true/flase
+ * fdisk_enable_details:
+ * @cxt: context
+ * @enable: true/flase
*
- * Enables or disables "details" display mode.
+ * Enables or disables "details" display mode. This function has effect to
+ * fdisk_partition_to_string() function.
*
* Returns: 0 on success, < 0 on error.
*/
-int fdisk_context_enable_details(struct fdisk_context *cxt, int enable)
+int fdisk_enable_details(struct fdisk_context *cxt, int enable)
{
assert(cxt);
cxt->display_details = enable ? 1 : 0;
return 0;
}
-int fdisk_context_display_details(struct fdisk_context *cxt)
+/**
+ * fdisk_is_details:
+ * @cxt: context
+ *
+ * Returns: 1 if details are enabled
+ */
+int fdisk_is_details(struct fdisk_context *cxt)
{
assert(cxt);
return cxt->display_details == 1;
}
/**
- * fdisk_context_enable_listonly:
- * cxt: context
- * enable: true/flase
+ * fdisk_enable_listonly:
+ * @cxt: context
+ * @enable: true/flase
*
* Just list partition only, don't care about another details, mistakes, ...
*
* Returns: 0 on success, < 0 on error.
*/
-int fdisk_context_enable_listonly(struct fdisk_context *cxt, int enable)
+int fdisk_enable_listonly(struct fdisk_context *cxt, int enable)
{
assert(cxt);
cxt->listonly = enable ? 1 : 0;
return 0;
}
-int fdisk_context_listonly(struct fdisk_context *cxt)
+/**
+ * fdisk_is_listonly:
+ * @cxt: context
+ *
+ * Returns: 1 if list-only mode enabled
+ */
+int fdisk_is_listonly(struct fdisk_context *cxt)
{
assert(cxt);
return cxt->listonly == 1;
}
-/*
+/**
+ * fdisk_set_unit:
+ * @cxt: context
* @str: "cylinder" or "sector".
*
* This is pure shit, unfortunately for example Sun addresses begin of the
* partition by cylinders...
+ *
+ * Returns: 0 on succes, <0 on error.
*/
-int fdisk_context_set_unit(struct fdisk_context *cxt, const char *str)
+int fdisk_set_unit(struct fdisk_context *cxt, const char *str)
{
assert(cxt);
@@ -436,35 +509,160 @@ int fdisk_context_set_unit(struct fdisk_context *cxt, const char *str)
else if (strcmp(str, "sector") == 0 || strcmp(str, "sectors") == 0)
cxt->display_in_cyl_units = 0;
- DBG(CXT, ul_debugobj(cxt, "display unit: %s", fdisk_context_get_unit(cxt, 0)));
+ DBG(CXT, ul_debugobj(cxt, "display unit: %s", fdisk_get_unit(cxt, 0)));
return 0;
}
-const char *fdisk_context_get_unit(struct fdisk_context *cxt, int n)
+/**
+ * fdisk_get_unit:
+ * @cxt: context
+ *
+ * Returns: unit name.
+ */
+const char *fdisk_get_unit(struct fdisk_context *cxt, int n)
{
assert(cxt);
- if (fdisk_context_use_cylinders(cxt))
+ if (fdisk_use_cylinders(cxt))
return P_("cylinder", "cylinders", n);
return P_("sector", "sectors", n);
}
-/* Returns 1 if user wants to display in cylinders. */
-int fdisk_context_use_cylinders(struct fdisk_context *cxt)
+/**
+ * fdisk_use_cylinders:
+ * @@cxt: context
+ *
+ * Returns 1 if user wants to display in cylinders.
+ */
+int fdisk_use_cylinders(struct fdisk_context *cxt)
{
assert(cxt);
return cxt->display_in_cyl_units == 1;
}
-/* Returns number of "units" per sector, default is 1 if display unit is sector.
+/**
+ * fdisk_get_units_per_sector:
+ * @cxt: context
+ *
+ * This is neccessary only for brain dead situations when we use "cylinders";
+ *
+ * Returns: number of "units" per sector, default is 1 if display unit is sector.
*/
-unsigned int fdisk_context_get_units_per_sector(struct fdisk_context *cxt)
+unsigned int fdisk_get_units_per_sector(struct fdisk_context *cxt)
{
assert(cxt);
- if (fdisk_context_use_cylinders(cxt)) {
+ if (fdisk_use_cylinders(cxt)) {
assert(cxt->geom.heads);
return cxt->geom.heads * cxt->geom.sectors;
}
return 1;
}
+
+/**
+ * fdisk_get_optimal_iosize:
+ * @cxt: context
+ *
+ * Returns: optimal I/O size
+ */
+unsigned long fdisk_get_optimal_iosize(struct fdisk_context *cxt)
+{
+ assert(cxt);
+ return cxt->optimal_io_size;
+}
+
+/**
+ * fdisk_get_minimal_iosize:
+ * @cxt: context
+ *
+ * Returns: minimal I/O size
+ */
+unsigned long fdisk_get_minimal_size(struct fdisk_context *cxt)
+{
+ assert(cxt);
+ return cxt->min_io_size;
+}
+
+/**
+ * fdisk_get_physector_size:
+ * @cxt: context
+ *
+ * Returns: physical sector size
+ */
+unsigned long fdisk_get_physector_size(struct fdisk_context *cxt)
+{
+ assert(cxt);
+ return cxt->phy_sector_size;
+}
+
+/**
+ * fdisk_get_sector_size:
+ * @cxt: context
+ *
+ * Returns: sector size
+ */
+unsigned long fdisk_get_sector_size(struct fdisk_context *cxt)
+{
+ assert(cxt);
+ return cxt->sector_size;
+}
+
+/**
+ * fdisk_get_alignment_offset
+ * @cxt: context
+ *
+ * Returns: alignment offset (used by 4K disks for backward compatibility with DOS tools).
+ */
+unsigned long fdisk_get_alignment_offset(struct fdisk_context *cxt)
+{
+ assert(cxt);
+ return cxt->alignment_offset;
+}
+
+/**
+ * fdisk_get_grain_size:
+ * @cxt: context
+ *
+ * Returns: usual grain used to align partitions
+ */
+unsigned long fdisk_get_grain_size(struct fdisk_context *cxt)
+{
+ assert(cxt);
+ return cxt->grain;
+}
+
+/**
+ * fdisk_get_first_lba:
+ * @cxt: context
+ *
+ * Returns: first possible LBA on disk for data partitions.
+ */
+unsigned long fdisk_get_first_lba(struct fdisk_context *cxt)
+{
+ assert(cxt);
+ return cxt->first_lba;
+}
+
+/**
+ * fdisk_get_nsectors:
+ * @cxt: context
+ *
+ * Returns: size of the device in (real) sectors.
+ */
+unsigned long fdisk_get_nsectors(struct fdisk_context *cxt)
+{
+ assert(cxt);
+ return cxt->total_sectors;
+}
+
+/**
+ * fdisk_get_devname:
+ * @cxt: context
+ *
+ * Returns: device name.
+ */
+const char *fdisk_get_devname(struct fdisk_context *cxt)
+{
+ assert(cxt);
+ return cxt->dev_path;
+}
diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c
index 4805102c7..520d0c4f5 100644
--- a/libfdisk/src/dos.c
+++ b/libfdisk/src/dos.c
@@ -80,7 +80,7 @@ static struct fdisk_parttype dos_parttypes[] = {
#define is_dos_compatible(_x) \
(fdisk_is_disklabel(_x, DOS) && \
- fdisk_dos_is_compatible(fdisk_context_get_label(_x, NULL)))
+ fdisk_dos_is_compatible(fdisk_get_label(_x, NULL)))
#define cround(c, n) fdisk_cround(c, n)
@@ -306,7 +306,7 @@ static void dos_init(struct fdisk_context *cxt)
pe->changed = 0;
}
- if (fdisk_context_listonly(cxt))
+ if (fdisk_is_listonly(cxt))
return;
/*
* Various warnings...
@@ -324,7 +324,7 @@ static void dos_init(struct fdisk_context *cxt)
"I/O) size boundary is recommended, or performance may be impacted."));
}
- if (fdisk_context_use_cylinders(cxt))
+ if (fdisk_use_cylinders(cxt))
fdisk_warnx(cxt, _("Cylinders as display units are deprecated."));
if (cxt->total_sectors > UINT_MAX) {
@@ -892,7 +892,7 @@ static int get_start_from_user( struct fdisk_context *cxt,
if (!ask)
return -ENOMEM;
fdisk_ask_set_query(ask,
- fdisk_context_use_cylinders(cxt) ?
+ fdisk_use_cylinders(cxt) ?
_("First cylinder") : _("First sector"));
fdisk_ask_set_type(ask, FDISK_ASKTYPE_NUMBER);
fdisk_ask_number_set_low(ask, fdisk_cround(cxt, low));
@@ -904,9 +904,9 @@ static int get_start_from_user( struct fdisk_context *cxt,
fdisk_free_ask(ask);
if (rc)
return rc;
- if (fdisk_context_use_cylinders(cxt)) {
+ if (fdisk_use_cylinders(cxt)) {
*start = (*start - 1)
- * fdisk_context_get_units_per_sector(cxt);
+ * fdisk_get_units_per_sector(cxt);
if (*start < low)
*start = low;
}
@@ -945,7 +945,7 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
else
start = cxt->first_lba;
- if (fdisk_context_use_cylinders(cxt) || !cxt->total_sectors)
+ if (fdisk_use_cylinders(cxt) || !cxt->total_sectors)
limit = cxt->geom.heads * cxt->geom.sectors * cxt->geom.cylinders - 1;
else
limit = cxt->total_sectors - 1;
@@ -963,10 +963,10 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
start = l->ext_offset + cxt->first_lba;
limit = get_abs_partition_end(ext_pe);
}
- if (fdisk_context_use_cylinders(cxt))
+ if (fdisk_use_cylinders(cxt))
for (i = 0; i < cxt->label->nparts_max; i++) {
first[i] = (fdisk_cround(cxt, first[i]) - 1)
- * fdisk_context_get_units_per_sector(cxt);
+ * fdisk_get_units_per_sector(cxt);
}
/*
@@ -988,7 +988,7 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
dflt = start;
if (start > limit)
break;
- if (start >= temp + fdisk_context_get_units_per_sector(cxt)
+ if (start >= temp + fdisk_get_units_per_sector(cxt)
&& read) {
fdisk_info(cxt, _("Sector %llu is already allocated."),
temp);
@@ -1048,11 +1048,11 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
return -ENOMEM;
fdisk_ask_set_type(ask, FDISK_ASKTYPE_OFFSET);
- if (fdisk_context_use_cylinders(cxt)) {
+ if (fdisk_use_cylinders(cxt)) {
fdisk_ask_set_query(ask, _("Last cylinder, +cylinders or +size{K,M,G,T,P}"));
fdisk_ask_number_set_unit(ask,
cxt->sector_size *
- fdisk_context_get_units_per_sector(cxt));
+ fdisk_get_units_per_sector(cxt));
} else {
fdisk_ask_set_query(ask, _("Last sector, +sectors or +size{K,M,G,T,P}"));
fdisk_ask_number_set_unit(ask,cxt->sector_size);
@@ -1069,8 +1069,8 @@ static int add_partition(struct fdisk_context *cxt, size_t n,
fdisk_free_ask(ask);
if (rc)
return rc;
- if (fdisk_context_use_cylinders(cxt)) {
- stop = stop * fdisk_context_get_units_per_sector(cxt) - 1;
+ if (fdisk_use_cylinders(cxt)) {
+ stop = stop * fdisk_get_units_per_sector(cxt) - 1;
if (stop >limit)
stop = limit;
}
diff --git a/libfdisk/src/fdiskP.h b/libfdisk/src/fdiskP.h
index 12457eae2..c17edb2dc 100644
--- a/libfdisk/src/fdiskP.h
+++ b/libfdisk/src/fdiskP.h
@@ -240,8 +240,8 @@ struct fdisk_field {
/* note that the defauls is to display a column always */
enum {
- FDISK_FIELDFL_DETAIL = (1 << 1), /* only display if fdisk_context_display_details() */
- FDISK_FIELDFL_EYECANDY = (1 << 2), /* don't display if fdisk_context_display_details() */
+ FDISK_FIELDFL_DETAIL = (1 << 1), /* only display if fdisk_is_details() */
+ FDISK_FIELDFL_EYECANDY = (1 << 2), /* don't display if fdisk_is_details() */
FDISK_FIELDFL_NUMBER = (1 << 3), /* column display numbers */
};
@@ -381,13 +381,9 @@ struct fdisk_context {
};
/* context.c */
-extern int __fdisk_context_switch_label(struct fdisk_context *cxt,
+extern int __fdisk_switch_label(struct fdisk_context *cxt,
struct fdisk_label *lb);
-extern int fdisk_context_enable_listonly(struct fdisk_context *cxt, int enable);
-extern int fdisk_context_listonly(struct fdisk_context *cxt);
-
-
/* alignment.c */
extern sector_t fdisk_scround(struct fdisk_context *cxt, sector_t num);
extern sector_t fdisk_cround(struct fdisk_context *cxt, sector_t num);
diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c
index 0fb5ac57a..27331ca4e 100644
--- a/libfdisk/src/gpt.c
+++ b/libfdisk/src/gpt.c
@@ -1387,7 +1387,7 @@ static int gpt_list_disklabel(struct fdisk_context *cxt)
assert(cxt->label);
assert(fdisk_is_disklabel(cxt, GPT));
- if (fdisk_context_display_details(cxt)) {
+ if (fdisk_is_details(cxt)) {
struct gpt_header *h = self_label(cxt)->pheader;
fdisk_info(cxt, _("First LBA: %ju"), h->first_usable_lba);
diff --git a/libfdisk/src/label.c b/libfdisk/src/label.c
index 0abda435a..65a5cde25 100644
--- a/libfdisk/src/label.c
+++ b/libfdisk/src/label.c
@@ -2,7 +2,7 @@
#include "fdiskP.h"
/*
- * Don't use this function derectly, use fdisk_new_context_from_filename()
+ * Don't use this function derectly
*/
int fdisk_probe_labels(struct fdisk_context *cxt)
{
@@ -33,7 +33,7 @@ int fdisk_probe_labels(struct fdisk_context *cxt)
continue;
}
- __fdisk_context_switch_label(cxt, lb);
+ __fdisk_switch_label(cxt, lb);
return 0;
}
@@ -100,7 +100,7 @@ int fdisk_missing_geometry(struct fdisk_context *cxt)
(!cxt->geom.heads || !cxt->geom.sectors
|| !cxt->geom.cylinders));
- if (rc && !fdisk_context_listonly(cxt))
+ if (rc && !fdisk_is_listonly(cxt))
fdisk_warnx(cxt, _("Incomplete geometry setting."));
return rc;
@@ -115,7 +115,7 @@ int fdisk_missing_geometry(struct fdisk_context *cxt)
*
* This function returns the default or all fields for the current label.
* Note that the set of the default fields depends on
- * fdisk_context_enable_details() function. If the details are enabled then
+ * fdisk_enable_details() function. If the details are enabled then
* this function usually returns more fields.
*
* Returns 0 on success, otherwise, a corresponding error.
@@ -139,14 +139,14 @@ int fdisk_get_fields_ids(struct fdisk_context *cxt, int all,
int id = cxt->label->fields[i].id;
if (!all &&
- ((fdisk_context_display_details(cxt) &&
+ ((fdisk_is_details(cxt) &&
(cxt->label->fields[i].flags & FDISK_FIELDFL_EYECANDY))
- || (!fdisk_context_display_details(cxt) &&
+ || (!fdisk_is_details(cxt) &&
(cxt->label->fields[i].flags & FDISK_FIELDFL_DETAIL))
|| (id == FDISK_FIELD_SECTORS &&
- fdisk_context_use_cylinders(cxt))
+ fdisk_use_cylinders(cxt))
|| (id == FDISK_FIELD_CYLINDERS &&
- !fdisk_context_use_cylinders(cxt))))
+ !fdisk_use_cylinders(cxt))))
continue;
c[n++] = id;
@@ -269,13 +269,13 @@ int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name)
haslabel = 1;
}
- lb = fdisk_context_get_label(cxt, name);
+ lb = fdisk_get_label(cxt, name);
if (!lb || lb->disabled)
return -EINVAL;
if (!lb->op->create)
return -ENOSYS;
- __fdisk_context_switch_label(cxt, lb);
+ __fdisk_switch_label(cxt, lb);
if (haslabel && !cxt->parent)
fdisk_reset_device_properties(cxt);
diff --git a/libfdisk/src/libfdisk.h b/libfdisk/src/libfdisk.h
index 74e7e9957..024ba63a4 100644
--- a/libfdisk/src/libfdisk.h
+++ b/libfdisk/src/libfdisk.h
@@ -69,39 +69,49 @@ enum {
extern void fdisk_init_debug(int mask);
/* context.h */
-extern struct fdisk_context *fdisk_new_context(void);
-extern struct fdisk_context *fdisk_new_nested_context(
- struct fdisk_context *parent, const char *name);
-extern void fdisk_free_context(struct fdisk_context *cxt);
-
-extern int fdisk_context_set_ask(struct fdisk_context *cxt,
- int (*ask_cb)(struct fdisk_context *, struct fdisk_ask *, void *),
- void *data);
-
-extern int fdisk_context_is_readonly(struct fdisk_context *cxt);
-extern int fdisk_context_assign_device(struct fdisk_context *cxt,
- const char *fname, int readonly);
-extern int fdisk_context_deassign_device(struct fdisk_context *cxt, int nosync);
-
-extern struct fdisk_label *fdisk_context_get_label(struct fdisk_context *cxt,
- const char *name);
-extern int fdisk_context_next_label(struct fdisk_context *cxt, struct fdisk_label **lb);
-extern size_t fdisk_context_get_nlabels(struct fdisk_context *cxt);
-
-extern int fdisk_context_switch_label(struct fdisk_context *cxt,
- const char *name);
-
-extern int fdisk_context_set_unit(struct fdisk_context *cxt, const char *str);
#define PLURAL 0
#define SINGULAR 1
-extern const char *fdisk_context_get_unit(struct fdisk_context *cxt, int n);
-extern unsigned int fdisk_context_get_units_per_sector(struct fdisk_context *cxt);
-extern int fdisk_context_enable_details(struct fdisk_context *cxt, int enable);
-extern int fdisk_context_use_cylinders(struct fdisk_context *cxt);
-extern int fdisk_context_display_details(struct fdisk_context *cxt);
+struct fdisk_context *fdisk_new_context(void);
+struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent, const char *name);
+void fdisk_free_context(struct fdisk_context *cxt);
+
+struct fdisk_label *fdisk_get_label(struct fdisk_context *cxt, const char *name);
+int fdisk_next_label(struct fdisk_context *cxt, struct fdisk_label **lb);
+size_t fdisk_get_nlabels(struct fdisk_context *cxt);
+int fdisk_switch_label(struct fdisk_context *cxt, const char *name);
+
+int fdisk_assign_device(struct fdisk_context *cxt,
+ const char *fname, int readonly);
+int fdisk_deassign_device(struct fdisk_context *cxt, int nosync);
+int fdisk_is_readonly(struct fdisk_context *cxt);
+
+int fdisk_set_ask(struct fdisk_context *cxt,
+ int (*ask_cb)(struct fdisk_context *, struct fdisk_ask *, void *),
+ void *data);
+
+int fdisk_enable_details(struct fdisk_context *cxt, int enable);
+int fdisk_is_details(struct fdisk_context *cxt);
+
+int fdisk_enable_listonly(struct fdisk_context *cxt, int enable);
+int fdisk_is_listonly(struct fdisk_context *cxt);
+
+int fdisk_set_unit(struct fdisk_context *cxt, const char *str);
+const char *fdisk_get_unit(struct fdisk_context *cxt, int n);
+int fdisk_use_cylinders(struct fdisk_context *cxt);
+unsigned int fdisk_get_units_per_sector(struct fdisk_context *cxt);
+
+unsigned long fdisk_get_optimal_iosize(struct fdisk_context *cxt);
+unsigned long fdisk_get_minimal_size(struct fdisk_context *cxt);
+unsigned long fdisk_get_physector_size(struct fdisk_context *cxt);
+unsigned long fdisk_get_sector_size(struct fdisk_context *cxt);
+unsigned long fdisk_get_alignment_offset(struct fdisk_context *cxt);
+unsigned long fdisk_get_grain_size(struct fdisk_context *cxt);
+unsigned long fdisk_get_first_lba(struct fdisk_context *cxt);
+unsigned long fdisk_get_nsectors(struct fdisk_context *cxt);
+const char *fdisk_get_devname(struct fdisk_context *cxt);
/* parttype.c */
extern struct fdisk_parttype *fdisk_get_parttype_from_code(struct fdisk_context *cxt,
diff --git a/libfdisk/src/partition.c b/libfdisk/src/partition.c
index 24cbbc98b..3cb271cca 100644
--- a/libfdisk/src/partition.c
+++ b/libfdisk/src/partition.c
@@ -358,7 +358,7 @@ int fdisk_partition_to_string(struct fdisk_partition *pa,
{
uint64_t sz = pa->size * cxt->sector_size;
- if (fdisk_context_display_details(cxt)) {
+ if (fdisk_is_details(cxt)) {
rc = pa->size_post ?
asprintf(&p, "%ju%c", sz, pa->size_post) :
asprintf(&p, "%ju", sz);
diff --git a/libfdisk/src/sgi.c b/libfdisk/src/sgi.c
index 8f2bce8d5..83d25c558 100644
--- a/libfdisk/src/sgi.c
+++ b/libfdisk/src/sgi.c
@@ -253,7 +253,7 @@ static int sgi_list_table(struct fdisk_context *cxt)
struct sgi_device_parameter *sgiparam = &sgilabel->devparam;
int rc = 0;
- if (fdisk_context_display_details(cxt))
+ if (fdisk_is_details(cxt))
fdisk_info(cxt, _(
"Label geometry: %d heads, %llu sectors\n"
" %llu cylinders, %d physical cylinders\n"
@@ -820,7 +820,7 @@ static int sgi_add_partition(struct fdisk_context *cxt,
return -ERANGE;
} else {
snprintf(mesg, sizeof(mesg), _("First %s"),
- fdisk_context_get_unit(cxt, SINGULAR));
+ fdisk_get_unit(cxt, SINGULAR));
ask = fdisk_new_ask();
if (!ask)
return -ENOMEM;
@@ -838,8 +838,8 @@ static int sgi_add_partition(struct fdisk_context *cxt,
if (rc)
return rc;
- if (fdisk_context_use_cylinders(cxt))
- first *= fdisk_context_get_units_per_sector(cxt);
+ if (fdisk_use_cylinders(cxt))
+ first *= fdisk_get_units_per_sector(cxt);
}
if (first && sys == SGI_TYPE_ENTIRE_DISK)
@@ -859,8 +859,8 @@ static int sgi_add_partition(struct fdisk_context *cxt,
} else {
snprintf(mesg, sizeof(mesg),
_("Last %s or +%s or +size{K,M,G,T,P}"),
- fdisk_context_get_unit(cxt, SINGULAR),
- fdisk_context_get_unit(cxt, PLURAL));
+ fdisk_get_unit(cxt, SINGULAR),
+ fdisk_get_unit(cxt, PLURAL));
ask = fdisk_new_ask();
if (!ask)
@@ -874,10 +874,10 @@ static int sgi_add_partition(struct fdisk_context *cxt,
fdisk_ask_number_set_high(ask, fdisk_scround(cxt, last) - 1);/* maximal */
fdisk_ask_number_set_base(ask, fdisk_scround(cxt, first));
- if (fdisk_context_use_cylinders(cxt))
+ if (fdisk_use_cylinders(cxt))
fdisk_ask_number_set_unit(ask,
cxt->sector_size *
- fdisk_context_get_units_per_sector(cxt));
+ fdisk_get_units_per_sector(cxt));
else
fdisk_ask_number_set_unit(ask,cxt->sector_size);
@@ -887,8 +887,8 @@ static int sgi_add_partition(struct fdisk_context *cxt,
fdisk_free_ask(ask);
if (rc)
return rc;
- if (fdisk_context_use_cylinders(cxt))
- last *= fdisk_context_get_units_per_sector(cxt);
+ if (fdisk_use_cylinders(cxt))
+ last *= fdisk_get_units_per_sector(cxt);
}
if (sys == SGI_TYPE_ENTIRE_DISK
diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c
index b6390ca2d..60c4cec6d 100644
--- a/libfdisk/src/sun.c
+++ b/libfdisk/src/sun.c
@@ -525,7 +525,7 @@ static int sun_add_partition(
struct fdisk_ask *ask;
snprintf(mesg, sizeof(mesg), _("First %s"),
- fdisk_context_get_unit(cxt, SINGULAR));
+ fdisk_get_unit(cxt, SINGULAR));
for (;;) {
ask = fdisk_new_ask();
if (!ask)
@@ -549,8 +549,8 @@ static int sun_add_partition(
if (rc)
return rc;
- if (fdisk_context_use_cylinders(cxt))
- first *= fdisk_context_get_units_per_sector(cxt);
+ if (fdisk_use_cylinders(cxt))
+ first *= fdisk_get_units_per_sector(cxt);
/* ewt asks to add: "don't start a partition at cyl 0"
However, edmundo@rano.demon.co.uk writes:
@@ -584,7 +584,7 @@ static int sun_add_partition(
"third partition covers the whole disk "
"and is of type `Whole disk'"));
- if (!fdisk_context_use_cylinders(cxt)) {
+ if (!fdisk_use_cylinders(cxt)) {
/* Starting sector has to be properly aligned */
int cs = cxt->geom.heads * cxt->geom.sectors;
int x = first % cs;
@@ -620,8 +620,8 @@ static int sun_add_partition(
snprintf(mesg, sizeof(mesg),
_("Last %s or +%s or +size{K,M,G,T,P}"),
- fdisk_context_get_unit(cxt, SINGULAR),
- fdisk_context_get_unit(cxt, PLURAL));
+ fdisk_get_unit(cxt, SINGULAR),
+ fdisk_get_unit(cxt, PLURAL));
fdisk_ask_set_query(ask, mesg);
fdisk_ask_set_type(ask, FDISK_ASKTYPE_OFFSET);
@@ -642,10 +642,10 @@ static int sun_add_partition(
fdisk_ask_number_set_base(ask, fdisk_scround(cxt, first));
}
- if (fdisk_context_use_cylinders(cxt))
+ if (fdisk_use_cylinders(cxt))
fdisk_ask_number_set_unit(ask,
cxt->sector_size *
- fdisk_context_get_units_per_sector(cxt));
+ fdisk_get_units_per_sector(cxt));
else
fdisk_ask_number_set_unit(ask, cxt->sector_size);
@@ -655,8 +655,8 @@ static int sun_add_partition(
fdisk_free_ask(ask);
if (rc)
return rc;
- if (fdisk_context_use_cylinders(cxt))
- last *= fdisk_context_get_units_per_sector(cxt);
+ if (fdisk_use_cylinders(cxt))
+ last *= fdisk_get_units_per_sector(cxt);
}
if (n == 2 && !first) {
@@ -668,8 +668,8 @@ static int sun_add_partition(
_("You haven't covered the whole disk with the 3rd partition, but your value\n"
"%lu %s covers some other partition. Your entry has been changed\n"
"to %lu %s"),
- (unsigned long) fdisk_scround(cxt, last), fdisk_context_get_unit(cxt, SINGULAR),
- (unsigned long) fdisk_scround(cxt, stop), fdisk_context_get_unit(cxt, SINGULAR));
+ (unsigned long) fdisk_scround(cxt, last), fdisk_get_unit(cxt, SINGULAR),
+ (unsigned long) fdisk_scround(cxt, stop), fdisk_get_unit(cxt, SINGULAR));
last = stop;
}
} else if (!whole_disk && last > stop)
@@ -726,7 +726,7 @@ static int sun_list_disklabel(struct fdisk_context *cxt)
sunlabel = self_disklabel(cxt);
- if (fdisk_context_display_details(cxt)) {
+ if (fdisk_is_details(cxt)) {
fdisk_info(cxt,
_("Label geometry: %d rpm, %d alternate and %d physical cylinders,\n"
" %d extra sects/cyl, interleave %d:1"),