9p-util.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * 9p utilities
  3. *
  4. * Copyright IBM, Corp. 2017
  5. *
  6. * Authors:
  7. * Greg Kurz <groug@kaod.org>
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  10. * See the COPYING file in the top-level directory.
  11. */
  12. #include "qemu/osdep.h"
  13. #include "qemu/xattr.h"
  14. #include "9p-util.h"
  15. ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name,
  16. void *value, size_t size)
  17. {
  18. char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
  19. int ret;
  20. ret = lgetxattr(proc_path, name, value, size);
  21. g_free(proc_path);
  22. return ret;
  23. }
  24. ssize_t flistxattrat_nofollow(int dirfd, const char *filename,
  25. char *list, size_t size)
  26. {
  27. char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
  28. int ret;
  29. ret = llistxattr(proc_path, list, size);
  30. g_free(proc_path);
  31. return ret;
  32. }
  33. ssize_t fremovexattrat_nofollow(int dirfd, const char *filename,
  34. const char *name)
  35. {
  36. char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
  37. int ret;
  38. ret = lremovexattr(proc_path, name);
  39. g_free(proc_path);
  40. return ret;
  41. }
  42. int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name,
  43. void *value, size_t size, int flags)
  44. {
  45. char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
  46. int ret;
  47. ret = lsetxattr(proc_path, name, value, size, flags);
  48. g_free(proc_path);
  49. return ret;
  50. }