]> Sergey Matveev's repositories - bfs.git/blob - src/fsade.h
Skip mtab
[bfs.git] / src / fsade.h
1 // Copyright © Tavian Barnes <tavianator@tavianator.com>
2 // SPDX-License-Identifier: 0BSD
3
4 /**
5  * A facade over (file)system features that are (un)implemented differently
6  * between platforms.
7  */
8
9 #ifndef BFS_FSADE_H
10 #define BFS_FSADE_H
11
12 #include "config.h"
13
14 #define BFS_CAN_CHECK_ACL BFS_USE_SYS_ACL_H
15
16 #if !defined(BFS_CAN_CHECK_CAPABILITIES) && BFS_USE_SYS_CAPABILITY_H
17 #  include <sys/capability.h>
18 #  ifdef CAP_CHOWN
19 #    define BFS_CAN_CHECK_CAPABILITIES true
20 #  endif
21 #endif
22
23 #define BFS_CAN_CHECK_XATTRS (BFS_USE_SYS_EXTATTR_H || BFS_USE_SYS_XATTR_H)
24
25 struct BFTW;
26
27 /**
28  * Check if a file has a non-trivial Access Control List.
29  *
30  * @param ftwbuf
31  *         The file to check.
32  * @return
33  *         1 if it does, 0 if it doesn't, or -1 if an error occurred.
34  */
35 int bfs_check_acl(const struct BFTW *ftwbuf);
36
37 /**
38  * Check if a file has a non-trivial capability set.
39  *
40  * @param ftwbuf
41  *         The file to check.
42  * @return
43  *         1 if it does, 0 if it doesn't, or -1 if an error occurred.
44  */
45 int bfs_check_capabilities(const struct BFTW *ftwbuf);
46
47 /**
48  * Check if a file has any extended attributes set.
49  *
50  * @param ftwbuf
51  *         The file to check.
52  * @return
53  *         1 if it does, 0 if it doesn't, or -1 if an error occurred.
54  */
55 int bfs_check_xattrs(const struct BFTW *ftwbuf);
56
57 /**
58  * Check if a file has an extended attribute with the given name.
59  *
60  * @param ftwbuf
61  *         The file to check.
62  * @param name
63  *         The name of the xattr to check.
64  * @return
65  *         1 if it does, 0 if it doesn't, or -1 if an error occurred.
66  */
67 int bfs_check_xattr_named(const struct BFTW *ftwbuf, const char *name);
68
69 #endif // BFS_FSADE_H