xattr.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * Copyright (C) 2004 <solar@gentoo.org>
  3. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  4. *
  5. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. */
  7. /* This file provides the following Extended Attribute system calls to uClibc.
  8. *
  9. * setxattr(), lsetxattr(), fsetxattr(),
  10. * getxattr(), lgetxattr(), fgetxattr(),
  11. * listxattr(), llistxattr(), flistxattr(),
  12. * removexattr(), lremovexattr(), fremovexattr()
  13. *
  14. * Dec 2004 - <solar@gentoo.org>
  15. */
  16. /* Taken from the manpage.
  17. * On success, a positive number is returned indicating the size of the
  18. * extended attribute name list. On failure, -1 is returned and errno
  19. * is set appropriately. If extended attributes are not supported by the
  20. * filesystem, or are disabled, errno is set to ENOSYS.
  21. */
  22. #include <sys/syscall.h>
  23. #include <unistd.h>
  24. #include <sys/xattr.h>
  25. /* sets */
  26. #ifdef __NR_setxattr
  27. _syscall5(int, setxattr, const char *, path, const char *, name,
  28. const void *, value, size_t, size, int, flags)
  29. #else
  30. int setxattr(__const char *__path, __const char *__name,
  31. __const void *__value, size_t __size, int __flags)
  32. {
  33. __set_errno(ENOSYS);
  34. return -1;
  35. }
  36. #endif
  37. #ifdef __NR_lsetxattr
  38. _syscall5(int, lsetxattr, const char *, path, const char *, name,
  39. const void *, value, size_t, size, int, flags)
  40. #else
  41. int lsetxattr(__const char *__path, __const char *__name,
  42. __const void *__value, size_t __size, int __flags)
  43. {
  44. __set_errno(ENOSYS);
  45. return -1;
  46. }
  47. #endif
  48. #ifdef __NR_fsetxattr
  49. _syscall5(int, fsetxattr, int, filedes, const char *, name, const void *,
  50. value, size_t, size, int, flags)
  51. #else
  52. int fsetxattr(int __fd, __const char *__name, __const void *__value,
  53. size_t __size, int __flags)
  54. {
  55. __set_errno(ENOSYS);
  56. return -1;
  57. }
  58. #endif
  59. /* gets */
  60. #ifdef __NR_getxattr
  61. _syscall4(ssize_t, getxattr, const char *, path, const char *, name,
  62. void *, value, size_t, size)
  63. #else
  64. ssize_t getxattr(__const char *__path, __const char *__name, void *__value,
  65. size_t __size)
  66. {
  67. __set_errno(ENOSYS);
  68. return -1;
  69. }
  70. #endif
  71. #ifdef __NR_lgetxattr
  72. _syscall4(ssize_t, lgetxattr, const char *, path, const char *, name,
  73. void *, value, size_t, size)
  74. #else
  75. ssize_t lgetxattr(__const char *__path, __const char *__name,
  76. void *__value, size_t __size)
  77. {
  78. __set_errno(ENOSYS);
  79. return -1;
  80. }
  81. #endif
  82. #ifdef __NR_fgetxattr
  83. _syscall4(ssize_t, fgetxattr, int, filedes, const char *, name, void *,
  84. value, size_t, size)
  85. #else
  86. ssize_t fgetxattr(int __fd, __const char *__name, void *__value,
  87. size_t __size)
  88. {
  89. __set_errno(ENOSYS);
  90. return -1;
  91. }
  92. #endif
  93. /* list */
  94. #ifdef __NR_listxattr
  95. _syscall3(ssize_t, listxattr, const char *, path, char *, list, size_t,
  96. size)
  97. #else
  98. ssize_t listxattr(__const char *__path, char *__list, size_t __size)
  99. {
  100. __set_errno(ENOSYS);
  101. return -1;
  102. }
  103. #endif
  104. #ifdef __NR_llistxattr
  105. _syscall3(ssize_t, llistxattr, const char *, path, char *, list, size_t,
  106. size)
  107. #else
  108. ssize_t llistxattr(__const char *__path, char *__list, size_t __size)
  109. {
  110. __set_errno(ENOSYS);
  111. return -1;
  112. }
  113. #endif
  114. #ifdef __NR_flistxattr
  115. _syscall3(ssize_t, flistxattr, int, filedes, char *, list, size_t, size)
  116. #else
  117. ssize_t flistxattr(int __fd, char *__list, size_t __size)
  118. {
  119. __set_errno(ENOSYS);
  120. return -1;
  121. }
  122. #endif
  123. /* remove */
  124. #ifdef __NR_removexattr
  125. _syscall2(int, removexattr, const char *, path, const char *, name)
  126. #else
  127. int removexattr(__const char *__path, __const char *__name)
  128. {
  129. __set_errno(ENOSYS);
  130. return -1;
  131. }
  132. #endif
  133. #ifdef __NR_lremovexattr
  134. _syscall2(int, lremovexattr, const char *, path, const char *, name)
  135. #else
  136. int lremovexattr(__const char *__path, __const char *__name)
  137. {
  138. __set_errno(ENOSYS);
  139. return -1;
  140. }
  141. #endif
  142. #ifdef __NR_fremovexattr
  143. _syscall2(int, fremovexattr, int, filedes, const char *, name)
  144. #else
  145. int fremovexattr(int __fd, __const char *__name)
  146. {
  147. __set_errno(ENOSYS);
  148. return -1;
  149. }
  150. #endif