Add libbtrfsutil
[platform/upstream/btrfs-progs.git] / libbtrfsutil / btrfsutil.h
1 /*
2  * Copyright (C) 2018 Facebook
3  *
4  * This file is part of libbtrfsutil.
5  *
6  * libbtrfsutil is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * libbtrfsutil 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
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with libbtrfsutil.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef BTRFS_UTIL_H
21 #define BTRFS_UTIL_H
22
23 #define BTRFS_UTIL_VERSION_MAJOR 1
24 #define BTRFS_UTIL_VERSION_MINOR 0
25 #define BTRFS_UTIL_VERSION_PATCH 0
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /**
32  * enum btrfs_util_error - libbtrfsutil error codes.
33  *
34  * All functions in libbtrfsutil that can return an error return this type and
35  * set errno.
36  */
37 enum btrfs_util_error {
38         BTRFS_UTIL_OK,
39         BTRFS_UTIL_ERROR_STOP_ITERATION,
40         BTRFS_UTIL_ERROR_NO_MEMORY,
41         BTRFS_UTIL_ERROR_INVALID_ARGUMENT,
42         BTRFS_UTIL_ERROR_NOT_BTRFS,
43         BTRFS_UTIL_ERROR_NOT_SUBVOLUME,
44         BTRFS_UTIL_ERROR_SUBVOLUME_NOT_FOUND,
45         BTRFS_UTIL_ERROR_OPEN_FAILED,
46         BTRFS_UTIL_ERROR_RMDIR_FAILED,
47         BTRFS_UTIL_ERROR_UNLINK_FAILED,
48         BTRFS_UTIL_ERROR_STAT_FAILED,
49         BTRFS_UTIL_ERROR_STATFS_FAILED,
50         BTRFS_UTIL_ERROR_SEARCH_FAILED,
51         BTRFS_UTIL_ERROR_INO_LOOKUP_FAILED,
52         BTRFS_UTIL_ERROR_SUBVOL_GETFLAGS_FAILED,
53         BTRFS_UTIL_ERROR_SUBVOL_SETFLAGS_FAILED,
54         BTRFS_UTIL_ERROR_SUBVOL_CREATE_FAILED,
55         BTRFS_UTIL_ERROR_SNAP_CREATE_FAILED,
56         BTRFS_UTIL_ERROR_SNAP_DESTROY_FAILED,
57         BTRFS_UTIL_ERROR_DEFAULT_SUBVOL_FAILED,
58         BTRFS_UTIL_ERROR_SYNC_FAILED,
59         BTRFS_UTIL_ERROR_START_SYNC_FAILED,
60         BTRFS_UTIL_ERROR_WAIT_SYNC_FAILED,
61 };
62
63 /**
64  * btrfs_util_strerror() - Convert a libtrfsutil error code to a string
65  * description.
66  * @err: The error to convert.
67  *
68  * Return: Error description.
69  */
70 const char *btrfs_util_strerror(enum btrfs_util_error err);
71
72 #ifdef __cplusplus
73 }
74 #endif
75
76 #endif /* BTRFS_UTIL_H */