Functions
fdisk_info ()
int
fdisk_info (struct fdisk_context *cxt
,
const char *fmt
,
...
);
High-level API to print warning message (errno expected)
Returns
0 on success, <0 on error
fdisk_warn ()
int
fdisk_warn (struct fdisk_context *cxt
,
const char *fmt
,
...
);
fdisk_warnx ()
int
fdisk_warnx (struct fdisk_context *cxt
,
const char *fmt
,
...
);
High-level API to print warning message
Returns
0 on success, <0 on error
fdisk_set_ask ()
int
fdisk_set_ask (struct fdisk_context *cxt
,
int (*ask_cb) (struct fdisk_context *, struct fdisk_ask *, void *)
,
void *data
);
Set callback for dialog driven partitioning and library warnings/errors.
Returns
0 on success, < 0 on error.
fdisk_is_ask()
#define fdisk_is_ask(a, x) (fdisk_ask_get_type(a) == FDISK_ASKTYPE_ ## x)
fdisk_ask_get_query ()
const char *
fdisk_ask_get_query (struct fdisk_ask *ask
);
Returns
pointer to dialog string.
fdisk_ask_get_type ()
int
fdisk_ask_get_type (struct fdisk_ask *ask
);
fdisk_ask_menu_get_default ()
int
fdisk_ask_menu_get_default (struct fdisk_ask *ask
);
Returns
default menu item key
fdisk_ask_menu_get_item ()
int
fdisk_ask_menu_get_item (struct fdisk_ask *ask
,
size_t idx
,
int *key
,
const char **name
,
const char **desc
);
Returns
0 on success, <0 on error, >0 if idx out-of-range
fdisk_ask_menu_get_nitems ()
size_t
fdisk_ask_menu_get_nitems (struct fdisk_ask *ask
);
Returns
number of menu items
fdisk_ask_menu_get_result ()
int
fdisk_ask_menu_get_result (struct fdisk_ask *ask
,
int *key
);
Returns
0 on success, <0 on error.
fdisk_ask_menu_set_result ()
int
fdisk_ask_menu_set_result (struct fdisk_ask *ask
,
int key
);
Returns
0 on success, <0 on error
fdisk_ask_number ()
int
fdisk_ask_number (struct fdisk_context *cxt
,
uintmax_t low
,
uintmax_t dflt
,
uintmax_t high
,
const char *query
,
uintmax_t *result
);
Returns
0 on success, <0 on error.
fdisk_ask_number_get_base ()
uint64_t
fdisk_ask_number_get_base (struct fdisk_ask *ask
);
Returns
base when user specify number in relative notation (+size)
fdisk_ask_number_get_default ()
uint64_t
fdisk_ask_number_get_default (struct fdisk_ask *ask
);
fdisk_ask_number_get_high ()
uint64_t
fdisk_ask_number_get_high (struct fdisk_ask *ask
);
Returns
maximal possible number when ask for numbers in range
fdisk_ask_number_get_low ()
uint64_t
fdisk_ask_number_get_low (struct fdisk_ask *ask
);
Returns
minimal possible number when ask for numbers in range
fdisk_ask_number_get_range ()
const char *
fdisk_ask_number_get_range (struct fdisk_ask *ask
);
Returns
string with range (e.g. "1,3,5-10")
fdisk_ask_number_get_result ()
uint64_t
fdisk_ask_number_get_result (struct fdisk_ask *ask
);
fdisk_ask_number_get_unit ()
uint64_t
fdisk_ask_number_get_unit (struct fdisk_ask *ask
);
Returns
number of bytes per the unit
fdisk_ask_number_inchars ()
int
fdisk_ask_number_inchars (struct fdisk_ask *ask
);
For example for BSD is normal to address partition by chars rather than by
number (first partition is 'a').
Returns
1 if number should be presented as chars
fdisk_ask_number_is_wrap_negative ()
int
fdisk_ask_number_is_wrap_negative (struct fdisk_ask *ask
);
The wrap-negative flag can be used to accept negative number from user. In this
case the dialog result is calculated as "high - num" (-N from high limit).
Since: 2.33
fdisk_ask_number_set_relative ()
int
fdisk_ask_number_set_relative (struct fdisk_ask *ask
,
int relative
);
Inform libfdisk that user can specify the number in relative notation rather than
by explicit number. This is useful for some optimization (e.g.
align end of partition, etc.)
Returns
0 on success, <0 on error
fdisk_ask_number_set_result ()
int
fdisk_ask_number_set_result (struct fdisk_ask *ask
,
uint64_t result
);
Returns
0 on success, <0 on error
fdisk_ask_partnum ()
int
fdisk_ask_partnum (struct fdisk_context *cxt
,
size_t *partnum
,
int wantnew
);
High-level API to ask for used or unused partition number.
Returns
0 on success, < 0 on error, 1 if no free/used partition
fdisk_ask_print_get_errno ()
int
fdisk_ask_print_get_errno (struct fdisk_ask *ask
);
Returns
error number for warning/error messages
fdisk_ask_print_get_mesg ()
const char *
fdisk_ask_print_get_mesg (struct fdisk_ask *ask
);
Returns
pointer to message
fdisk_ask_string ()
int
fdisk_ask_string (struct fdisk_context *cxt
,
const char *query
,
char **result
);
High-level API to ask for strings. Don't forget to deallocate the result
.
Returns
0 on success, <0 on error.
fdisk_ask_string_get_result ()
char *
fdisk_ask_string_get_result (struct fdisk_ask *ask
);
Returns
pointer to dialog result
fdisk_ask_string_set_result ()
int
fdisk_ask_string_set_result (struct fdisk_ask *ask
,
char *result
);
You don't have to care about the result
deallocation, libfdisk is going to
deallocate the result when destroy ask
instance.
Returns
0 on success, <0 on error
fdisk_ask_yesno ()
int
fdisk_ask_yesno (struct fdisk_context *cxt
,
const char *query
,
int *result
);
High-level API to ask Yes/No questions
Returns
0 on success, <0 on error
fdisk_ask_yesno_get_result ()
int
fdisk_ask_yesno_get_result (struct fdisk_ask *ask
);
fdisk_ask_yesno_set_result ()
int
fdisk_ask_yesno_set_result (struct fdisk_ask *ask
,
int result
);
Returns
0 on success, <0 on error
fdisk_ref_ask ()
void
fdisk_ref_ask (struct fdisk_ask *ask
);
Increments reference counter.
fdisk_unref_ask ()
void
fdisk_unref_ask (struct fdisk_ask *ask
);
Decrements reference counter, on zero the ask
is automatically
deallocated.