1 /* SPDX-License-Identifier: GPL-2.0 */
3 #ifndef _LINUX_FILEATTR_H
4 #define _LINUX_FILEATTR_H
6 /* Flags shared betwen flags/xflags */
8 (FS_SYNC_FL | FS_IMMUTABLE_FL | FS_APPEND_FL | \
9 FS_NODUMP_FL | FS_NOATIME_FL | FS_DAX_FL | \
12 #define FS_XFLAG_COMMON \
13 (FS_XFLAG_SYNC | FS_XFLAG_IMMUTABLE | FS_XFLAG_APPEND | \
14 FS_XFLAG_NODUMP | FS_XFLAG_NOATIME | FS_XFLAG_DAX | \
18 * Merged interface for miscellaneous file attributes. 'flags' originates from
19 * ext* and 'fsx_flags' from xfs. There's some overlap between the two, which
20 * is handled by the VFS helpers, so filesystems are free to implement just one
21 * or both of these sub-interfaces.
24 u32 flags; /* flags (FS_IOC_GETFLAGS/FS_IOC_SETFLAGS) */
26 u32 fsx_xflags; /* xflags field value (get/set) */
27 u32 fsx_extsize; /* extsize field value (get/set)*/
28 u32 fsx_nextents; /* nextents field value (get) */
29 u32 fsx_projid; /* project identifier (get/set) */
30 u32 fsx_cowextsize; /* CoW extsize field value (get/set)*/
36 int copy_fsxattr_to_user(const struct fileattr *fa, struct fsxattr __user *ufa);
38 void fileattr_fill_xflags(struct fileattr *fa, u32 xflags);
39 void fileattr_fill_flags(struct fileattr *fa, u32 flags);
42 * fileattr_has_fsx - check for extended flags/attributes
43 * @fa: fileattr pointer
45 * Return: true if any attributes are present that are not represented in
48 static inline bool fileattr_has_fsx(const struct fileattr *fa)
50 return fa->fsx_valid &&
51 ((fa->fsx_xflags & ~FS_XFLAG_COMMON) || fa->fsx_extsize != 0 ||
52 fa->fsx_projid != 0 || fa->fsx_cowextsize != 0);
55 int vfs_fileattr_get(struct dentry *dentry, struct fileattr *fa);
56 int vfs_fileattr_set(struct user_namespace *mnt_userns, struct dentry *dentry,
59 #endif /* _LINUX_FILEATTR_H */