]>
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 KZ |
30 | struct fdisk_parttype; |
31 | ||
8adbcf0c KZ |
32 | /* |
33 | * Supported partition table types (labels) | |
34 | */ | |
35 | enum fdisk_labeltype { | |
36 | FDISK_DISKLABEL_DOS = 1, | |
37 | FDISK_DISKLABEL_SUN = 2, | |
38 | FDISK_DISKLABEL_SGI = 4, | |
39 | FDISK_DISKLABEL_AIX = 8, | |
40 | FDISK_DISKLABEL_OSF = 16, | |
41 | FDISK_DISKLABEL_MAC = 32, | |
42 | FDISK_DISKLABEL_GPT = 64, | |
43 | FDISK_DISKLABEL_ANY = -1 | |
44 | }; | |
45 | ||
d56a7c23 KZ |
46 | /* init.c */ |
47 | extern void fdisk_init_debug(int mask); | |
48 | ||
f4be9e2b | 49 | /* context.h */ |
4e0e8253 | 50 | extern struct fdisk_context *fdisk_new_context(void); |
f4be9e2b KZ |
51 | extern void fdisk_free_context(struct fdisk_context *cxt); |
52 | ||
4e0e8253 KZ |
53 | extern int fdisk_context_assign_device(struct fdisk_context *cxt, |
54 | const char *fname, int readonly); | |
55 | ||
0c5d095e KZ |
56 | extern struct fdisk_label *fdisk_context_get_label(struct fdisk_context *cxt, |
57 | const char *name); | |
58 | ||
a5fe1b3f KZ |
59 | /* parttype.c */ |
60 | extern struct fdisk_parttype *fdisk_get_parttype_from_code(struct fdisk_context *cxt, | |
61 | unsigned int code); | |
62 | extern struct fdisk_parttype *fdisk_get_parttype_from_string(struct fdisk_context *cxt, | |
63 | const char *str); | |
64 | extern struct fdisk_parttype *fdisk_parse_parttype(struct fdisk_context *cxt, const char *str); | |
65 | ||
66 | extern struct fdisk_parttype *fdisk_new_unknown_parttype(unsigned int type, const char *typestr); | |
67 | extern void fdisk_free_parttype(struct fdisk_parttype *type); | |
68 | extern size_t fdisk_get_nparttypes(struct fdisk_context *cxt); | |
69 | ||
8adbcf0c KZ |
70 | /* label.c */ |
71 | extern int fdisk_dev_has_disklabel(struct fdisk_context *cxt); | |
72 | ||
73 | extern int fdisk_dev_is_disklabel(struct fdisk_context *cxt, enum fdisk_labeltype l); | |
74 | #define fdisk_is_disklabel(c, x) fdisk_dev_is_disklabel(c, FDISK_DISKLABEL_ ## x) | |
75 | ||
76 | extern int fdisk_write_disklabel(struct fdisk_context *cxt); | |
77 | extern int fdisk_verify_disklabel(struct fdisk_context *cxt); | |
171372d3 | 78 | extern int fdisk_create_disklabel(struct fdisk_context *cxt, const char *name); |
8adbcf0c KZ |
79 | |
80 | extern int fdisk_add_partition(struct fdisk_context *cxt, int partnum, struct fdisk_parttype *t); | |
81 | extern int fdisk_delete_partition(struct fdisk_context *cxt, int partnum); | |
82 | ||
171372d3 KZ |
83 | extern struct fdisk_parttype *fdisk_get_partition_type(struct fdisk_context *cxt, int partnum); |
84 | extern int fdisk_set_partition_type(struct fdisk_context *cxt, int partnum, | |
85 | struct fdisk_parttype *t); | |
86 | ||
c578f9af KZ |
87 | /* alignment.c */ |
88 | extern int fdisk_reset_alignment(struct fdisk_context *cxt); | |
89 | ||
d56a7c23 KZ |
90 | #ifdef __cplusplus |
91 | } | |
92 | #endif | |
93 | ||
94 | #endif /* _LIBFDISK_FDISK_H */ |