1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_FS_IOCTL_H
3 #define _BCACHEFS_FS_IOCTL_H
7 /* bcachefs inode flags -> vfs inode flags: */
8 static const __maybe_unused unsigned bch_flags_to_vfs[] = {
9 [__BCH_INODE_sync] = S_SYNC,
10 [__BCH_INODE_immutable] = S_IMMUTABLE,
11 [__BCH_INODE_append] = S_APPEND,
12 [__BCH_INODE_noatime] = S_NOATIME,
15 /* bcachefs inode flags -> FS_IOC_GETFLAGS: */
16 static const __maybe_unused unsigned bch_flags_to_uflags[] = {
17 [__BCH_INODE_sync] = FS_SYNC_FL,
18 [__BCH_INODE_immutable] = FS_IMMUTABLE_FL,
19 [__BCH_INODE_append] = FS_APPEND_FL,
20 [__BCH_INODE_nodump] = FS_NODUMP_FL,
21 [__BCH_INODE_noatime] = FS_NOATIME_FL,
24 /* bcachefs inode flags -> FS_IOC_FSGETXATTR: */
25 static const __maybe_unused unsigned bch_flags_to_xflags[] = {
26 [__BCH_INODE_sync] = FS_XFLAG_SYNC,
27 [__BCH_INODE_immutable] = FS_XFLAG_IMMUTABLE,
28 [__BCH_INODE_append] = FS_XFLAG_APPEND,
29 [__BCH_INODE_nodump] = FS_XFLAG_NODUMP,
30 [__BCH_INODE_noatime] = FS_XFLAG_NOATIME,
31 //[__BCH_INODE_PROJINHERIT] = FS_XFLAG_PROJINHERIT;
34 #define set_flags(_map, _in, _out) \
38 for (_i = 0; _i < ARRAY_SIZE(_map); _i++) \
39 if ((_in) & (1 << _i)) \
42 (_out) &= ~_map[_i]; \
45 #define map_flags(_map, _in) \
49 set_flags(_map, _in, _out); \
53 #define map_flags_rev(_map, _in) \
55 unsigned _i, _out = 0; \
57 for (_i = 0; _i < ARRAY_SIZE(_map); _i++) \
58 if ((_in) & _map[_i]) { \
65 #define map_defined(_map) \
69 map_flags_rev(_map, _in); \
72 /* Set VFS inode flags from bcachefs inode: */
73 static inline void bch2_inode_flags_to_vfs(struct bch_inode_info *inode)
75 set_flags(bch_flags_to_vfs, inode->ei_inode.bi_flags, inode->v.i_flags);
78 long bch2_fs_file_ioctl(struct file *, unsigned, unsigned long);
79 long bch2_compat_fs_ioctl(struct file *, unsigned, unsigned long);
81 #endif /* _BCACHEFS_FS_IOCTL_H */