fileattr.h 1.9 KB

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