11ceffa54SAneesh Kumar K.V 21ceffa54SAneesh Kumar K.V /* 31ceffa54SAneesh Kumar K.V * Virtio 9p backend 41ceffa54SAneesh Kumar K.V * 51ceffa54SAneesh Kumar K.V * Copyright IBM, Corp. 2011 61ceffa54SAneesh Kumar K.V * 71ceffa54SAneesh Kumar K.V * Authors: 81ceffa54SAneesh Kumar K.V * Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> 91ceffa54SAneesh Kumar K.V * 101ceffa54SAneesh Kumar K.V * This work is licensed under the terms of the GNU GPL, version 2. See 111ceffa54SAneesh Kumar K.V * the COPYING file in the top-level directory. 121ceffa54SAneesh Kumar K.V * 131ceffa54SAneesh Kumar K.V */ 141ceffa54SAneesh Kumar K.V 151ceffa54SAneesh Kumar K.V #include "fsdev/qemu-fsdev.h" 161de7afc9SPaolo Bonzini #include "qemu/thread.h" 17*10817bf0SDaniel P. Berrange #include "qemu/coroutine.h" 181ceffa54SAneesh Kumar K.V #include "virtio-9p-coth.h" 191ceffa54SAneesh Kumar K.V 20bccacf6cSAneesh Kumar K.V int v9fs_co_llistxattr(V9fsPDU *pdu, V9fsPath *path, void *value, size_t size) 211ceffa54SAneesh Kumar K.V { 221ceffa54SAneesh Kumar K.V int err; 23bccacf6cSAneesh Kumar K.V V9fsState *s = pdu->s; 241ceffa54SAneesh Kumar K.V 25bccacf6cSAneesh Kumar K.V if (v9fs_request_cancelled(pdu)) { 26bccacf6cSAneesh Kumar K.V return -EINTR; 27bccacf6cSAneesh Kumar K.V } 28532decb7SAneesh Kumar K.V v9fs_path_read_lock(s); 291ceffa54SAneesh Kumar K.V v9fs_co_run_in_worker( 301ceffa54SAneesh Kumar K.V { 312289be19SAneesh Kumar K.V err = s->ops->llistxattr(&s->ctx, path, value, size); 321ceffa54SAneesh Kumar K.V if (err < 0) { 331ceffa54SAneesh Kumar K.V err = -errno; 341ceffa54SAneesh Kumar K.V } 351ceffa54SAneesh Kumar K.V }); 36532decb7SAneesh Kumar K.V v9fs_path_unlock(s); 371ceffa54SAneesh Kumar K.V return err; 381ceffa54SAneesh Kumar K.V } 391ceffa54SAneesh Kumar K.V 40bccacf6cSAneesh Kumar K.V int v9fs_co_lgetxattr(V9fsPDU *pdu, V9fsPath *path, 411ceffa54SAneesh Kumar K.V V9fsString *xattr_name, 421ceffa54SAneesh Kumar K.V void *value, size_t size) 431ceffa54SAneesh Kumar K.V { 441ceffa54SAneesh Kumar K.V int err; 45bccacf6cSAneesh Kumar K.V V9fsState *s = pdu->s; 461ceffa54SAneesh Kumar K.V 47bccacf6cSAneesh Kumar K.V if (v9fs_request_cancelled(pdu)) { 48bccacf6cSAneesh Kumar K.V return -EINTR; 49bccacf6cSAneesh Kumar K.V } 50532decb7SAneesh Kumar K.V v9fs_path_read_lock(s); 511ceffa54SAneesh Kumar K.V v9fs_co_run_in_worker( 521ceffa54SAneesh Kumar K.V { 532289be19SAneesh Kumar K.V err = s->ops->lgetxattr(&s->ctx, path, 541ceffa54SAneesh Kumar K.V xattr_name->data, 551ceffa54SAneesh Kumar K.V value, size); 561ceffa54SAneesh Kumar K.V if (err < 0) { 571ceffa54SAneesh Kumar K.V err = -errno; 581ceffa54SAneesh Kumar K.V } 591ceffa54SAneesh Kumar K.V }); 60532decb7SAneesh Kumar K.V v9fs_path_unlock(s); 611ceffa54SAneesh Kumar K.V return err; 621ceffa54SAneesh Kumar K.V } 63bed4352cSAneesh Kumar K.V 64bccacf6cSAneesh Kumar K.V int v9fs_co_lsetxattr(V9fsPDU *pdu, V9fsPath *path, 65bed4352cSAneesh Kumar K.V V9fsString *xattr_name, void *value, 66bed4352cSAneesh Kumar K.V size_t size, int flags) 67bed4352cSAneesh Kumar K.V { 68bed4352cSAneesh Kumar K.V int err; 69bccacf6cSAneesh Kumar K.V V9fsState *s = pdu->s; 70bed4352cSAneesh Kumar K.V 71bccacf6cSAneesh Kumar K.V if (v9fs_request_cancelled(pdu)) { 72bccacf6cSAneesh Kumar K.V return -EINTR; 73bccacf6cSAneesh Kumar K.V } 74532decb7SAneesh Kumar K.V v9fs_path_read_lock(s); 75bed4352cSAneesh Kumar K.V v9fs_co_run_in_worker( 76bed4352cSAneesh Kumar K.V { 772289be19SAneesh Kumar K.V err = s->ops->lsetxattr(&s->ctx, path, 78bed4352cSAneesh Kumar K.V xattr_name->data, value, 79bed4352cSAneesh Kumar K.V size, flags); 80bed4352cSAneesh Kumar K.V if (err < 0) { 81bed4352cSAneesh Kumar K.V err = -errno; 82bed4352cSAneesh Kumar K.V } 83bed4352cSAneesh Kumar K.V }); 84532decb7SAneesh Kumar K.V v9fs_path_unlock(s); 85bed4352cSAneesh Kumar K.V return err; 86bed4352cSAneesh Kumar K.V } 87bed4352cSAneesh Kumar K.V 88bccacf6cSAneesh Kumar K.V int v9fs_co_lremovexattr(V9fsPDU *pdu, V9fsPath *path, 89bed4352cSAneesh Kumar K.V V9fsString *xattr_name) 90bed4352cSAneesh Kumar K.V { 91bed4352cSAneesh Kumar K.V int err; 92bccacf6cSAneesh Kumar K.V V9fsState *s = pdu->s; 93bed4352cSAneesh Kumar K.V 94bccacf6cSAneesh Kumar K.V if (v9fs_request_cancelled(pdu)) { 95bccacf6cSAneesh Kumar K.V return -EINTR; 96bccacf6cSAneesh Kumar K.V } 97532decb7SAneesh Kumar K.V v9fs_path_read_lock(s); 98bed4352cSAneesh Kumar K.V v9fs_co_run_in_worker( 99bed4352cSAneesh Kumar K.V { 1002289be19SAneesh Kumar K.V err = s->ops->lremovexattr(&s->ctx, path, xattr_name->data); 101bed4352cSAneesh Kumar K.V if (err < 0) { 102bed4352cSAneesh Kumar K.V err = -errno; 103bed4352cSAneesh Kumar K.V } 104bed4352cSAneesh Kumar K.V }); 105532decb7SAneesh Kumar K.V v9fs_path_unlock(s); 106bed4352cSAneesh Kumar K.V return err; 107bed4352cSAneesh Kumar K.V } 108