xattr-at.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Prototypes for openat-style fd-relative functions for operating with
  2. extended file attributes.
  3. Copyright 2012-2023 Free Software Foundation, Inc.
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef XATTRS_AT_H
  15. #define XATTRS_AT_H
  16. #include <sys/types.h>
  17. #if defined(HAVE_SYS_XATTR_H)
  18. # include <sys/xattr.h>
  19. #elif defined(HAVE_ATTR_XATTR_H)
  20. # include <attr/xattr.h>
  21. #endif
  22. #include <errno.h>
  23. #ifndef ENOATTR
  24. # define ENOATTR ENODATA /* No such attribute */
  25. #endif
  26. /* These are the dir-fd-relative variants of the functions without the
  27. "at" suffix. For example, setxattrat (AT_FDCWD, path, name, value, size,
  28. flags &c) is usually equivalent to setxattr (file, name, value, size,
  29. flags). For more info use the setxattr(2), getxattr(2) or listxattr(2)
  30. manpages. */
  31. /* dir-fd-relative setxattr. Operation sets the VALUE of the extended
  32. attribute identified by NAME and associated with the given PATH in the
  33. filesystem relatively to directory identified by DIR_FD. See the
  34. setxattr(2) manpage for the description of all parameters. */
  35. int setxattrat (int dir_fd, const char *path, const char *name,
  36. const void *value, size_t size, int flags);
  37. /* dir-fd-relative lsetxattr. This function is just like setxattrat,
  38. except when DIR_FD and FILE specify a symlink: lsetxattrat operates on the
  39. symlink, while the setxattrat operates on the referent of the symlink. */
  40. int lsetxattrat (int dir_fd, const char *path, const char *name,
  41. const void *value, size_t size, int flags);
  42. /* dir-fd-relative getxattr. Operation gets the VALUE of the extended
  43. attribute idenfified by NAME and associated with the given PATH in the
  44. filesystem relatively to directory identified by DIR_FD. For more info
  45. about all parameters see the getxattr(2) manpage. */
  46. ssize_t getxattrat (int dir_fd, const char *path, const char *name,
  47. void *value, size_t size);
  48. /* dir-fd-relative lgetxattr. This function is just like getxattrat,
  49. except when DIR_FD and FILE specify a symlink: lgetxattrat operates on the
  50. symlink, while the getxattrat operates on the referent of the symlink. */
  51. ssize_t lgetxattrat (int dir_fd, const char *path, const char *name,
  52. void *value, size_t size);
  53. /* dir-fd-relative listxattr. Obtain the list of extended attributes names. For
  54. more info see the listxattr(2) manpage. */
  55. ssize_t listxattrat (int dir_fd, const char *path, char *list, size_t size);
  56. /* dir-fd-relative llistxattr. This function is just like listxattrat,
  57. except when DIR_FD and FILE specify a symlink: llistxattr operates on the
  58. symlink, while the listxattrat operates on the referent of the symlink. */
  59. ssize_t llistxattrat (int dir_fd, const char *path, char *list, size_t size);
  60. #endif /* XATTRS_AT_H */