blob: 844e17e199413e26d5a900cf4d85e5cc81d14dc1 [file] [log] [blame]
bigbiff7b4c7a62015-01-01 19:44:14 -05001/*
2 * libfdisk.h - libfdisk API
3 *
4 * Copyright (C) 2012-2014 Karel Zak <kzak@redhat.com>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#ifndef _LIBFDISK_H
22#define _LIBFDISK_H
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#include <stdio.h>
29#include <stdarg.h>
30#include <stdint.h>
31
32/**
33 * LIBFDISK_VERSION:
34 *
35 * Library version string
36 */
37#define LIBFDISK_VERSION "2.25.0"
38
39/**
40 * fdisk_context:
41 *
42 * Basic library handler.
43 */
44struct fdisk_context;
45
46/**
47 * fdisk_label:
48 *
49 * Disk label specific driver and setting.
50 */
51struct fdisk_label;
52
53/**
54 * fdisk_parttype:
55 *
56 * Partition type.
57 */
58struct fdisk_parttype;
59
60/**
61 * fdisk_partition:
62 *
63 * Partition abstraction (and template).
64 */
65struct fdisk_partition;
66
67/**
68 * fdisk_ask:
69 *
70 * Ask API handler for dialogs with users.
71 */
72struct fdisk_ask;
73
74/**
75 * fdisk_iter:
76 *
77 * Unified iterator.
78 */
79struct fdisk_iter;
80
81/**
82 * fdisk_table:
83 *
84 * Container for fdisk_partition objects
85 */
86struct fdisk_table;
87
88/**
89 * fdisk_field
90 *
91 * Output field description.
92 */
93struct fdisk_field;
94
95/**
96 * fdisk_script
97 *
98 * library handler for sfdisk compatible scripts
99 */
100struct fdisk_script;
101
102/**
103 * fdisk_sector_t
104 *
105 * LBA adresses type
106 */
107typedef uint64_t fdisk_sector_t;
108
109/**
110 * fdisk_labeltype:
111 *
112 * Supported partition table types (labels)
113 */
114enum fdisk_labeltype {
115 FDISK_DISKLABEL_DOS = (1 << 1),
116 FDISK_DISKLABEL_SUN = (1 << 2),
117 FDISK_DISKLABEL_SGI = (1 << 3),
118 FDISK_DISKLABEL_BSD = (1 << 4),
119 FDISK_DISKLABEL_GPT = (1 << 5)
120};
121
122/**
123 * fdisk_asktype:
124 *
125 * Ask API dialog types
126 */
127enum fdisk_asktype {
128 FDISK_ASKTYPE_NONE = 0,
129 FDISK_ASKTYPE_NUMBER,
130 FDISK_ASKTYPE_OFFSET,
131 FDISK_ASKTYPE_WARN,
132 FDISK_ASKTYPE_WARNX,
133 FDISK_ASKTYPE_INFO,
134 FDISK_ASKTYPE_YESNO,
135 FDISK_ASKTYPE_STRING,
136 FDISK_ASKTYPE_MENU
137};
138
139/* init.c */
140extern void fdisk_init_debug(int mask);
141
142/* context.h */
143
144#define FDISK_PLURAL 0
145#define FDISK_SINGULAR 1
146
147struct fdisk_context *fdisk_new_context(void);
148struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent, const char *name);
149void fdisk_unref_context(struct fdisk_context *cxt);
150void fdisk_ref_context(struct fdisk_context *cxt);
151
152struct fdisk_context *fdisk_get_parent(struct fdisk_context *cxt);
153size_t fdisk_get_npartitions(struct fdisk_context *cxt);
154
155struct fdisk_label *fdisk_get_label(struct fdisk_context *cxt, const char *name);
156int fdisk_next_label(struct fdisk_context *cxt, struct fdisk_label **lb);
157size_t fdisk_get_nlabels(struct fdisk_context *cxt);
158
159int fdisk_has_label(struct fdisk_context *cxt);
160int fdisk_is_labeltype(struct fdisk_context *cxt, enum fdisk_labeltype id);
161#define fdisk_is_label(c, x) fdisk_is_labeltype(c, FDISK_DISKLABEL_ ## x)
162
163
164int fdisk_assign_device(struct fdisk_context *cxt,
165 const char *fname, int readonly);
166int fdisk_deassign_device(struct fdisk_context *cxt, int nosync);
167int fdisk_is_readonly(struct fdisk_context *cxt);
168
169int fdisk_enable_details(struct fdisk_context *cxt, int enable);
170int fdisk_is_details(struct fdisk_context *cxt);
171
172int fdisk_enable_listonly(struct fdisk_context *cxt, int enable);
173int fdisk_is_listonly(struct fdisk_context *cxt);
174
175int fdisk_set_unit(struct fdisk_context *cxt, const char *str);
176const char *fdisk_get_unit(struct fdisk_context *cxt, int n);
177int fdisk_use_cylinders(struct fdisk_context *cxt);
178unsigned int fdisk_get_units_per_sector(struct fdisk_context *cxt);
179
180unsigned long fdisk_get_optimal_iosize(struct fdisk_context *cxt);
181unsigned long fdisk_get_minimal_iosize(struct fdisk_context *cxt);
182unsigned long fdisk_get_physector_size(struct fdisk_context *cxt);
183unsigned long fdisk_get_sector_size(struct fdisk_context *cxt);
184unsigned long fdisk_get_alignment_offset(struct fdisk_context *cxt);
185unsigned long fdisk_get_grain_size(struct fdisk_context *cxt);
186fdisk_sector_t fdisk_get_first_lba(struct fdisk_context *cxt);
187fdisk_sector_t fdisk_set_first_lba(struct fdisk_context *cxt, fdisk_sector_t lba);
188fdisk_sector_t fdisk_get_last_lba(struct fdisk_context *cxt);
189fdisk_sector_t fdisk_set_last_lba(struct fdisk_context *cxt, fdisk_sector_t lba);
190fdisk_sector_t fdisk_get_nsectors(struct fdisk_context *cxt);
191const char *fdisk_get_devname(struct fdisk_context *cxt);
192int fdisk_get_devfd(struct fdisk_context *cxt);
193
194unsigned int fdisk_get_geom_heads(struct fdisk_context *cxt);
195fdisk_sector_t fdisk_get_geom_sectors(struct fdisk_context *cxt);
196fdisk_sector_t fdisk_get_geom_cylinders(struct fdisk_context *cxt);
197
198
199
200/* parttype.c */
201struct fdisk_parttype *fdisk_new_parttype(void);
202void fdisk_ref_parttype(struct fdisk_parttype *t);
203void fdisk_unref_parttype(struct fdisk_parttype *t);
204int fdisk_parttype_set_name(struct fdisk_parttype *t, const char *str);
205int fdisk_parttype_set_typestr(struct fdisk_parttype *t, const char *str);
206int fdisk_parttype_set_code(struct fdisk_parttype *t, int code);
207size_t fdisk_label_get_nparttypes(const struct fdisk_label *lb);
208struct fdisk_parttype *fdisk_label_get_parttype(const struct fdisk_label *lb, size_t n);
209int fdisk_label_has_code_parttypes(const struct fdisk_label *lb);
210struct fdisk_parttype *fdisk_label_get_parttype_from_code(
211 const struct fdisk_label *lb,
212 unsigned int code);
213struct fdisk_parttype *fdisk_label_get_parttype_from_string(
214 const struct fdisk_label *lb,
215 const char *str);
216struct fdisk_parttype *fdisk_new_unknown_parttype(unsigned int code,
217 const char *typestr);
218struct fdisk_parttype *fdisk_copy_parttype(const struct fdisk_parttype *type);
219struct fdisk_parttype *fdisk_label_parse_parttype(
220 const struct fdisk_label *lb,
221 const char *str);
222const char *fdisk_parttype_get_string(const struct fdisk_parttype *t);
223unsigned int fdisk_parttype_get_code(const struct fdisk_parttype *t);
224const char *fdisk_parttype_get_name(const struct fdisk_parttype *t);
225int fdisk_parttype_is_unknown(const struct fdisk_parttype *t);
226
227/* label.c */
228
229/**
230 * fdisk_fieldtype
231 *
232 * Types of fdisk_field
233 */
234enum fdisk_fieldtype {
235 FDISK_FIELD_NONE = 0,
236
237 /* generic */
238 FDISK_FIELD_DEVICE,
239 FDISK_FIELD_START,
240 FDISK_FIELD_END,
241 FDISK_FIELD_SECTORS,
242 FDISK_FIELD_CYLINDERS,
243 FDISK_FIELD_SIZE,
244 FDISK_FIELD_TYPE,
245 FDISK_FIELD_TYPEID,
246
247 /* label specific */
248 FDISK_FIELD_ATTR,
249 FDISK_FIELD_BOOT,
250 FDISK_FIELD_BSIZE,
251 FDISK_FIELD_CPG,
252 FDISK_FIELD_EADDR,
253 FDISK_FIELD_FSIZE,
254 FDISK_FIELD_NAME,
255 FDISK_FIELD_SADDR,
256 FDISK_FIELD_UUID,
257
258 FDISK_NFIELDS /* must be last */
259};
260
261int fdisk_label_get_type(const struct fdisk_label *lb);
262const char *fdisk_label_get_name(const struct fdisk_label *lb);
263int fdisk_label_require_geometry(const struct fdisk_label *lb);
264
265
266extern int fdisk_write_disklabel(struct fdisk_context *cxt);
267extern int fdisk_verify_disklabel(struct fdisk_context *cxt);
268extern int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name);
269extern int fdisk_list_disklabel(struct fdisk_context *cxt);
270extern int fdisk_locate_disklabel(struct fdisk_context *cxt, int n, const char **name, off_t *offset, size_t *size);
271
272extern int fdisk_get_disklabel_id(struct fdisk_context *cxt, char **id);
273extern int fdisk_set_disklabel_id(struct fdisk_context *cxt);
274
275extern int fdisk_get_partition(struct fdisk_context *cxt, size_t partno, struct fdisk_partition **pa);
276extern int fdisk_set_partition(struct fdisk_context *cxt, size_t partno, struct fdisk_partition *pa);
277extern int fdisk_add_partition(struct fdisk_context *cxt, struct fdisk_partition *pa, size_t *partno);
278extern int fdisk_delete_partition(struct fdisk_context *cxt, size_t partno);
279
280extern int fdisk_delete_all_partitions(struct fdisk_context *cxt);
281
282extern int fdisk_set_partition_type(struct fdisk_context *cxt, size_t partnum,
283 struct fdisk_parttype *t);
284
285
286extern int fdisk_label_get_fields_ids(
287 const struct fdisk_label *lb,
288 struct fdisk_context *cxt,
289 int **ids, size_t *nids);
290
291extern const struct fdisk_field *fdisk_label_get_field(const struct fdisk_label *lb, int id);
292extern const struct fdisk_field *fdisk_label_get_field_by_name(
293 const struct fdisk_label *lb,
294 const char *name);
295
296extern int fdisk_field_get_id(const struct fdisk_field *field);
297extern const char *fdisk_field_get_name(const struct fdisk_field *field);
298extern double fdisk_field_get_width(const struct fdisk_field *field);
299extern int fdisk_field_is_number(const struct fdisk_field *field);
300
301
302extern void fdisk_label_set_changed(struct fdisk_label *lb, int changed);
303extern int fdisk_label_is_changed(const struct fdisk_label *lb);
304
305extern void fdisk_label_set_disabled(struct fdisk_label *lb, int disabled);
306extern int fdisk_label_is_disabled(const struct fdisk_label *lb);
307
308extern int fdisk_is_partition_used(struct fdisk_context *cxt, size_t n);
309
310extern int fdisk_toggle_partition_flag(struct fdisk_context *cxt, size_t partnum, unsigned long flag);
311
312extern struct fdisk_partition *fdisk_new_partition(void);
313extern void fdisk_reset_partition(struct fdisk_partition *pa);
314extern void fdisk_ref_partition(struct fdisk_partition *pa);
315extern void fdisk_unref_partition(struct fdisk_partition *pa);
316extern int fdisk_partition_is_freespace(struct fdisk_partition *pa);
317
318int fdisk_partition_set_start(struct fdisk_partition *pa, uint64_t off);
319int fdisk_partition_unset_start(struct fdisk_partition *pa);
320uint64_t fdisk_partition_get_start(struct fdisk_partition *pa);
321int fdisk_partition_has_start(struct fdisk_partition *pa);
322int fdisk_partition_cmp_start(struct fdisk_partition *a,
323 struct fdisk_partition *b);
324int fdisk_partition_start_follow_default(struct fdisk_partition *pa, int enable);
325int fdisk_partition_start_is_default(struct fdisk_partition *pa);
326
327int fdisk_partition_set_size(struct fdisk_partition *pa, uint64_t sz);
328int fdisk_partition_unset_size(struct fdisk_partition *pa);
329uint64_t fdisk_partition_get_size(struct fdisk_partition *pa);
330int fdisk_partition_has_size(struct fdisk_partition *pa);
331int fdisk_partition_size_explicit(struct fdisk_partition *pa, int enable);
332
333int fdisk_partition_has_end(struct fdisk_partition *pa);
334fdisk_sector_t fdisk_partition_get_end(struct fdisk_partition *pa);
335
336int fdisk_partition_set_partno(struct fdisk_partition *pa, size_t num);
337int fdisk_partition_unset_partno(struct fdisk_partition *pa);
338size_t fdisk_partition_get_partno(struct fdisk_partition *pa);
339int fdisk_partition_has_partno(struct fdisk_partition *pa);
340int fdisk_partition_cmp_partno(struct fdisk_partition *a,
341 struct fdisk_partition *b);
342int fdisk_partition_partno_follow_default(struct fdisk_partition *pa, int enable);
343
344
345extern int fdisk_partition_set_type(struct fdisk_partition *pa, struct fdisk_parttype *type);
346extern struct fdisk_parttype *fdisk_partition_get_type(struct fdisk_partition *pa);
347extern int fdisk_partition_set_name(struct fdisk_partition *pa, const char *name);
348extern const char *fdisk_partition_get_name(struct fdisk_partition *pa);
349extern int fdisk_partition_set_uuid(struct fdisk_partition *pa, const char *uuid);
350extern int fdisk_partition_set_attrs(struct fdisk_partition *pa, const char *attrs);
351extern const char *fdisk_partition_get_uuid(struct fdisk_partition *pa);
352extern const char *fdisk_partition_get_attrs(struct fdisk_partition *pa);
353extern int fdisk_partition_is_nested(struct fdisk_partition *pa);
354extern int fdisk_partition_is_container(struct fdisk_partition *pa);
355extern int fdisk_partition_get_parent(struct fdisk_partition *pa, size_t *parent);
356extern int fdisk_partition_is_used(struct fdisk_partition *pa);
357extern int fdisk_partition_is_bootable(struct fdisk_partition *pa);
358extern int fdisk_partition_to_string(struct fdisk_partition *pa,
359 struct fdisk_context *cxt,
360 int id, char **data);
361
362int fdisk_partition_next_partno(struct fdisk_partition *pa,
363 struct fdisk_context *cxt,
364 size_t *n);
365
366extern int fdisk_partition_end_follow_default(struct fdisk_partition *pa, int enable);
367extern int fdisk_partition_end_is_default(struct fdisk_partition *pa);
368
369extern int fdisk_reorder_partitions(struct fdisk_context *cxt);
370
371/* table.c */
372extern struct fdisk_table *fdisk_new_table(void);
373extern int fdisk_reset_table(struct fdisk_table *tb);
374extern void fdisk_ref_table(struct fdisk_table *tb);
375extern void fdisk_unref_table(struct fdisk_table *tb);
376extern size_t fdisk_table_get_nents(struct fdisk_table *tb);
377extern int fdisk_table_is_empty(struct fdisk_table *tb);
378extern int fdisk_table_add_partition(struct fdisk_table *tb, struct fdisk_partition *pa);
379extern int fdisk_table_remove_partition(struct fdisk_table *tb, struct fdisk_partition *pa);
380
381extern int fdisk_get_partitions(struct fdisk_context *cxt, struct fdisk_table **tb);
382extern int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb);
383
384extern int fdisk_table_wrong_order(struct fdisk_table *tb);
385extern int fdisk_table_sort_partitions(struct fdisk_table *tb,
386 int (*cmp)(struct fdisk_partition *,
387 struct fdisk_partition *));
388
389extern int fdisk_table_next_partition(
390 struct fdisk_table *tb,
391 struct fdisk_iter *itr,
392 struct fdisk_partition **pa);
393
394extern struct fdisk_partition *fdisk_table_get_partition(
395 struct fdisk_table *tb,
396 size_t n);
397extern int fdisk_apply_table(struct fdisk_context *cxt, struct fdisk_table *tb);
398
399/* alignment.c */
400#define FDISK_ALIGN_UP 1
401#define FDISK_ALIGN_DOWN 2
402#define FDISK_ALIGN_NEAREST 3
403
404fdisk_sector_t fdisk_align_lba(struct fdisk_context *cxt, fdisk_sector_t lba, int direction);
405fdisk_sector_t fdisk_align_lba_in_range(struct fdisk_context *cxt,
406 fdisk_sector_t lba, fdisk_sector_t start, fdisk_sector_t stop);
407int fdisk_lba_is_phy_aligned(struct fdisk_context *cxt, fdisk_sector_t lba);
408
409int fdisk_override_geometry(struct fdisk_context *cxt,
410 unsigned int cylinders,
411 unsigned int heads,
412 unsigned int sectors);
413int fdisk_save_user_geometry(struct fdisk_context *cxt,
414 unsigned int cylinders,
415 unsigned int heads,
416 unsigned int sectors);
417int fdisk_save_user_sector_size(struct fdisk_context *cxt,
418 unsigned int phy,
419 unsigned int log);
420int fdisk_has_user_device_properties(struct fdisk_context *cxt);
421int fdisk_reset_alignment(struct fdisk_context *cxt);
422int fdisk_reset_device_properties(struct fdisk_context *cxt);
423int fdisk_reread_partition_table(struct fdisk_context *cxt);
424
425/* iter.c */
426enum {
427
428 FDISK_ITER_FORWARD = 0,
429 FDISK_ITER_BACKWARD
430};
431extern struct fdisk_iter *fdisk_new_iter(int direction);
432extern void fdisk_free_iter(struct fdisk_iter *itr);
433extern void fdisk_reset_iter(struct fdisk_iter *itr, int direction);
434extern int fdisk_iter_get_direction(struct fdisk_iter *itr);
435
436
437/* dos.c */
438#define DOS_FLAG_ACTIVE 1
439
440extern int fdisk_dos_move_begin(struct fdisk_context *cxt, size_t i);
441extern int fdisk_dos_enable_compatible(struct fdisk_label *lb, int enable);
442extern int fdisk_dos_is_compatible(struct fdisk_label *lb);
443
444/* sun.h */
445extern int fdisk_sun_set_alt_cyl(struct fdisk_context *cxt);
446extern int fdisk_sun_set_xcyl(struct fdisk_context *cxt);
447extern int fdisk_sun_set_ilfact(struct fdisk_context *cxt);
448extern int fdisk_sun_set_rspeed(struct fdisk_context *cxt);
449extern int fdisk_sun_set_pcylcount(struct fdisk_context *cxt);
450
451/* bsd.c */
452extern int fdisk_bsd_edit_disklabel(struct fdisk_context *cxt);
453extern int fdisk_bsd_write_bootstrap(struct fdisk_context *cxt);
454extern int fdisk_bsd_link_partition(struct fdisk_context *cxt);
455
456/* sgi.h */
457#define SGI_FLAG_BOOT 1
458#define SGI_FLAG_SWAP 2
459extern int fdisk_sgi_set_bootfile(struct fdisk_context *cxt);
460extern int fdisk_sgi_create_info(struct fdisk_context *cxt);
461
462/* gpt */
463
464/* GPT partition attributes */
465enum {
466 /* System partition (disk partitioning utilities must preserve the
467 * partition as is) */
468 GPT_FLAG_REQUIRED = 1,
469
470 /* EFI firmware should ignore the content of the partition and not try
471 * to read from it */
472 GPT_FLAG_NOBLOCK,
473
474 /* Legacy BIOS bootable */
475 GPT_FLAG_LEGACYBOOT,
476
477 /* bites 48-63, Defined and used by the individual partition type.
478 *
479 * The flag GPT_FLAG_GUIDSPECIFIC forces libfdisk to ask (by ask API)
480 * for a bit number. If you want to toggle specific bit and avoid any
481 * dialog, then use the bit number (in range 48..63). For example:
482 *
483 * // start dialog to ask for bit number
484 * fdisk_toggle_partition_flag(cxt, n, GPT_FLAG_GUIDSPECIFIC);
485 *
486 * // toggle bit 60
487 * fdisk_toggle_partition_flag(cxt, n, 60);
488 */
489 GPT_FLAG_GUIDSPECIFIC
490};
491
492extern int fdisk_gpt_is_hybrid(struct fdisk_context *cxt);
493
494
495/* script.c */
496struct fdisk_script *fdisk_new_script(struct fdisk_context *cxt);
497struct fdisk_script *fdisk_new_script_from_file(struct fdisk_context *cxt,
498 const char *filename);
499void fdisk_ref_script(struct fdisk_script *dp);
500void fdisk_unref_script(struct fdisk_script *dp);
501
502const char *fdisk_script_get_header(struct fdisk_script *dp, const char *name);
503int fdisk_script_set_header(struct fdisk_script *dp, const char *name, const char *data);
504struct fdisk_table *fdisk_script_get_table(struct fdisk_script *dp);
505int fdisk_script_get_nlines(struct fdisk_script *dp);
506
507int fdisk_script_read_context(struct fdisk_script *dp, struct fdisk_context *cxt);
508int fdisk_script_write_file(struct fdisk_script *dp, FILE *f);
509int fdisk_script_read_file(struct fdisk_script *dp, FILE *f);
510int fdisk_script_read_line(struct fdisk_script *dp, FILE *f, char *buf, size_t bufsz);
511
512int fdisk_set_script(struct fdisk_context *cxt, struct fdisk_script *dp);
513struct fdisk_script *fdisk_get_script(struct fdisk_context *cxt);
514
515int fdisk_apply_script_headers(struct fdisk_context *cxt, struct fdisk_script *dp);
516int fdisk_apply_script(struct fdisk_context *cxt, struct fdisk_script *dp);
517
518
519/* ask.c */
520#define fdisk_is_ask(a, x) (fdisk_ask_get_type(a) == FDISK_ASKTYPE_ ## x)
521
522int fdisk_set_ask(struct fdisk_context *cxt,
523 int (*ask_cb)(struct fdisk_context *, struct fdisk_ask *, void *),
524 void *data);
525
526
527void fdisk_ref_ask(struct fdisk_ask *ask);
528void fdisk_unref_ask(struct fdisk_ask *ask);
529const char *fdisk_ask_get_query(struct fdisk_ask *ask);
530int fdisk_ask_get_type(struct fdisk_ask *ask);
531const char *fdisk_ask_number_get_range(struct fdisk_ask *ask);
532uint64_t fdisk_ask_number_get_default(struct fdisk_ask *ask);
533uint64_t fdisk_ask_number_get_low(struct fdisk_ask *ask);
534uint64_t fdisk_ask_number_get_high(struct fdisk_ask *ask);
535uint64_t fdisk_ask_number_get_result(struct fdisk_ask *ask);
536int fdisk_ask_number_set_result(struct fdisk_ask *ask, uint64_t result);
537uint64_t fdisk_ask_number_get_base(struct fdisk_ask *ask);
538uint64_t fdisk_ask_number_get_unit(struct fdisk_ask *ask);
539int fdisk_ask_number_set_relative(struct fdisk_ask *ask, int relative);
540int fdisk_ask_number_inchars(struct fdisk_ask *ask);
541int fdisk_ask_partnum(struct fdisk_context *cxt, size_t *partnum, int wantnew);
542
543int fdisk_ask_number(struct fdisk_context *cxt,
544 uintmax_t low,
545 uintmax_t dflt,
546 uintmax_t high,
547 const char *query,
548 uintmax_t *result);
549char *fdisk_ask_string_get_result(struct fdisk_ask *ask);
550int fdisk_ask_string_set_result(struct fdisk_ask *ask, char *result);
551int fdisk_ask_string(struct fdisk_context *cxt,
552 const char *query,
553 char **result);
554int fdisk_ask_yesno(struct fdisk_context *cxt,
555 const char *query,
556 int *result);
557int fdisk_ask_yesno_get_result(struct fdisk_ask *ask);
558int fdisk_ask_yesno_set_result(struct fdisk_ask *ask, int result);
559int fdisk_ask_menu_get_default(struct fdisk_ask *ask);
560int fdisk_ask_menu_set_result(struct fdisk_ask *ask, int key);
561int fdisk_ask_menu_get_result(struct fdisk_ask *ask, int *key);
562int fdisk_ask_menu_get_item(struct fdisk_ask *ask, size_t idx, int *key,
563 const char **name, const char **desc);
564size_t fdisk_ask_menu_get_nitems(struct fdisk_ask *ask);
565int fdisk_ask_print_get_errno(struct fdisk_ask *ask);
566const char *fdisk_ask_print_get_mesg(struct fdisk_ask *ask);
567
568int fdisk_info(struct fdisk_context *cxt, const char *fmt, ...);
569int fdisk_warn(struct fdisk_context *cxt, const char *fmt, ...);
570int fdisk_warnx(struct fdisk_context *cxt, const char *fmt, ...);
571
572/* utils.h */
573extern char *fdisk_partname(const char *dev, size_t partno);
574
575#ifdef __cplusplus
576}
577#endif
578
579#endif /* _LIBFDISK_H */