2
0

9p-util-linux.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * 9p utilities (Linux Implementation)
  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. /*
  13. * Not so fast! You might want to read the 9p developer docs first:
  14. * https://wiki.qemu.org/Documentation/9p
  15. */
  16. #include "qemu/osdep.h"
  17. #include "qemu/xattr.h"
  18. #include "9p-util.h"
  19. ssize_t fgetxattrat_nofollow(int dirfd, const char *filename, const char *name,
  20. void *value, size_t size)
  21. {
  22. char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
  23. int ret;
  24. ret = lgetxattr(proc_path, name, value, size);
  25. g_free(proc_path);
  26. return ret;
  27. }
  28. ssize_t flistxattrat_nofollow(int dirfd, const char *filename,
  29. char *list, size_t size)
  30. {
  31. char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
  32. int ret;
  33. ret = llistxattr(proc_path, list, size);
  34. g_free(proc_path);
  35. return ret;
  36. }
  37. ssize_t fremovexattrat_nofollow(int dirfd, const char *filename,
  38. const char *name)
  39. {
  40. char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
  41. int ret;
  42. ret = lremovexattr(proc_path, name);
  43. g_free(proc_path);
  44. return ret;
  45. }
  46. int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name,
  47. void *value, size_t size, int flags)
  48. {
  49. char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename);
  50. int ret;
  51. ret = lsetxattr(proc_path, name, value, size, flags);
  52. g_free(proc_path);
  53. return ret;
  54. }
  55. int qemu_mknodat(int dirfd, const char *filename, mode_t mode, dev_t dev)
  56. {
  57. return mknodat(dirfd, filename, mode, dev);
  58. }