xattr.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #endif
  30. #ifdef __NR_lsetxattr
  31. _syscall5(int, lsetxattr, const char *, path, const char *, name,
  32. const void *, value, size_t, size, int, flags)
  33. #endif
  34. #ifdef __NR_fsetxattr
  35. _syscall5(int, fsetxattr, int, filedes, const char *, name, const void *,
  36. value, size_t, size, int, flags)
  37. #endif
  38. /* gets */
  39. #ifdef __NR_getxattr
  40. _syscall4(ssize_t, getxattr, const char *, path, const char *, name,
  41. void *, value, size_t, size)
  42. #endif
  43. #ifdef __NR_lgetxattr
  44. _syscall4(ssize_t, lgetxattr, const char *, path, const char *, name,
  45. void *, value, size_t, size)
  46. #endif
  47. #ifdef __NR_fgetxattr
  48. _syscall4(ssize_t, fgetxattr, int, filedes, const char *, name, void *,
  49. value, size_t, size)
  50. #endif
  51. /* list */
  52. #ifdef __NR_listxattr
  53. _syscall3(ssize_t, listxattr, const char *, path, char *, list, size_t,
  54. size)
  55. #endif
  56. #ifdef __NR_llistxattr
  57. _syscall3(ssize_t, llistxattr, const char *, path, char *, list, size_t,
  58. size)
  59. #endif
  60. #ifdef __NR_flistxattr
  61. _syscall3(ssize_t, flistxattr, int, filedes, char *, list, size_t, size)
  62. #endif
  63. /* remove */
  64. #ifdef __NR_removexattr
  65. _syscall2(int, removexattr, const char *, path, const char *, name)
  66. #endif
  67. #ifdef __NR_lremovexattr
  68. _syscall2(int, lremovexattr, const char *, path, const char *, name)
  69. #endif
  70. #ifdef __NR_fremovexattr
  71. _syscall2(int, fremovexattr, int, filedes, const char *, name)
  72. #endif