]> git.ipfire.org Git - thirdparty/util-linux.git/blob - disk-utils/fdisk-list.h
a30cd6a5159c4e082c05d257ef95a32f1c3a7951
[thirdparty/util-linux.git] / disk-utils / fdisk-list.h
1 /*
2 * SPDX-License-Identifier: GPL-2.0-or-later
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * Copyright (C) 2014-2023 Karel Zak <kzak@redhat.com>
10 */
11 #ifndef UTIL_LINUX_FDISK_LIST_H
12 #define UTIL_LINUX_FDISK_LIST_H
13
14 extern void list_disklabel(struct fdisk_context *cxt);
15 extern void list_disk_identifier(struct fdisk_context *cxt);
16 extern void list_disk_geometry(struct fdisk_context *cxt);
17 extern void list_freespace(struct fdisk_context *cxt);
18
19 extern char *next_proc_partition(FILE **f);
20 extern int print_device_pt(struct fdisk_context *cxt, char *device, int warnme, int verify, int separator);
21 extern int print_device_freespace(struct fdisk_context *cxt, char *device, int warnme, int separator);
22
23 extern void print_all_devices_pt(struct fdisk_context *cxt, int verify);
24 extern void print_all_devices_freespace(struct fdisk_context *cxt);
25
26 extern void list_available_columns(FILE *out);
27 extern int *init_fields(struct fdisk_context *cxt, const char *str, size_t *n);
28
29
30 /* used by fdisk and sfdisk */
31 enum {
32 WIPEMODE_AUTO = 0,
33 WIPEMODE_NEVER = 1,
34 WIPEMODE_ALWAYS = 2
35 };
36
37 static inline int wipemode_from_string(const char *str)
38 {
39 size_t i;
40 static const char *modes[] = {
41 [WIPEMODE_AUTO] = "auto",
42 [WIPEMODE_NEVER] = "never",
43 [WIPEMODE_ALWAYS] = "always"
44 };
45
46 if (!str || !*str)
47 return -EINVAL;
48
49 for (i = 0; i < ARRAY_SIZE(modes); i++) {
50 if (strcasecmp(str, modes[i]) == 0)
51 return i;
52 }
53
54 return -EINVAL;
55 }
56
57 #endif /* UTIL_LINUX_FDISK_LIST_H */