]>
Commit | Line | Data |
---|---|---|
d56a7c23 KZ |
1 | /* |
2 | * libfdisk.h - libfdisk API | |
3 | * | |
4 | * Copyright (C) 2012 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_FDISK_H | |
22 | #define _LIBFDISK_FDISK_H | |
23 | ||
24 | #ifdef __cplusplus | |
25 | extern "C" { | |
26 | #endif | |
27 | ||
a5fe1b3f | 28 | struct fdisk_context; |
0c5d095e | 29 | struct fdisk_label; |
a5fe1b3f | 30 | struct fdisk_parttype; |
7845ca8d | 31 | struct fdisk_ask; |
a5fe1b3f | 32 | |
8adbcf0c KZ |
33 | /* |
34 | * Supported partition table types (labels) | |
35 | */ | |
36 | enum fdisk_labeltype { | |
37 | FDISK_DISKLABEL_DOS = 1, | |
38 | FDISK_DISKLABEL_SUN = 2, | |
39 | FDISK_DISKLABEL_SGI = 4, | |
40 | FDISK_DISKLABEL_AIX = 8, | |
41 | FDISK_DISKLABEL_OSF = 16, | |
42 | FDISK_DISKLABEL_MAC = 32, | |
43 | FDISK_DISKLABEL_GPT = 64, | |
44 | FDISK_DISKLABEL_ANY = -1 | |
45 | }; | |
46 | ||
47b8e7c0 | 47 | enum { |
7845ca8d | 48 | FDISK_PARTSTAT_NONE = 0, |
47b8e7c0 KZ |
49 | FDISK_PARTSTAT_USED /* partition used */ |
50 | }; | |
51 | ||
d56a7c23 KZ |
52 | /* init.c */ |
53 | extern void fdisk_init_debug(int mask); | |
54 | ||
f4be9e2b | 55 | /* context.h */ |
4e0e8253 | 56 | extern struct fdisk_context *fdisk_new_context(void); |
f4be9e2b KZ |
57 | extern void fdisk_free_context(struct fdisk_context *cxt); |
58 | ||
7845ca8d KZ |
59 | extern int fdisk_context_set_ask(struct fdisk_context *cxt, |
60 | int (*ask_cb)(struct fdisk_context *, struct fdisk_ask *, void *), | |
61 | void *data); | |
62 | ||
4e0e8253 KZ |
63 | extern int fdisk_context_assign_device(struct fdisk_context *cxt, |
64 | const char *fname, int readonly); | |
65 | ||
0c5d095e KZ |
66 | extern struct fdisk_label *fdisk_context_get_label(struct fdisk_context *cxt, |
67 | const char *name); | |
68 | ||
53b422ab KZ |
69 | extern int fdisk_context_switch_label(struct fdisk_context *cxt, |
70 | const char *name); | |
71 | ||
a5fe1b3f KZ |
72 | /* parttype.c */ |
73 | extern struct fdisk_parttype *fdisk_get_parttype_from_code(struct fdisk_context *cxt, | |
74 | unsigned int code); | |
75 | extern struct fdisk_parttype *fdisk_get_parttype_from_string(struct fdisk_context *cxt, | |
76 | const char *str); | |
77 | extern struct fdisk_parttype *fdisk_parse_parttype(struct fdisk_context *cxt, const char *str); | |
78 | ||
79 | extern struct fdisk_parttype *fdisk_new_unknown_parttype(unsigned int type, const char *typestr); | |
80 | extern void fdisk_free_parttype(struct fdisk_parttype *type); | |
81 | extern size_t fdisk_get_nparttypes(struct fdisk_context *cxt); | |
82 | ||
8adbcf0c KZ |
83 | /* label.c */ |
84 | extern int fdisk_dev_has_disklabel(struct fdisk_context *cxt); | |
85 | ||
86 | extern int fdisk_dev_is_disklabel(struct fdisk_context *cxt, enum fdisk_labeltype l); | |
87 | #define fdisk_is_disklabel(c, x) fdisk_dev_is_disklabel(c, FDISK_DISKLABEL_ ## x) | |
88 | ||
89 | extern int fdisk_write_disklabel(struct fdisk_context *cxt); | |
90 | extern int fdisk_verify_disklabel(struct fdisk_context *cxt); | |
171372d3 | 91 | extern int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name); |
8adbcf0c | 92 | |
7845ca8d | 93 | extern int fdisk_add_partition(struct fdisk_context *cxt, struct fdisk_parttype *t); |
9ffeb235 | 94 | extern int fdisk_delete_partition(struct fdisk_context *cxt, size_t partnum); |
8adbcf0c | 95 | |
9ffeb235 KZ |
96 | extern struct fdisk_parttype *fdisk_get_partition_type(struct fdisk_context *cxt, size_t partnum); |
97 | extern int fdisk_set_partition_type(struct fdisk_context *cxt, size_t partnum, | |
171372d3 KZ |
98 | struct fdisk_parttype *t); |
99 | ||
2e3b40d3 KZ |
100 | extern void fdisk_label_set_changed(struct fdisk_label *lb, int changed); |
101 | extern int fdisk_label_is_changed(struct fdisk_label *lb); | |
102 | ||
9ffeb235 | 103 | extern int fdisk_partition_get_status(struct fdisk_context *cxt, size_t partnum, int *status); |
2e3b40d3 | 104 | |
c578f9af KZ |
105 | /* alignment.c */ |
106 | extern int fdisk_reset_alignment(struct fdisk_context *cxt); | |
107 | ||
852ce62b KZ |
108 | |
109 | /* dos.c */ | |
110 | extern int fdisk_dos_enable_compatible(struct fdisk_label *lb, int enable); | |
111 | extern int fdisk_dos_is_compatible(struct fdisk_label *lb); | |
112 | ||
7845ca8d KZ |
113 | /* ask.c */ |
114 | extern const char *fdisk_ask_get_question(struct fdisk_ask *ask); | |
115 | extern int fdisk_ask_get_type(struct fdisk_ask *ask); | |
116 | extern const char *fdisk_ask_number_get_range(struct fdisk_ask *ask); | |
117 | extern uint64_t fdisk_ask_number_get_default(struct fdisk_ask *ask); | |
118 | extern uint64_t fdisk_ask_number_get_low(struct fdisk_ask *ask); | |
119 | extern uint64_t fdisk_ask_number_get_high(struct fdisk_ask *ask); | |
120 | extern int fdisk_ask_number_set_result(struct fdisk_ask *ask, uint64_t result); | |
121 | ||
d56a7c23 KZ |
122 | #ifdef __cplusplus |
123 | } | |
124 | #endif | |
125 | ||
126 | #endif /* _LIBFDISK_FDISK_H */ |