xattr.c 3.8 KB

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