]> git.ipfire.org Git - thirdparty/util-linux.git/blame - libfdisk/src/libfdisk.h.in
taskset: Accept 0 pid for current process
[thirdparty/util-linux.git] / libfdisk / src / libfdisk.h.in
CommitLineData
d56a7c23
KZ
1/*
2 * libfdisk.h - libfdisk API
3 *
0bb4c979 4 * Copyright (C) 2012-2014 Karel Zak <kzak@redhat.com>
d56a7c23
KZ
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 *
762f295a
BS
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://gnu.org/licenses/>.
d56a7c23
KZ
18 */
19
0bb4c979
KZ
20#ifndef _LIBFDISK_H
21#define _LIBFDISK_H
d56a7c23
KZ
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
fdb006e8 27#include <stdio.h>
ab6ea0e8
KZ
28#include <stdarg.h>
29#include <stdint.h>
745801e4 30#include <sys/types.h>
ab6ea0e8 31
0bb4c979
KZ
32/**
33 * LIBFDISK_VERSION:
34 *
35 * Library version string
36 */
37#define LIBFDISK_VERSION "@LIBFDISK_VERSION@"
38
791da22d
KZ
39#define LIBFDISK_MAJOR_VERSION @LIBFDISK_MAJOR_VERSION@
40#define LIBFDISK_MINOR_VERSION @LIBFDISK_MINOR_VERSION@
41#define LIBFDISK_PATCH_VERSION @LIBFDISK_PATCH_VERSION@
42
a78dba34
KZ
43/**
44 * fdisk_context:
45 *
46 * Basic library handler.
47 */
a5fe1b3f 48struct fdisk_context;
a78dba34
KZ
49
50/**
51 * fdisk_label:
52 *
53 * Disk label specific driver and setting.
54 */
0c5d095e 55struct fdisk_label;
a78dba34
KZ
56
57/**
58 * fdisk_parttype:
59 *
60 * Partition type.
61 */
a5fe1b3f 62struct fdisk_parttype;
a78dba34
KZ
63
64/**
65 * fdisk_partition:
66 *
67 * Partition abstraction (and template).
68 */
8c0a7f91 69struct fdisk_partition;
a78dba34
KZ
70
71/**
72 * fdisk_ask:
73 *
74 * Ask API handler for dialogs with users.
75 */
7845ca8d 76struct fdisk_ask;
a78dba34
KZ
77
78/**
79 * fdisk_iter:
80 *
81 * Unified iterator.
82 */
04406c0d 83struct fdisk_iter;
a78dba34
KZ
84
85/**
86 * fdisk_table:
87 *
88 * Container for fdisk_partition objects
89 */
04406c0d 90struct fdisk_table;
a78dba34
KZ
91
92/**
93 * fdisk_field
94 *
95 * Output field description.
96 */
bd85d11f 97struct fdisk_field;
a78dba34
KZ
98
99/**
100 * fdisk_script
101 *
5989556a 102 * library handler for sfdisk compatible scripts and dumps
a78dba34 103 */
9138d6f9 104struct fdisk_script;
a5fe1b3f 105
0073a4cf
KZ
106/**
107 * fdisk_sector_t
108 *
73afd3f8 109 * LBA addresses type
0073a4cf
KZ
110 */
111typedef uint64_t fdisk_sector_t;
8d605c88 112
a78dba34
KZ
113/**
114 * fdisk_labeltype:
f92c9f37
KZ
115 * @FDISK_DISKLABEL_DOS: MBR label type
116 * @FDISK_DISKLABEL_SUN: SUN label type
117 * @FDISK_DISKLABEL_SGI: SGI label type
118 * @FDISK_DISKLABEL_BSD: BSD label type
119 * @FDISK_DISKLABEL_GPT: UEFI GPT type
a78dba34 120 *
8adbcf0c
KZ
121 * Supported partition table types (labels)
122 */
123enum fdisk_labeltype {
8c14a743
KZ
124 FDISK_DISKLABEL_DOS = (1 << 1), /* MBR label type */
125 FDISK_DISKLABEL_SUN = (1 << 2), /* SUN label type */
126 FDISK_DISKLABEL_SGI = (1 << 3), /* SGI label type */
127 FDISK_DISKLABEL_BSD = (1 << 4), /* BSD label t ype */
128 FDISK_DISKLABEL_GPT = (1 << 5) /* UEFI GPT type */
8adbcf0c
KZ
129};
130
5989556a 131/**
f92c9f37 132 * fdisk_labelitem:
5989556a
KZ
133 *
134 * library handler for label specific information. See
135 * generic FDISK_LABELITEM_* and label specific {GPT,MBR,..}_LABELITEM_*.
136 */
137struct fdisk_labelitem;
138
a78dba34
KZ
139/**
140 * fdisk_asktype:
f92c9f37
KZ
141 * @FDISK_ASKTYPE_NONE: undefined type
142 * @FDISK_ASKTYPE_NUMBER: ask for number
143 * @FDISK_ASKTYPE_OFFSET: ask for offset
144 * @FDISK_ASKTYPE_WARN: print warning message and errno
145 * @FDISK_ASKTYPE_WARNX: print warning message
11026083 146 * @FDISK_ASKTYPE_INFO: print info message
f92c9f37
KZ
147 * @FDISK_ASKTYPE_YESNO: ask Yes/No question
148 * @FDISK_ASKTYPE_STRING: ask for string
149 * @FDISK_ASKTYPE_MENU: ask for menu item
a78dba34
KZ
150 *
151 * Ask API dialog types
152 */
153enum fdisk_asktype {
f92c9f37
KZ
154 FDISK_ASKTYPE_NONE = 0,
155 FDISK_ASKTYPE_NUMBER,
156 FDISK_ASKTYPE_OFFSET,
157 FDISK_ASKTYPE_WARN,
158 FDISK_ASKTYPE_WARNX,
159 FDISK_ASKTYPE_INFO,
160 FDISK_ASKTYPE_YESNO,
161 FDISK_ASKTYPE_STRING,
162 FDISK_ASKTYPE_MENU
4114da08
KZ
163};
164
d56a7c23
KZ
165/* init.c */
166extern void fdisk_init_debug(int mask);
167
791da22d
KZ
168/* version.c */
169extern int fdisk_parse_version_string(const char *ver_string);
170extern int fdisk_get_library_version(const char **ver_string);
171extern int fdisk_get_library_features(const char ***features);
172
f4be9e2b 173/* context.h */
b4bfbadd 174
385810d2
KZ
175#define FDISK_PLURAL 0
176#define FDISK_SINGULAR 1
b4bfbadd 177
6a632136
KZ
178struct fdisk_context *fdisk_new_context(void);
179struct fdisk_context *fdisk_new_nested_context(struct fdisk_context *parent, const char *name);
c7119037 180void fdisk_unref_context(struct fdisk_context *cxt);
62a9ef3e 181void fdisk_ref_context(struct fdisk_context *cxt);
6a632136 182
1753a234 183struct fdisk_context *fdisk_get_parent(struct fdisk_context *cxt);
59c8e95b 184size_t fdisk_get_npartitions(struct fdisk_context *cxt);
1753a234 185
6a632136
KZ
186struct fdisk_label *fdisk_get_label(struct fdisk_context *cxt, const char *name);
187int fdisk_next_label(struct fdisk_context *cxt, struct fdisk_label **lb);
188size_t fdisk_get_nlabels(struct fdisk_context *cxt);
6a632136 189
aa36c2cf 190int fdisk_has_label(struct fdisk_context *cxt);
705854f3 191int fdisk_is_labeltype(struct fdisk_context *cxt, enum fdisk_labeltype id);
aa36c2cf
KZ
192#define fdisk_is_label(c, x) fdisk_is_labeltype(c, FDISK_DISKLABEL_ ## x)
193
194
6a632136
KZ
195int fdisk_assign_device(struct fdisk_context *cxt,
196 const char *fname, int readonly);
7571ec08
KZ
197int fdisk_assign_device_by_fd(struct fdisk_context *cxt, int fd,
198 const char *fname, int readonly);
6a632136 199int fdisk_deassign_device(struct fdisk_context *cxt, int nosync);
2469ba36
KZ
200int fdisk_reassign_device(struct fdisk_context *cxt);
201
6a632136 202int fdisk_is_readonly(struct fdisk_context *cxt);
7526c305 203int fdisk_is_regfile(struct fdisk_context *cxt);
b9da1532 204int fdisk_device_is_used(struct fdisk_context *cxt);
6a632136 205
992f7cba
KZ
206int fdisk_disable_dialogs(struct fdisk_context *cxt, int disable);
207int fdisk_has_dialogs(struct fdisk_context *cxt);
208
6a632136
KZ
209int fdisk_enable_details(struct fdisk_context *cxt, int enable);
210int fdisk_is_details(struct fdisk_context *cxt);
211
212int fdisk_enable_listonly(struct fdisk_context *cxt, int enable);
213int fdisk_is_listonly(struct fdisk_context *cxt);
214
6cbb7371
KZ
215int fdisk_enable_wipe(struct fdisk_context *cxt, int enable);
216int fdisk_has_wipe(struct fdisk_context *cxt);
217const char *fdisk_get_collision(struct fdisk_context *cxt);
0cec78a3 218int fdisk_is_ptcollision(struct fdisk_context *cxt);
6cbb7371 219
6a632136
KZ
220int fdisk_set_unit(struct fdisk_context *cxt, const char *str);
221const char *fdisk_get_unit(struct fdisk_context *cxt, int n);
222int fdisk_use_cylinders(struct fdisk_context *cxt);
223unsigned int fdisk_get_units_per_sector(struct fdisk_context *cxt);
224
225unsigned long fdisk_get_optimal_iosize(struct fdisk_context *cxt);
1753a234 226unsigned long fdisk_get_minimal_iosize(struct fdisk_context *cxt);
6a632136
KZ
227unsigned long fdisk_get_physector_size(struct fdisk_context *cxt);
228unsigned long fdisk_get_sector_size(struct fdisk_context *cxt);
229unsigned long fdisk_get_alignment_offset(struct fdisk_context *cxt);
230unsigned long fdisk_get_grain_size(struct fdisk_context *cxt);
0073a4cf
KZ
231fdisk_sector_t fdisk_get_first_lba(struct fdisk_context *cxt);
232fdisk_sector_t fdisk_set_first_lba(struct fdisk_context *cxt, fdisk_sector_t lba);
233fdisk_sector_t fdisk_get_last_lba(struct fdisk_context *cxt);
234fdisk_sector_t fdisk_set_last_lba(struct fdisk_context *cxt, fdisk_sector_t lba);
235fdisk_sector_t fdisk_get_nsectors(struct fdisk_context *cxt);
745801e4 236
6a632136 237const char *fdisk_get_devname(struct fdisk_context *cxt);
1753a234 238int fdisk_get_devfd(struct fdisk_context *cxt);
745801e4
KZ
239dev_t fdisk_get_devno(struct fdisk_context *cxt);
240const char *fdisk_get_devmodel(struct fdisk_context *cxt);
241
1753a234
KZ
242
243unsigned int fdisk_get_geom_heads(struct fdisk_context *cxt);
0073a4cf
KZ
244fdisk_sector_t fdisk_get_geom_sectors(struct fdisk_context *cxt);
245fdisk_sector_t fdisk_get_geom_cylinders(struct fdisk_context *cxt);
a5c1b0fa 246
354f8cc8
KZ
247enum {
248 FDISK_SIZEUNIT_HUMAN = 0, /* default, human readable {M,G,P,...} */
249 FDISK_SIZEUNIT_BYTES /* bytes */
250};
251int fdisk_set_size_unit(struct fdisk_context *cxt, int unit);
252int fdisk_get_size_unit(struct fdisk_context *cxt);
6d37c2ce 253
3457d90e
KZ
254int fdisk_has_protected_bootbits(struct fdisk_context *cxt);
255int fdisk_enable_bootbits_protection(struct fdisk_context *cxt, int enable);
6d37c2ce 256
a5fe1b3f 257/* parttype.c */
dfc6db2a
KZ
258struct fdisk_parttype *fdisk_new_parttype(void);
259void fdisk_ref_parttype(struct fdisk_parttype *t);
260void fdisk_unref_parttype(struct fdisk_parttype *t);
261int fdisk_parttype_set_name(struct fdisk_parttype *t, const char *str);
262int fdisk_parttype_set_typestr(struct fdisk_parttype *t, const char *str);
263int fdisk_parttype_set_code(struct fdisk_parttype *t, int code);
eac3aac9 264size_t fdisk_label_get_nparttypes(const struct fdisk_label *lb);
dfc6db2a 265struct fdisk_parttype *fdisk_label_get_parttype(const struct fdisk_label *lb, size_t n);
f94e753b
KZ
266int fdisk_label_get_parttype_shortcut(
267 const struct fdisk_label *lb, size_t n,
268 const char **typestr,
269 const char **shortcut,
270 const char **alias);
eac3aac9 271int fdisk_label_has_code_parttypes(const struct fdisk_label *lb);
f94e753b 272int fdisk_label_has_parttypes_shortcuts(const struct fdisk_label *lb);
a745611d 273struct fdisk_parttype *fdisk_label_get_parttype_from_code(
eac3aac9 274 const struct fdisk_label *lb,
a745611d 275 unsigned int code);
a745611d 276struct fdisk_parttype *fdisk_label_get_parttype_from_string(
eac3aac9 277 const struct fdisk_label *lb,
a745611d
KZ
278 const char *str);
279struct fdisk_parttype *fdisk_new_unknown_parttype(unsigned int code,
280 const char *typestr);
dfc6db2a 281struct fdisk_parttype *fdisk_copy_parttype(const struct fdisk_parttype *type);
a745611d 282struct fdisk_parttype *fdisk_label_parse_parttype(
eac3aac9 283 const struct fdisk_label *lb,
a745611d 284 const char *str);
f94e753b
KZ
285struct fdisk_parttype *fdisk_label_advparse_parttype(
286 const struct fdisk_label *lb,
287 const char *str,
288 int flags);
289
290/**
291 * fdisk_parttype_parser_flags:
292 * @FDISK_PARTTYPE_PARSE_DATA: parse hex or UUID from string
293 * @FDISK_PARTTYPE_PARSE_DATALAST: try hex or UUID as the last possibility (don't use!)
c709dbcd
KZ
294 * @FDISK_PARTTYPE_PARSE_SHORTCUT: try input as type shortcut (e.g 'L' for linux partition)
295 * @FDISK_PARTTYPE_PARSE_ALIAS: try input as type alias (e.g. 'linux' for linux partition)
f94e753b
KZ
296 * @FDISK_PARTTYPE_PARSE_DEPRECATED: accept also deprecated aliases and shortcuts
297 * @FDISK_PARTTYPE_PARSE_DEFAULT: recommended flags for new code
298 * @FDISK_PARTTYPE_PARSE_NOUNKNOWN: ignore unknown types
c709dbcd 299 * @FDISK_PARTTYPE_PARSE_SEQNUM: use input as sequntial number of type (e.g. list-types fdisk dialog)
5353ba3f 300 * @FDISK_PARTTYPE_PARSE_NAME: parse type human readable name
f94e753b
KZ
301 */
302enum fdisk_parttype_parser_flags {
303 FDISK_PARTTYPE_PARSE_DATA = (1 << 1),
304 FDISK_PARTTYPE_PARSE_DATALAST = (1 << 2),
305 FDISK_PARTTYPE_PARSE_SHORTCUT = (1 << 3),
306 FDISK_PARTTYPE_PARSE_ALIAS = (1 << 4),
307 FDISK_PARTTYPE_PARSE_DEPRECATED = (1 << 5),
308 FDISK_PARTTYPE_PARSE_NOUNKNOWN = (1 << 6),
309 FDISK_PARTTYPE_PARSE_SEQNUM = (1 << 7),
5353ba3f 310 FDISK_PARTTYPE_PARSE_NAME = (1 << 8),
f94e753b
KZ
311
312 FDISK_PARTTYPE_PARSE_DEFAULT = (FDISK_PARTTYPE_PARSE_DATA | \
313 FDISK_PARTTYPE_PARSE_SHORTCUT | \
314 FDISK_PARTTYPE_PARSE_ALIAS | \
5353ba3f 315 FDISK_PARTTYPE_PARSE_NAME | \
f94e753b
KZ
316 FDISK_PARTTYPE_PARSE_SEQNUM )
317};
318
a745611d
KZ
319const char *fdisk_parttype_get_string(const struct fdisk_parttype *t);
320unsigned int fdisk_parttype_get_code(const struct fdisk_parttype *t);
321const char *fdisk_parttype_get_name(const struct fdisk_parttype *t);
c1ba5863 322int fdisk_parttype_is_unknown(const struct fdisk_parttype *t);
950edd1a 323
e4c5250d
KZ
324
325/* field.c */
326extern int fdisk_field_get_id(const struct fdisk_field *field);
327extern const char *fdisk_field_get_name(const struct fdisk_field *field);
328extern double fdisk_field_get_width(const struct fdisk_field *field);
329extern int fdisk_field_is_number(const struct fdisk_field *field);
330
331
8adbcf0c 332/* label.c */
a78dba34
KZ
333
334/**
f854eca3 335 * fdisk_fieldtype:
9070c2e2
KZ
336 * @FDISK_FIELD_NONE: unspecified item
337 * @FDISK_FIELD_DEVICE: partition device name
338 * @FDISK_FIELD_START: start offset of the partition
339 * @FDISK_FIELD_END: end offset of the partition
340 * @FDISK_FIELD_SECTORS: number of sectors
341 * @FDISK_FIELD_CYLINDERS: number of cylinders (deprecated)
342 * @FDISK_FIELD_SIZE: partition size
343 * @FDISK_FIELD_TYPE: partition type
344 * @FDISK_FIELD_TYPEID: partition type ID
345 * @FDISK_FIELD_ATTR: partition attribute (GPT)
346 * @FDISK_FIELD_BOOT: partition boot flag
347 * @FDISK_FIELD_BSIZE: size of the boot area (BSD)
348 * @FDISK_FIELD_CPG: BSD
349 * @FDISK_FIELD_EADDR: End-C/H/S (MBR)
350 * @FDISK_FIELD_FSIZE: BSD
351 * @FDISK_FIELD_NAME: partition label/name
352 * @FDISK_FIELD_SADDR: Start-C/H/S (MBR)
353 * @FDISK_FIELD_UUID: partition UUID (GPT)
354 * @FDISK_FIELD_FSUUID: Filesystem UUID
355 * @FDISK_FIELD_FSLABEL: Filesystem LABEL
356 * @FDISK_FIELD_FSTYPE: Filesystem type
357 * @FDISK_NFIELDS: Don't use, counter.
a78dba34 358 *
5989556a 359 * Types of fdisk_field. The fields describe a partition.
a78dba34
KZ
360 */
361enum fdisk_fieldtype {
bd85d11f 362 FDISK_FIELD_NONE = 0,
d6faa8e0
KZ
363
364 /* generic */
9070c2e2
KZ
365 FDISK_FIELD_DEVICE,
366 FDISK_FIELD_START,
367 FDISK_FIELD_END,
368 FDISK_FIELD_SECTORS,
369 FDISK_FIELD_CYLINDERS,
370 FDISK_FIELD_SIZE,
371 FDISK_FIELD_TYPE,
372 FDISK_FIELD_TYPEID,
d6faa8e0
KZ
373
374 /* label specific */
9070c2e2
KZ
375 FDISK_FIELD_ATTR,
376 FDISK_FIELD_BOOT,
377 FDISK_FIELD_BSIZE,
378 FDISK_FIELD_CPG,
379 FDISK_FIELD_EADDR,
380 FDISK_FIELD_FSIZE,
381 FDISK_FIELD_NAME,
382 FDISK_FIELD_SADDR,
383 FDISK_FIELD_UUID,
eac3aac9 384
131e38a2
KZ
385 FDISK_FIELD_FSUUID,
386 FDISK_FIELD_FSLABEL,
387 FDISK_FIELD_FSTYPE,
388
eac3aac9 389 FDISK_NFIELDS /* must be last */
21a44c9b
KZ
390};
391
eac3aac9
KZ
392int fdisk_label_get_type(const struct fdisk_label *lb);
393const char *fdisk_label_get_name(const struct fdisk_label *lb);
394int fdisk_label_require_geometry(const struct fdisk_label *lb);
0b52b94c 395
8adbcf0c
KZ
396
397extern int fdisk_write_disklabel(struct fdisk_context *cxt);
398extern int fdisk_verify_disklabel(struct fdisk_context *cxt);
171372d3 399extern int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name);
3c5fb475 400extern int fdisk_list_disklabel(struct fdisk_context *cxt);
9bbcf43f
KZ
401extern int fdisk_locate_disklabel(struct fdisk_context *cxt, int n,
402 const char **name,
403 uint64_t *offset,
404 size_t *size);
8adbcf0c 405
2dd2880f
KZ
406extern int fdisk_label_get_geomrange_cylinders(const struct fdisk_label *lb,
407 fdisk_sector_t *mi, fdisk_sector_t *ma);
408extern int fdisk_label_get_geomrange_heads(const struct fdisk_label *lb,
409 unsigned int *mi, unsigned int *ma);
410extern int fdisk_label_get_geomrange_sectors(const struct fdisk_label *lb,
411 fdisk_sector_t *mi, fdisk_sector_t *ma);
412
5989556a 413/**
f854eca3 414 * fdisk_labelitem_gen:
9070c2e2
KZ
415 * @FDISK_LABELITEM_ID: Unique disk identifier
416 * @__FDISK_NLABELITEMS: Specifies reserved range for generic items (0..7)
5989556a 417 *
9070c2e2 418 * Generic disklabel items.
5989556a
KZ
419 */
420enum fdisk_labelitem_gen {
9070c2e2
KZ
421 FDISK_LABELITEM_ID = 0,
422 __FDISK_NLABELITEMS = 8
5989556a
KZ
423};
424
40c9c3a6
KZ
425/* item.c */
426extern struct fdisk_labelitem *fdisk_new_labelitem(void);
427extern void fdisk_ref_labelitem(struct fdisk_labelitem *li);
428extern int fdisk_reset_labelitem(struct fdisk_labelitem *li);
429extern void fdisk_unref_labelitem(struct fdisk_labelitem *li);
430extern const char *fdisk_labelitem_get_name(struct fdisk_labelitem *li);
431extern int fdisk_labelitem_get_id(struct fdisk_labelitem *li);
432extern int fdisk_labelitem_get_data_u64(struct fdisk_labelitem *li, uint64_t *data);
433extern int fdisk_labelitem_get_data_string(struct fdisk_labelitem *li, const char **data);
434extern int fdisk_labelitem_is_string(struct fdisk_labelitem *li);
435extern int fdisk_labelitem_is_number(struct fdisk_labelitem *li);
436
5989556a 437extern int fdisk_get_disklabel_item(struct fdisk_context *cxt, int id, struct fdisk_labelitem *item);
40c9c3a6 438
21fe3dde 439extern int fdisk_get_disklabel_id(struct fdisk_context *cxt, char **id);
35b1f0a4 440extern int fdisk_set_disklabel_id(struct fdisk_context *cxt);
e5f31446 441extern int fdisk_set_disklabel_id_from_string(struct fdisk_context *cxt, const char *str);
8c0a7f91 442
85151521 443extern int fdisk_get_partition(struct fdisk_context *cxt, size_t partno, struct fdisk_partition **pa);
0dad2177 444extern int fdisk_set_partition(struct fdisk_context *cxt, size_t partno, struct fdisk_partition *pa);
c3bc7483 445extern int fdisk_add_partition(struct fdisk_context *cxt, struct fdisk_partition *pa, size_t *partno);
e11c6684 446extern int fdisk_delete_partition(struct fdisk_context *cxt, size_t partno);
3c0e6b15 447extern int fdisk_delete_all_partitions(struct fdisk_context *cxt);
8adbcf0c 448
131e38a2
KZ
449extern int fdisk_wipe_partition(struct fdisk_context *cxt, size_t partno, int enable);
450
9ffeb235 451extern int fdisk_set_partition_type(struct fdisk_context *cxt, size_t partnum,
171372d3
KZ
452 struct fdisk_parttype *t);
453
0dad2177 454
11ee1177 455extern int fdisk_label_get_fields_ids(
eac3aac9 456 const struct fdisk_label *lb,
11ee1177
KZ
457 struct fdisk_context *cxt,
458 int **ids, size_t *nids);
eac3aac9 459
31ea7fa6
KZ
460extern int fdisk_label_get_fields_ids_all(
461 const struct fdisk_label *lb,
462 struct fdisk_context *cxt,
463 int **ids, size_t *nids);
464
eac3aac9
KZ
465extern const struct fdisk_field *fdisk_label_get_field(const struct fdisk_label *lb, int id);
466extern const struct fdisk_field *fdisk_label_get_field_by_name(
467 const struct fdisk_label *lb,
468 const char *name);
bd85d11f 469
2e3b40d3 470extern void fdisk_label_set_changed(struct fdisk_label *lb, int changed);
eac3aac9 471extern int fdisk_label_is_changed(const struct fdisk_label *lb);
2e3b40d3 472
7a188aed 473extern void fdisk_label_set_disabled(struct fdisk_label *lb, int disabled);
eac3aac9 474extern int fdisk_label_is_disabled(const struct fdisk_label *lb);
7a188aed 475
8c0a7f91
KZ
476extern int fdisk_is_partition_used(struct fdisk_context *cxt, size_t n);
477
a1ef792f 478extern int fdisk_toggle_partition_flag(struct fdisk_context *cxt, size_t partnum, unsigned long flag);
2e3b40d3 479
8c0a7f91
KZ
480extern struct fdisk_partition *fdisk_new_partition(void);
481extern void fdisk_reset_partition(struct fdisk_partition *pa);
d6cfa8b3
KZ
482extern void fdisk_ref_partition(struct fdisk_partition *pa);
483extern void fdisk_unref_partition(struct fdisk_partition *pa);
1de9fddb 484extern int fdisk_partition_is_freespace(struct fdisk_partition *pa);
e5c93999 485
ecf40cda
KZ
486int fdisk_partition_set_start(struct fdisk_partition *pa, uint64_t off);
487int fdisk_partition_unset_start(struct fdisk_partition *pa);
ac6a6b0d 488fdisk_sector_t fdisk_partition_get_start(struct fdisk_partition *pa);
ecf40cda
KZ
489int fdisk_partition_has_start(struct fdisk_partition *pa);
490int fdisk_partition_cmp_start(struct fdisk_partition *a,
e5c93999 491 struct fdisk_partition *b);
ecf40cda
KZ
492int fdisk_partition_start_follow_default(struct fdisk_partition *pa, int enable);
493int fdisk_partition_start_is_default(struct fdisk_partition *pa);
e5c93999 494
ecf40cda
KZ
495int fdisk_partition_set_size(struct fdisk_partition *pa, uint64_t sz);
496int fdisk_partition_unset_size(struct fdisk_partition *pa);
ac6a6b0d 497fdisk_sector_t fdisk_partition_get_size(struct fdisk_partition *pa);
ecf40cda
KZ
498int fdisk_partition_has_size(struct fdisk_partition *pa);
499int fdisk_partition_size_explicit(struct fdisk_partition *pa, int enable);
e5c93999 500
bbfc2429
KZ
501int fdisk_partition_has_end(struct fdisk_partition *pa);
502fdisk_sector_t fdisk_partition_get_end(struct fdisk_partition *pa);
503
0123bd1a
KZ
504int fdisk_partition_set_partno(struct fdisk_partition *pa, size_t num);
505int fdisk_partition_unset_partno(struct fdisk_partition *pa);
506size_t fdisk_partition_get_partno(struct fdisk_partition *pa);
507int fdisk_partition_has_partno(struct fdisk_partition *pa);
508int fdisk_partition_cmp_partno(struct fdisk_partition *a,
509 struct fdisk_partition *b);
131e38a2 510
0123bd1a
KZ
511int fdisk_partition_partno_follow_default(struct fdisk_partition *pa, int enable);
512
dfc6db2a
KZ
513extern int fdisk_partition_set_type(struct fdisk_partition *pa, struct fdisk_parttype *type);
514extern struct fdisk_parttype *fdisk_partition_get_type(struct fdisk_partition *pa);
8c0a7f91
KZ
515extern int fdisk_partition_set_name(struct fdisk_partition *pa, const char *name);
516extern const char *fdisk_partition_get_name(struct fdisk_partition *pa);
517extern int fdisk_partition_set_uuid(struct fdisk_partition *pa, const char *uuid);
c77ba531 518extern int fdisk_partition_set_attrs(struct fdisk_partition *pa, const char *attrs);
8c0a7f91
KZ
519extern const char *fdisk_partition_get_uuid(struct fdisk_partition *pa);
520extern const char *fdisk_partition_get_attrs(struct fdisk_partition *pa);
8c0a7f91 521extern int fdisk_partition_is_nested(struct fdisk_partition *pa);
bd5e8291 522extern int fdisk_partition_is_container(struct fdisk_partition *pa);
03643931 523extern int fdisk_partition_get_parent(struct fdisk_partition *pa, size_t *parent);
8c0a7f91 524extern int fdisk_partition_is_used(struct fdisk_partition *pa);
59c8e95b 525extern int fdisk_partition_is_bootable(struct fdisk_partition *pa);
943271e2 526extern int fdisk_partition_is_wholedisk(struct fdisk_partition *pa);
6c89f750
KZ
527extern int fdisk_partition_to_string(struct fdisk_partition *pa,
528 struct fdisk_context *cxt,
529 int id, char **data);
8c0a7f91 530
0123bd1a 531int fdisk_partition_next_partno(struct fdisk_partition *pa,
6c89f750
KZ
532 struct fdisk_context *cxt,
533 size_t *n);
77d6a70a 534
20f878fe 535extern int fdisk_partition_end_follow_default(struct fdisk_partition *pa, int enable);
0051ec9b 536extern int fdisk_partition_end_is_default(struct fdisk_partition *pa);
20f878fe 537
dd7ba604
KZ
538extern int fdisk_reorder_partitions(struct fdisk_context *cxt);
539
29f2e825
KZ
540extern int fdisk_partition_has_wipe(struct fdisk_context *cxt, struct fdisk_partition *pa);
541
5ee1a36c
TW
542extern int fdisk_partition_get_max_size(struct fdisk_context *cxt, size_t n,
543 fdisk_sector_t *maxsz);
544
29f2e825 545
b48cdebc
KZ
546/* table.c */
547extern struct fdisk_table *fdisk_new_table(void);
548extern int fdisk_reset_table(struct fdisk_table *tb);
549extern void fdisk_ref_table(struct fdisk_table *tb);
550extern void fdisk_unref_table(struct fdisk_table *tb);
e54b1c6f 551extern size_t fdisk_table_get_nents(struct fdisk_table *tb);
b48cdebc
KZ
552extern int fdisk_table_is_empty(struct fdisk_table *tb);
553extern int fdisk_table_add_partition(struct fdisk_table *tb, struct fdisk_partition *pa);
554extern int fdisk_table_remove_partition(struct fdisk_table *tb, struct fdisk_partition *pa);
555
2cec7949
KZ
556extern int fdisk_get_partitions(struct fdisk_context *cxt, struct fdisk_table **tb);
557extern int fdisk_get_freespaces(struct fdisk_context *cxt, struct fdisk_table **tb);
558
1dd63a3b 559
8b60872e 560extern int fdisk_table_wrong_order(struct fdisk_table *tb);
e5c93999
KZ
561extern int fdisk_table_sort_partitions(struct fdisk_table *tb,
562 int (*cmp)(struct fdisk_partition *,
563 struct fdisk_partition *));
564
04406c0d
KZ
565extern int fdisk_table_next_partition(
566 struct fdisk_table *tb,
567 struct fdisk_iter *itr,
568 struct fdisk_partition **pa);
28b6a23c
KZ
569
570extern struct fdisk_partition *fdisk_table_get_partition(
571 struct fdisk_table *tb,
572 size_t n);
b17c1f14
KZ
573extern struct fdisk_partition *fdisk_table_get_partition_by_partno(
574 struct fdisk_table *tb,
575 size_t partno);
576
3c0e6b15 577extern int fdisk_apply_table(struct fdisk_context *cxt, struct fdisk_table *tb);
28b6a23c 578
c578f9af 579/* alignment.c */
8d605c88
KZ
580#define FDISK_ALIGN_UP 1
581#define FDISK_ALIGN_DOWN 2
582#define FDISK_ALIGN_NEAREST 3
583
0073a4cf
KZ
584fdisk_sector_t fdisk_align_lba(struct fdisk_context *cxt, fdisk_sector_t lba, int direction);
585fdisk_sector_t fdisk_align_lba_in_range(struct fdisk_context *cxt,
586 fdisk_sector_t lba, fdisk_sector_t start, fdisk_sector_t stop);
587int fdisk_lba_is_phy_aligned(struct fdisk_context *cxt, fdisk_sector_t lba);
1653f0b0 588
8d605c88 589int fdisk_override_geometry(struct fdisk_context *cxt,
1653f0b0
KZ
590 unsigned int cylinders,
591 unsigned int heads,
592 unsigned int sectors);
8d605c88
KZ
593int fdisk_save_user_geometry(struct fdisk_context *cxt,
594 unsigned int cylinders,
595 unsigned int heads,
596 unsigned int sectors);
597int fdisk_save_user_sector_size(struct fdisk_context *cxt,
1653f0b0
KZ
598 unsigned int phy,
599 unsigned int log);
adf09b5c
KZ
600
601int fdisk_save_user_grain(struct fdisk_context *cxt, unsigned long grain);
602
8d605c88
KZ
603int fdisk_has_user_device_properties(struct fdisk_context *cxt);
604int fdisk_reset_alignment(struct fdisk_context *cxt);
7190b9b2 605int fdisk_reset_device_properties(struct fdisk_context *cxt);
8d605c88 606int fdisk_reread_partition_table(struct fdisk_context *cxt);
1dd63a3b 607int fdisk_reread_changes(struct fdisk_context *cxt, struct fdisk_table *org);
852ce62b 608
6c89f750
KZ
609/* iter.c */
610enum {
611
612 FDISK_ITER_FORWARD = 0,
613 FDISK_ITER_BACKWARD
614};
615extern struct fdisk_iter *fdisk_new_iter(int direction);
616extern void fdisk_free_iter(struct fdisk_iter *itr);
617extern void fdisk_reset_iter(struct fdisk_iter *itr, int direction);
618extern int fdisk_iter_get_direction(struct fdisk_iter *itr);
619
620
852ce62b 621/* dos.c */
b7d101a2
KZ
622#define DOS_FLAG_ACTIVE 1
623
dac364ad 624extern int fdisk_dos_fix_chs(struct fdisk_context *cxt);
b7d101a2 625extern int fdisk_dos_move_begin(struct fdisk_context *cxt, size_t i);
852ce62b
KZ
626extern int fdisk_dos_enable_compatible(struct fdisk_label *lb, int enable);
627extern int fdisk_dos_is_compatible(struct fdisk_label *lb);
628
4170ae9c
KZ
629/* sun.h */
630extern int fdisk_sun_set_alt_cyl(struct fdisk_context *cxt);
631extern int fdisk_sun_set_xcyl(struct fdisk_context *cxt);
632extern int fdisk_sun_set_ilfact(struct fdisk_context *cxt);
633extern int fdisk_sun_set_rspeed(struct fdisk_context *cxt);
634extern int fdisk_sun_set_pcylcount(struct fdisk_context *cxt);
635
f854eca3
KZ
636/**
637 * fdisk_labelitem_sun:
f92c9f37
KZ
638 * @SUN_LABELITEM_LABELID: Label ID
639 * @SUN_LABELITEM_VTOCID: Volume ID
640 * @SUN_LABELITEM_RPM: Rpm
641 * @SUN_LABELITEM_ACYL: Alternate cylinders
642 * @SUN_LABELITEM_PCYL: Physical cylinders
643 * @SUN_LABELITEM_APC: Extra sects/cyl
644 * @SUN_LABELITEM_INTRLV: Interleave
f854eca3
KZ
645 *
646 * SUN specific label items.
647 */
5989556a
KZ
648enum fdisk_labelitem_sun {
649 SUN_LABELITEM_LABELID = __FDISK_NLABELITEMS,
650 SUN_LABELITEM_VTOCID,
651 SUN_LABELITEM_RPM,
652 SUN_LABELITEM_ACYL,
653 SUN_LABELITEM_PCYL,
654 SUN_LABELITEM_APC,
655 SUN_LABELITEM_INTRLV
656};
657
d5b2b8db
KZ
658/* bsd.c */
659extern int fdisk_bsd_edit_disklabel(struct fdisk_context *cxt);
660extern int fdisk_bsd_write_bootstrap(struct fdisk_context *cxt);
661extern int fdisk_bsd_link_partition(struct fdisk_context *cxt);
662
f854eca3
KZ
663/**
664 * fdisk_labelitem_bsd:
f92c9f37
KZ
665 * @BSD_LABELITEM_TYPE: type
666 * @BSD_LABELITEM_DISK: disk
667 * @BSD_LABELITEM_PACKNAME: packname
11026083 668 * @BSD_LABELITEM_FLAGS: flags (removable, ecc, badsect)
f92c9f37
KZ
669 * @BSD_LABELITEM_SECSIZE: Bytes/Sector
670 * @BSD_LABELITEM_NTRACKS: Tracks/Cylinder
671 * @BSD_LABELITEM_SECPERCYL: Sectors/Cylinder
672 * @BSD_LABELITEM_CYLINDERS: Cylinders
673 * @BSD_LABELITEM_RPM: rpm
674 * @BSD_LABELITEM_INTERLEAVE: interleave
675 * @BSD_LABELITEM_TRACKSKEW: trackskew
676 * @BSD_LABELITEM_CYLINDERSKEW: cylinderskew
677 * @BSD_LABELITEM_HEADSWITCH: headswitch
678 * @BSD_LABELITEM_TRKSEEK: track-to-track seek
f854eca3
KZ
679 *
680 * BSD specific label items.
681 */
5989556a
KZ
682enum fdisk_labelitem_bsd {
683 /* specific */
684 BSD_LABELITEM_TYPE = __FDISK_NLABELITEMS,
685 BSD_LABELITEM_DISK,
686 BSD_LABELITEM_PACKNAME,
687 BSD_LABELITEM_FLAGS,
688 BSD_LABELITEM_SECSIZE,
689 BSD_LABELITEM_NTRACKS,
690 BSD_LABELITEM_SECPERCYL,
691 BSD_LABELITEM_CYLINDERS,
692 BSD_LABELITEM_RPM,
693 BSD_LABELITEM_INTERLEAVE,
694 BSD_LABELITEM_TRACKSKEW,
695 BSD_LABELITEM_CYLINDERSKEW,
696 BSD_LABELITEM_HEADSWITCH,
697 BSD_LABELITEM_TRKSEEK
698};
699
067686d8
KZ
700/* sgi.h */
701#define SGI_FLAG_BOOT 1
702#define SGI_FLAG_SWAP 2
ac84272d
KZ
703extern int fdisk_sgi_set_bootfile(struct fdisk_context *cxt);
704extern int fdisk_sgi_create_info(struct fdisk_context *cxt);
067686d8 705
f854eca3
KZ
706/**
707 * fdisk_labelitem_sgi:
f92c9f37
KZ
708 * @SGI_LABELITEM_PCYLCOUNT: Physical cylinders
709 * @SGI_LABELITEM_SPARECYL: Extra sects/cyl
710 * @SGI_LABELITEM_ILFACT: nterleave
711 * @SGI_LABELITEM_BOOTFILE: Bootfile
f854eca3
KZ
712 *
713 * SGI specific label items.
714 */
5989556a
KZ
715enum fdisk_labelitem_sgi {
716 SGI_LABELITEM_PCYLCOUNT = __FDISK_NLABELITEMS,
717 SGI_LABELITEM_SPARECYL,
718 SGI_LABELITEM_ILFACT,
719 SGI_LABELITEM_BOOTFILE
720};
721
34b06299 722/* gpt */
773aae5c 723
0c07055c
KZ
724/*
725 * GPT partition attributes
726 */
727
728/**
729 * GPT_FLAG_REQUIRED:
730 *
731 * GPT attribute; marks a partition as system partition (disk
732 * partitioning utilities must preserve the partition as is)
733 */
734#define GPT_FLAG_REQUIRED 1
735
736/**
737 * GPT_FLAG_NOBLOCK:
738 *
739 * GPT attribute; EFI firmware should ignore the content of the
740 * partition and not try to read from it
741 */
742#define GPT_FLAG_NOBLOCK 2
743
744/**
745 * GPT_FLAG_LEGACYBOOT:
746 *
747 * GPT attribute; use the partition for legacy boot method
748 */
749#define GPT_FLAG_LEGACYBOOT 3
750
751/**
752 * GPT_FLAG_GUIDSPECIFIC:
753 *
754 * GPT attribute; for bites 48-63, defined and used by the individual partition
755 * type.
756 *
757 * The flag GPT_FLAG_GUIDSPECIFIC forces libfdisk to ask (by ask API)
758 * for a bit number. If you want to toggle specific bit and avoid any
759 * dialog, then use the bit number (in range 48..63). For example:
760 *
761 * // start dialog to ask for bit number
762 * fdisk_toggle_partition_flag(cxt, n, GPT_FLAG_GUIDSPECIFIC);
763 *
764 * // toggle bit 60
765 * fdisk_toggle_partition_flag(cxt, n, 60);
766 */
767#define GPT_FLAG_GUIDSPECIFIC 4
c83f772e 768
433d05ff 769extern int fdisk_gpt_is_hybrid(struct fdisk_context *cxt);
b7c015d1 770extern int fdisk_gpt_set_npartitions(struct fdisk_context *cxt, uint32_t nents);
4a4a0927
MM
771extern int fdisk_gpt_get_partition_attrs(struct fdisk_context *cxt, size_t partnum, uint64_t *attrs);
772extern int fdisk_gpt_set_partition_attrs(struct fdisk_context *cxt, size_t partnum, uint64_t attrs);
34b06299 773
387ac277
KZ
774extern void fdisk_gpt_disable_relocation(struct fdisk_label *lb, int disable);
775extern void fdisk_gpt_enable_minimize(struct fdisk_label *lb, int enable);
776
f854eca3
KZ
777/**
778 * fdisk_labelitem_gpt:
f92c9f37
KZ
779 * @GPT_LABELITEM_ID: GPT disklabel UUID (!= partition UUID)
780 * @GPT_LABELITEM_FIRSTLBA: First Usable LBA
b9d930d6 781 * @GPT_LABELITEM_LASTLBA: Last Usable LBA
f92c9f37 782 * @GPT_LABELITEM_ALTLBA: Alternative LBA (backup header LBA)
11026083 783 * @GPT_LABELITEM_ENTRIESLBA: Partitions entries array LBA
f92c9f37 784 * @GPT_LABELITEM_ENTRIESALLOC: Number of allocated entries in entries array
b9d930d6 785 * @GPT_LABELITEM_ENTRIESLASTLBA: Last LBA where is entries array
f854eca3
KZ
786 *
787 * GPT specific label items.
788 */
5989556a
KZ
789enum fdisk_labelitem_gpt {
790 /* generic */
f92c9f37 791 GPT_LABELITEM_ID = FDISK_LABELITEM_ID,
5989556a 792 /* specific */
f92c9f37
KZ
793 GPT_LABELITEM_FIRSTLBA = __FDISK_NLABELITEMS,
794 GPT_LABELITEM_LASTLBA,
795 GPT_LABELITEM_ALTLBA,
796 GPT_LABELITEM_ENTRIESLBA,
b9d930d6
KZ
797 GPT_LABELITEM_ENTRIESALLOC,
798 GPT_LABELITEM_ENTRIESLASTLBA
5989556a 799};
50992267 800
9138d6f9
KZ
801/* script.c */
802struct fdisk_script *fdisk_new_script(struct fdisk_context *cxt);
803struct fdisk_script *fdisk_new_script_from_file(struct fdisk_context *cxt,
804 const char *filename);
805void fdisk_ref_script(struct fdisk_script *dp);
806void fdisk_unref_script(struct fdisk_script *dp);
807
808const char *fdisk_script_get_header(struct fdisk_script *dp, const char *name);
809int fdisk_script_set_header(struct fdisk_script *dp, const char *name, const char *data);
810struct fdisk_table *fdisk_script_get_table(struct fdisk_script *dp);
bfdca6d7 811int fdisk_script_set_table(struct fdisk_script *dp, struct fdisk_table *tb);
3186f4a9 812int fdisk_script_get_nlines(struct fdisk_script *dp);
35ca5118 813int fdisk_script_has_force_label(struct fdisk_script *dp);
9138d6f9 814
5cdbe36f
KZ
815int fdisk_script_set_userdata(struct fdisk_script *dp, void *data);
816void *fdisk_script_get_userdata(struct fdisk_script *dp);
817
818int fdisk_script_set_fgets(struct fdisk_script *dp,
819 char *(*fn_fgets)(struct fdisk_script *, char *, size_t, FILE *));
9138d6f9 820int fdisk_script_read_context(struct fdisk_script *dp, struct fdisk_context *cxt);
3c7fde5f 821int fdisk_script_enable_json(struct fdisk_script *dp, int json);
9138d6f9 822int fdisk_script_write_file(struct fdisk_script *dp, FILE *f);
9138d6f9 823int fdisk_script_read_file(struct fdisk_script *dp, FILE *f);
705854f3 824int fdisk_script_read_line(struct fdisk_script *dp, FILE *f, char *buf, size_t bufsz);
9138d6f9
KZ
825
826int fdisk_set_script(struct fdisk_context *cxt, struct fdisk_script *dp);
827struct fdisk_script *fdisk_get_script(struct fdisk_context *cxt);
828
0051ec9b 829int fdisk_apply_script_headers(struct fdisk_context *cxt, struct fdisk_script *dp);
9138d6f9
KZ
830int fdisk_apply_script(struct fdisk_context *cxt, struct fdisk_script *dp);
831
832
7845ca8d 833/* ask.c */
ab6ea0e8
KZ
834#define fdisk_is_ask(a, x) (fdisk_ask_get_type(a) == FDISK_ASKTYPE_ ## x)
835
a1ef792f
KZ
836int fdisk_set_ask(struct fdisk_context *cxt,
837 int (*ask_cb)(struct fdisk_context *, struct fdisk_ask *, void *),
838 void *data);
839
840
1c01e44f
KZ
841void fdisk_ref_ask(struct fdisk_ask *ask);
842void fdisk_unref_ask(struct fdisk_ask *ask);
843const char *fdisk_ask_get_query(struct fdisk_ask *ask);
844int fdisk_ask_get_type(struct fdisk_ask *ask);
845const char *fdisk_ask_number_get_range(struct fdisk_ask *ask);
846uint64_t fdisk_ask_number_get_default(struct fdisk_ask *ask);
847uint64_t fdisk_ask_number_get_low(struct fdisk_ask *ask);
848uint64_t fdisk_ask_number_get_high(struct fdisk_ask *ask);
849uint64_t fdisk_ask_number_get_result(struct fdisk_ask *ask);
850int fdisk_ask_number_set_result(struct fdisk_ask *ask, uint64_t result);
851uint64_t fdisk_ask_number_get_base(struct fdisk_ask *ask);
852uint64_t fdisk_ask_number_get_unit(struct fdisk_ask *ask);
853int fdisk_ask_number_set_relative(struct fdisk_ask *ask, int relative);
757cefbb 854int fdisk_ask_number_is_wrap_negative(struct fdisk_ask *ask);
1c01e44f
KZ
855int fdisk_ask_number_inchars(struct fdisk_ask *ask);
856int fdisk_ask_partnum(struct fdisk_context *cxt, size_t *partnum, int wantnew);
857
858int fdisk_ask_number(struct fdisk_context *cxt,
24fc19a1
KZ
859 uintmax_t low,
860 uintmax_t dflt,
861 uintmax_t high,
862 const char *query,
863 uintmax_t *result);
1c01e44f
KZ
864char *fdisk_ask_string_get_result(struct fdisk_ask *ask);
865int fdisk_ask_string_set_result(struct fdisk_ask *ask, char *result);
866int fdisk_ask_string(struct fdisk_context *cxt,
34b06299
KZ
867 const char *query,
868 char **result);
1c01e44f
KZ
869int fdisk_ask_yesno(struct fdisk_context *cxt,
870 const char *query,
871 int *result);
872int fdisk_ask_yesno_get_result(struct fdisk_ask *ask);
873int fdisk_ask_yesno_set_result(struct fdisk_ask *ask, int result);
7817415a
KZ
874
875int fdisk_ask_menu(struct fdisk_context *cxt, char *query, int *result, int dflt, ...);
876
1c01e44f
KZ
877int fdisk_ask_menu_get_default(struct fdisk_ask *ask);
878int fdisk_ask_menu_set_result(struct fdisk_ask *ask, int key);
879int fdisk_ask_menu_get_result(struct fdisk_ask *ask, int *key);
880int fdisk_ask_menu_get_item(struct fdisk_ask *ask, size_t idx, int *key,
20f878fe 881 const char **name, const char **desc);
1c01e44f
KZ
882size_t fdisk_ask_menu_get_nitems(struct fdisk_ask *ask);
883int fdisk_ask_print_get_errno(struct fdisk_ask *ask);
884const char *fdisk_ask_print_get_mesg(struct fdisk_ask *ask);
20f878fe 885
fbae1442
KZ
886int fdisk_info(struct fdisk_context *cxt, const char *fmt, ...)
887 __attribute__ ((__format__ (__printf__, 2, 3)));
888int fdisk_warn(struct fdisk_context *cxt, const char *fmt, ...)
889 __attribute__ ((__format__ (__printf__, 2, 3)));
890int fdisk_warnx(struct fdisk_context *cxt, const char *fmt, ...)
891 __attribute__ ((__format__ (__printf__, 2, 3)));
20f878fe 892
0051ec9b
KZ
893/* utils.h */
894extern char *fdisk_partname(const char *dev, size_t partno);
895
d56a7c23
KZ
896#ifdef __cplusplus
897}
898#endif
899
0bb4c979 900#endif /* _LIBFDISK_H */