2
0

coxattr.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. #include "qemu/osdep.h"
  14. #include "fsdev/qemu-fsdev.h"
  15. #include "qemu/thread.h"
  16. #include "qemu/coroutine.h"
  17. #include "qemu/main-loop.h"
  18. #include "coth.h"
  19. int coroutine_fn v9fs_co_llistxattr(V9fsPDU *pdu, V9fsPath *path, void *value,
  20. size_t size)
  21. {
  22. int err;
  23. V9fsState *s = pdu->s;
  24. if (v9fs_request_cancelled(pdu)) {
  25. return -EINTR;
  26. }
  27. v9fs_path_read_lock(s);
  28. v9fs_co_run_in_worker(
  29. {
  30. err = s->ops->llistxattr(&s->ctx, path, value, size);
  31. if (err < 0) {
  32. err = -errno;
  33. }
  34. });
  35. v9fs_path_unlock(s);
  36. return err;
  37. }
  38. int coroutine_fn v9fs_co_lgetxattr(V9fsPDU *pdu, V9fsPath *path,
  39. V9fsString *xattr_name, void *value,
  40. size_t size)
  41. {
  42. int err;
  43. V9fsState *s = pdu->s;
  44. if (v9fs_request_cancelled(pdu)) {
  45. return -EINTR;
  46. }
  47. v9fs_path_read_lock(s);
  48. v9fs_co_run_in_worker(
  49. {
  50. err = s->ops->lgetxattr(&s->ctx, path,
  51. xattr_name->data,
  52. value, size);
  53. if (err < 0) {
  54. err = -errno;
  55. }
  56. });
  57. v9fs_path_unlock(s);
  58. return err;
  59. }
  60. int coroutine_fn v9fs_co_lsetxattr(V9fsPDU *pdu, V9fsPath *path,
  61. V9fsString *xattr_name, void *value,
  62. size_t size, int flags)
  63. {
  64. int err;
  65. V9fsState *s = pdu->s;
  66. if (v9fs_request_cancelled(pdu)) {
  67. return -EINTR;
  68. }
  69. v9fs_path_read_lock(s);
  70. v9fs_co_run_in_worker(
  71. {
  72. err = s->ops->lsetxattr(&s->ctx, path,
  73. xattr_name->data, value,
  74. size, flags);
  75. if (err < 0) {
  76. err = -errno;
  77. }
  78. });
  79. v9fs_path_unlock(s);
  80. return err;
  81. }
  82. int coroutine_fn v9fs_co_lremovexattr(V9fsPDU *pdu, V9fsPath *path,
  83. V9fsString *xattr_name)
  84. {
  85. int err;
  86. V9fsState *s = pdu->s;
  87. if (v9fs_request_cancelled(pdu)) {
  88. return -EINTR;
  89. }
  90. v9fs_path_read_lock(s);
  91. v9fs_co_run_in_worker(
  92. {
  93. err = s->ops->lremovexattr(&s->ctx, path, xattr_name->data);
  94. if (err < 0) {
  95. err = -errno;
  96. }
  97. });
  98. v9fs_path_unlock(s);
  99. return err;
  100. }