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