coxattr.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * 9p backend
  3. *
  4. * Copyright IBM, Corp. 2011
  5. *
  6. * Authors:
  7. * Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
  8. *
  9. * This work is licensed under the terms of the GNU GPL, version 2. See
  10. * the COPYING file in the top-level directory.
  11. *
  12. */
  13. /*
  14. * Not so fast! You might want to read the 9p developer docs first:
  15. * https://wiki.qemu.org/Documentation/9p
  16. */
  17. #include "qemu/osdep.h"
  18. #include "fsdev/qemu-fsdev.h"
  19. #include "qemu/thread.h"
  20. #include "qemu/main-loop.h"
  21. #include "coth.h"
  22. int coroutine_fn v9fs_co_llistxattr(V9fsPDU *pdu, V9fsPath *path, void *value,
  23. size_t size)
  24. {
  25. int err;
  26. V9fsState *s = pdu->s;
  27. if (v9fs_request_cancelled(pdu)) {
  28. return -EINTR;
  29. }
  30. v9fs_path_read_lock(s);
  31. v9fs_co_run_in_worker(
  32. {
  33. err = s->ops->llistxattr(&s->ctx, path, value, size);
  34. if (err < 0) {
  35. err = -errno;
  36. }
  37. });
  38. v9fs_path_unlock(s);
  39. return err;
  40. }
  41. int coroutine_fn v9fs_co_lgetxattr(V9fsPDU *pdu, V9fsPath *path,
  42. V9fsString *xattr_name, void *value,
  43. size_t size)
  44. {
  45. int err;
  46. V9fsState *s = pdu->s;
  47. if (v9fs_request_cancelled(pdu)) {
  48. return -EINTR;
  49. }
  50. v9fs_path_read_lock(s);
  51. v9fs_co_run_in_worker(
  52. {
  53. err = s->ops->lgetxattr(&s->ctx, path,
  54. xattr_name->data,
  55. value, size);
  56. if (err < 0) {
  57. err = -errno;
  58. }
  59. });
  60. v9fs_path_unlock(s);
  61. return err;
  62. }
  63. int coroutine_fn v9fs_co_lsetxattr(V9fsPDU *pdu, V9fsPath *path,
  64. V9fsString *xattr_name, void *value,
  65. size_t size, int flags)
  66. {
  67. int err;
  68. V9fsState *s = pdu->s;
  69. if (v9fs_request_cancelled(pdu)) {
  70. return -EINTR;
  71. }
  72. v9fs_path_read_lock(s);
  73. v9fs_co_run_in_worker(
  74. {
  75. err = s->ops->lsetxattr(&s->ctx, path,
  76. xattr_name->data, value,
  77. size, flags);
  78. if (err < 0) {
  79. err = -errno;
  80. }
  81. });
  82. v9fs_path_unlock(s);
  83. return err;
  84. }
  85. int coroutine_fn v9fs_co_lremovexattr(V9fsPDU *pdu, V9fsPath *path,
  86. V9fsString *xattr_name)
  87. {
  88. int err;
  89. V9fsState *s = pdu->s;
  90. if (v9fs_request_cancelled(pdu)) {
  91. return -EINTR;
  92. }
  93. v9fs_path_read_lock(s);
  94. v9fs_co_run_in_worker(
  95. {
  96. err = s->ops->lremovexattr(&s->ctx, path, xattr_name->data);
  97. if (err < 0) {
  98. err = -errno;
  99. }
  100. });
  101. v9fs_path_unlock(s);
  102. return err;
  103. }