1
0

xattr.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Copyright (C) 2002-2026 Free Software Foundation, Inc.
  17. This file is part of the GNU C Library.
  18. The GNU C Library is free software; you can redistribute it and/or
  19. modify it under the terms of the GNU Lesser General Public
  20. License as published by the Free Software Foundation; either
  21. version 2.1 of the License, or (at your option) any later version.
  22. The GNU C Library is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  25. Lesser General Public License for more details.
  26. You should have received a copy of the GNU Lesser General Public
  27. License along with the GNU C Library; if not, see
  28. <https://www.gnu.org/licenses/>. */
  29. #ifndef _SYS_XATTR_H
  30. #define _SYS_XATTR_H 1
  31. #include <features.h>
  32. #include <sys/types.h>
  33. __BEGIN_DECLS
  34. /* The following constants should be used for the fifth parameter of
  35. `*setxattr'. */
  36. #ifndef __USE_KERNEL_XATTR_DEFS
  37. enum
  38. {
  39. XATTR_CREATE = 1, /* set value, fail if attr already exists. */
  40. #define XATTR_CREATE XATTR_CREATE
  41. XATTR_REPLACE = 2 /* set value, fail if attr does not exist. */
  42. #define XATTR_REPLACE XATTR_REPLACE
  43. };
  44. #endif
  45. /* Set the attribute NAME of the file pointed to by PATH to VALUE (which
  46. is SIZE bytes long). Return 0 on success, -1 for errors. */
  47. extern int setxattr (const char *__path, const char *__name,
  48. const void *__value, size_t __size, int __flags)
  49. __THROW __attr_access ((__read_only__, 3, 4));
  50. /* Set the attribute NAME of the file pointed to by PATH to VALUE (which is
  51. SIZE bytes long), not following symlinks for the last pathname component.
  52. Return 0 on success, -1 for errors. */
  53. extern int lsetxattr (const char *__path, const char *__name,
  54. const void *__value, size_t __size, int __flags)
  55. __THROW __attr_access ((__read_only__, 3, 4));
  56. /* Set the attribute NAME of the file descriptor FD to VALUE (which is SIZE
  57. bytes long). Return 0 on success, -1 for errors. */
  58. extern int fsetxattr (int __fd, const char *__name, const void *__value,
  59. size_t __size, int __flags)
  60. __THROW __attr_access ((__read_only__, 3, 4));
  61. /* Get the attribute NAME of the file pointed to by PATH to VALUE (which is
  62. SIZE bytes long). Return 0 on success, -1 for errors. */
  63. extern ssize_t getxattr (const char *__path, const char *__name,
  64. void *__value, size_t __size)
  65. __THROW __attr_access ((__write_only__, 3, 4));
  66. /* Get the attribute NAME of the file pointed to by PATH to VALUE (which is
  67. SIZE bytes long), not following symlinks for the last pathname component.
  68. Return 0 on success, -1 for errors. */
  69. extern ssize_t lgetxattr (const char *__path, const char *__name,
  70. void *__value, size_t __size)
  71. __THROW __attr_access ((__write_only__, 3, 4));
  72. /* Get the attribute NAME of the file descriptor FD to VALUE (which is SIZE
  73. bytes long). Return 0 on success, -1 for errors. */
  74. extern ssize_t fgetxattr (int __fd, const char *__name, void *__value,
  75. size_t __size)
  76. __THROW __attr_access ((__write_only__, 3, 4));
  77. /* List attributes of the file pointed to by PATH into the user-supplied
  78. buffer LIST (which is SIZE bytes big). Return 0 on success, -1 for
  79. errors. */
  80. extern ssize_t listxattr (const char *__path, char *__list, size_t __size)
  81. __THROW __attr_access ((__write_only__, 2, 3));
  82. /* List attributes of the file pointed to by PATH into the user-supplied
  83. buffer LIST (which is SIZE bytes big), not following symlinks for the
  84. last pathname component. Return 0 on success, -1 for errors. */
  85. extern ssize_t llistxattr (const char *__path, char *__list, size_t __size)
  86. __THROW __attr_access ((__write_only__, 2, 3));
  87. /* List attributes of the file descriptor FD into the user-supplied buffer
  88. LIST (which is SIZE bytes big). Return 0 on success, -1 for errors. */
  89. extern ssize_t flistxattr (int __fd, char *__list, size_t __size)
  90. __THROW __attr_access ((__write_only__, 2, 3));
  91. /* Remove the attribute NAME from the file pointed to by PATH. Return 0
  92. on success, -1 for errors. */
  93. extern int removexattr (const char *__path, const char *__name) __THROW;
  94. /* Remove the attribute NAME from the file pointed to by PATH, not
  95. following symlinks for the last pathname component. Return 0 on
  96. success, -1 for errors. */
  97. extern int lremovexattr (const char *__path, const char *__name) __THROW;
  98. /* Remove the attribute NAME from the file descriptor FD. Return 0 on
  99. success, -1 for errors. */
  100. extern int fremovexattr (int __fd, const char *__name) __THROW;
  101. __END_DECLS
  102. #endif /* sys/xattr.h */