xattr-at.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* openat-style fd-relative functions for operating with extended file
  2. 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. #include <config.h>
  15. #include "xattr-at.h"
  16. #include "openat.h"
  17. #include <stdlib.h>
  18. #include <unistd.h>
  19. #include <errno.h>
  20. #include <fcntl.h>
  21. #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
  22. #include "save-cwd.h"
  23. #include "openat-priv.h"
  24. #ifdef HAVE_XATTRS
  25. /* setxattrat */
  26. #define AT_FUNC_NAME setxattrat
  27. #define AT_FUNC_F1 setxattr
  28. #define AT_FUNC_POST_FILE_PARAM_DECLS , const char *name, const void *value \
  29. , size_t size, int flags
  30. #define AT_FUNC_POST_FILE_ARGS , name, value, size, flags
  31. #include "at-func.c"
  32. #undef AT_FUNC_NAME
  33. #undef AT_FUNC_F1
  34. #undef AT_FUNC_POST_FILE_PARAM_DECLS
  35. #undef AT_FUNC_POST_FILE_ARGS
  36. /* lsetxattrat */
  37. #define AT_FUNC_NAME lsetxattrat
  38. #define AT_FUNC_F1 lsetxattr
  39. #define AT_FUNC_POST_FILE_PARAM_DECLS , const char *name, const void *value \
  40. , size_t size, int flags
  41. #define AT_FUNC_POST_FILE_ARGS , name, value, size, flags
  42. #include "at-func.c"
  43. #undef AT_FUNC_NAME
  44. #undef AT_FUNC_F1
  45. #undef AT_FUNC_POST_FILE_PARAM_DECLS
  46. #undef AT_FUNC_POST_FILE_ARGS
  47. /* getxattrat */
  48. #define AT_FUNC_NAME getxattrat
  49. #define AT_FUNC_RESULT ssize_t
  50. #define AT_FUNC_F1 getxattr
  51. #define AT_FUNC_POST_FILE_PARAM_DECLS , const char *name, void *value \
  52. , size_t size
  53. #define AT_FUNC_POST_FILE_ARGS , name, value, size
  54. #include "at-func.c"
  55. #undef AT_FUNC_NAME
  56. #undef AT_FUNC_F1
  57. #undef AT_FUNC_RESULT
  58. #undef AT_FUNC_POST_FILE_PARAM_DECLS
  59. #undef AT_FUNC_POST_FILE_ARGS
  60. /* lgetxattrat */
  61. #define AT_FUNC_NAME lgetxattrat
  62. #define AT_FUNC_RESULT ssize_t
  63. #define AT_FUNC_F1 lgetxattr
  64. #define AT_FUNC_POST_FILE_PARAM_DECLS , const char *name, void *value \
  65. , size_t size
  66. #define AT_FUNC_POST_FILE_ARGS , name, value, size
  67. #include "at-func.c"
  68. #undef AT_FUNC_NAME
  69. #undef AT_FUNC_F1
  70. #undef AT_FUNC_RESULT
  71. #undef AT_FUNC_POST_FILE_PARAM_DECLS
  72. #undef AT_FUNC_POST_FILE_ARGS
  73. /* listxattrat */
  74. #define AT_FUNC_NAME listxattrat
  75. #define AT_FUNC_RESULT ssize_t
  76. #define AT_FUNC_F1 listxattr
  77. #define AT_FUNC_POST_FILE_PARAM_DECLS , char *list , size_t size
  78. #define AT_FUNC_POST_FILE_ARGS , list , size
  79. #include "at-func.c"
  80. #undef AT_FUNC_NAME
  81. #undef AT_FUNC_F1
  82. #undef AT_FUNC_RESULT
  83. #undef AT_FUNC_POST_FILE_PARAM_DECLS
  84. #undef AT_FUNC_POST_FILE_ARGS
  85. /* llistxattrat */
  86. #define AT_FUNC_NAME llistxattrat
  87. #define AT_FUNC_RESULT ssize_t
  88. #define AT_FUNC_F1 llistxattr
  89. #define AT_FUNC_POST_FILE_PARAM_DECLS , char *list , size_t size
  90. #define AT_FUNC_POST_FILE_ARGS , list , size
  91. #include "at-func.c"
  92. #undef AT_FUNC_NAME
  93. #undef AT_FUNC_F1
  94. #undef AT_FUNC_RESULT
  95. #undef AT_FUNC_POST_FILE_PARAM_DECLS
  96. #undef AT_FUNC_POST_FILE_ARGS
  97. #endif /* HAVE_XATTRS */