btrfs-progs: remove useless branch in __merge_refs
[btrfs-progs-unstable/devel.git] / libbtrfsutil / errors.c
blob634edc65c6ddfbaf349483fa788fc4fed32e2ee8
1 /*
2 * Copyright (C) 2018 Facebook
4 * This file is part of libbtrfsutil.
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.
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.
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/>.
20 #include <stddef.h>
22 #include "btrfsutil_internal.h"
24 static const char * const error_messages[] = {
25 [BTRFS_UTIL_OK] = "Success",
26 [BTRFS_UTIL_ERROR_STOP_ITERATION] = "Stop iteration",
27 [BTRFS_UTIL_ERROR_NO_MEMORY] = "Cannot allocate memory",
28 [BTRFS_UTIL_ERROR_INVALID_ARGUMENT] = "Invalid argument",
29 [BTRFS_UTIL_ERROR_NOT_BTRFS] = "Not a Btrfs filesystem",
30 [BTRFS_UTIL_ERROR_NOT_SUBVOLUME] = "Not a Btrfs subvolume",
31 [BTRFS_UTIL_ERROR_SUBVOLUME_NOT_FOUND] = "Subvolume not found",
32 [BTRFS_UTIL_ERROR_OPEN_FAILED] = "Could not open",
33 [BTRFS_UTIL_ERROR_RMDIR_FAILED] = "Could not rmdir",
34 [BTRFS_UTIL_ERROR_UNLINK_FAILED] = "Could not unlink",
35 [BTRFS_UTIL_ERROR_STAT_FAILED] = "Could not stat",
36 [BTRFS_UTIL_ERROR_STATFS_FAILED] = "Could not statfs",
37 [BTRFS_UTIL_ERROR_SEARCH_FAILED] = "Could not search B-tree",
38 [BTRFS_UTIL_ERROR_INO_LOOKUP_FAILED] = "Could not lookup inode",
39 [BTRFS_UTIL_ERROR_SUBVOL_GETFLAGS_FAILED] = "Could not get subvolume flags",
40 [BTRFS_UTIL_ERROR_SUBVOL_SETFLAGS_FAILED] = "Could not set subvolume flags",
41 [BTRFS_UTIL_ERROR_SUBVOL_CREATE_FAILED] = "Could not create subvolume",
42 [BTRFS_UTIL_ERROR_SNAP_CREATE_FAILED] = "Could not create snapshot",
43 [BTRFS_UTIL_ERROR_SNAP_DESTROY_FAILED] = "Could not destroy subvolume/snapshot",
44 [BTRFS_UTIL_ERROR_DEFAULT_SUBVOL_FAILED] = "Could not set default subvolume",
45 [BTRFS_UTIL_ERROR_SYNC_FAILED] = "Could not sync filesystem",
46 [BTRFS_UTIL_ERROR_START_SYNC_FAILED] = "Could not start filesystem sync",
47 [BTRFS_UTIL_ERROR_WAIT_SYNC_FAILED] = "Could not wait for filesystem sync",
50 PUBLIC const char *btrfs_util_strerror(enum btrfs_util_error err)
52 if (err < 0 || err >= sizeof(error_messages) / sizeof(error_messages[0]))
53 return NULL;
54 return error_messages[err];