xattr-at.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* openat-style fd-relative functions for operating with extended file
  2. attributes.
  3. Copyright 2012-2014 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. /* setxattrat */
  25. #define AT_FUNC_NAME setxattrat
  26. #define AT_FUNC_F1 setxattr
  27. #define AT_FUNC_POST_FILE_PARAM_DECLS , const char *name, const void *value \
  28. , size_t size, int flags
  29. #define AT_FUNC_POST_FILE_ARGS , name, value, size, flags
  30. #include "at-func.c"
  31. #undef AT_FUNC_NAME
  32. #undef AT_FUNC_F1
  33. #undef AT_FUNC_POST_FILE_PARAM_DECLS
  34. #undef AT_FUNC_POST_FILE_ARGS
  35. /* lsetxattrat */
  36. #define AT_FUNC_NAME lsetxattrat
  37. #define AT_FUNC_F1 lsetxattr
  38. #define AT_FUNC_POST_FILE_PARAM_DECLS , const char *name, const void *value \
  39. , size_t size, int flags
  40. #define AT_FUNC_POST_FILE_ARGS , name, value, size, flags
  41. #include "at-func.c"
  42. #undef AT_FUNC_NAME
  43. #undef AT_FUNC_F1
  44. #undef AT_FUNC_POST_FILE_PARAM_DECLS
  45. #undef AT_FUNC_POST_FILE_ARGS
  46. /* getxattrat */
  47. #define AT_FUNC_NAME getxattrat
  48. #define AT_FUNC_RESULT ssize_t
  49. #define AT_FUNC_F1 getxattr
  50. #define AT_FUNC_POST_FILE_PARAM_DECLS , const char *name, void *value \
  51. , size_t size
  52. #define AT_FUNC_POST_FILE_ARGS , name, value, size
  53. #include "at-func.c"
  54. #undef AT_FUNC_NAME
  55. #undef AT_FUNC_F1
  56. #undef AT_FUNC_RESULT
  57. #undef AT_FUNC_POST_FILE_PARAM_DECLS
  58. #undef AT_FUNC_POST_FILE_ARGS
  59. /* lgetxattrat */
  60. #define AT_FUNC_NAME lgetxattrat
  61. #define AT_FUNC_RESULT ssize_t
  62. #define AT_FUNC_F1 lgetxattr
  63. #define AT_FUNC_POST_FILE_PARAM_DECLS , const char *name, void *value \
  64. , size_t size
  65. #define AT_FUNC_POST_FILE_ARGS , name, value, size
  66. #include "at-func.c"
  67. #undef AT_FUNC_NAME
  68. #undef AT_FUNC_F1
  69. #undef AT_FUNC_RESULT
  70. #undef AT_FUNC_POST_FILE_PARAM_DECLS
  71. #undef AT_FUNC_POST_FILE_ARGS
  72. /* listxattrat */
  73. #define AT_FUNC_NAME listxattrat
  74. #define AT_FUNC_RESULT ssize_t
  75. #define AT_FUNC_F1 listxattr
  76. #define AT_FUNC_POST_FILE_PARAM_DECLS , char *list , size_t size
  77. #define AT_FUNC_POST_FILE_ARGS , list , size
  78. #include "at-func.c"
  79. #undef AT_FUNC_NAME
  80. #undef AT_FUNC_F1
  81. #undef AT_FUNC_RESULT
  82. #undef AT_FUNC_POST_FILE_PARAM_DECLS
  83. #undef AT_FUNC_POST_FILE_ARGS
  84. /* llistxattrat */
  85. #define AT_FUNC_NAME llistxattrat
  86. #define AT_FUNC_RESULT ssize_t
  87. #define AT_FUNC_F1 llistxattr
  88. #define AT_FUNC_POST_FILE_PARAM_DECLS , char *list , size_t size
  89. #define AT_FUNC_POST_FILE_ARGS , list , size
  90. #include "at-func.c"
  91. #undef AT_FUNC_NAME
  92. #undef AT_FUNC_F1
  93. #undef AT_FUNC_RESULT
  94. #undef AT_FUNC_POST_FILE_PARAM_DECLS
  95. #undef AT_FUNC_POST_FILE_ARGS