11ceffa54SAneesh Kumar K.V /* 2af8b38b0SGreg Kurz * 9p backend 31ceffa54SAneesh Kumar K.V * 41ceffa54SAneesh Kumar K.V * Copyright IBM, Corp. 2011 51ceffa54SAneesh Kumar K.V * 61ceffa54SAneesh Kumar K.V * Authors: 71ceffa54SAneesh Kumar K.V * Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> 81ceffa54SAneesh Kumar K.V * 91ceffa54SAneesh Kumar K.V * This work is licensed under the terms of the GNU GPL, version 2. See 101ceffa54SAneesh Kumar K.V * the COPYING file in the top-level directory. 111ceffa54SAneesh Kumar K.V * 121ceffa54SAneesh Kumar K.V */ 131ceffa54SAneesh Kumar K.V 14fbc04127SPeter Maydell #include "qemu/osdep.h" 151ceffa54SAneesh Kumar K.V #include "fsdev/qemu-fsdev.h" 161de7afc9SPaolo Bonzini #include "qemu/thread.h" 1710817bf0SDaniel P. Berrange #include "qemu/coroutine.h" 18*db725815SMarkus Armbruster #include "qemu/main-loop.h" 19fe52840cSWei Liu #include "coth.h" 201ceffa54SAneesh Kumar K.V 215bdade66SGreg Kurz int coroutine_fn v9fs_co_llistxattr(V9fsPDU *pdu, V9fsPath *path, void *value, 225bdade66SGreg Kurz size_t size) 231ceffa54SAneesh Kumar K.V { 241ceffa54SAneesh Kumar K.V int err; 25bccacf6cSAneesh Kumar K.V V9fsState *s = pdu->s; 261ceffa54SAneesh Kumar K.V 27bccacf6cSAneesh Kumar K.V if (v9fs_request_cancelled(pdu)) { 28bccacf6cSAneesh Kumar K.V return -EINTR; 29bccacf6cSAneesh Kumar K.V } 30532decb7SAneesh Kumar K.V v9fs_path_read_lock(s); 311ceffa54SAneesh Kumar K.V v9fs_co_run_in_worker( 321ceffa54SAneesh Kumar K.V { 332289be19SAneesh Kumar K.V err = s->ops->llistxattr(&s->ctx, path, value, size); 341ceffa54SAneesh Kumar K.V if (err < 0) { 351ceffa54SAneesh Kumar K.V err = -errno; 361ceffa54SAneesh Kumar K.V } 371ceffa54SAneesh Kumar K.V }); 38532decb7SAneesh Kumar K.V v9fs_path_unlock(s); 391ceffa54SAneesh Kumar K.V return err; 401ceffa54SAneesh Kumar K.V } 411ceffa54SAneesh Kumar K.V 425bdade66SGreg Kurz int coroutine_fn v9fs_co_lgetxattr(V9fsPDU *pdu, V9fsPath *path, 435bdade66SGreg Kurz V9fsString *xattr_name, void *value, 445bdade66SGreg Kurz size_t size) 451ceffa54SAneesh Kumar K.V { 461ceffa54SAneesh Kumar K.V int err; 47bccacf6cSAneesh Kumar K.V V9fsState *s = pdu->s; 481ceffa54SAneesh Kumar K.V 49bccacf6cSAneesh Kumar K.V if (v9fs_request_cancelled(pdu)) { 50bccacf6cSAneesh Kumar K.V return -EINTR; 51bccacf6cSAneesh Kumar K.V } 52532decb7SAneesh Kumar K.V v9fs_path_read_lock(s); 531ceffa54SAneesh Kumar K.V v9fs_co_run_in_worker( 541ceffa54SAneesh Kumar K.V { 552289be19SAneesh Kumar K.V err = s->ops->lgetxattr(&s->ctx, path, 561ceffa54SAneesh Kumar K.V xattr_name->data, 571ceffa54SAneesh Kumar K.V value, size); 581ceffa54SAneesh Kumar K.V if (err < 0) { 591ceffa54SAneesh Kumar K.V err = -errno; 601ceffa54SAneesh Kumar K.V } 611ceffa54SAneesh Kumar K.V }); 62532decb7SAneesh Kumar K.V v9fs_path_unlock(s); 631ceffa54SAneesh Kumar K.V return err; 641ceffa54SAneesh Kumar K.V } 65bed4352cSAneesh Kumar K.V 665bdade66SGreg Kurz int coroutine_fn v9fs_co_lsetxattr(V9fsPDU *pdu, V9fsPath *path, 67bed4352cSAneesh Kumar K.V V9fsString *xattr_name, void *value, 68bed4352cSAneesh Kumar K.V size_t size, int flags) 69bed4352cSAneesh Kumar K.V { 70bed4352cSAneesh Kumar K.V int err; 71bccacf6cSAneesh Kumar K.V V9fsState *s = pdu->s; 72bed4352cSAneesh Kumar K.V 73bccacf6cSAneesh Kumar K.V if (v9fs_request_cancelled(pdu)) { 74bccacf6cSAneesh Kumar K.V return -EINTR; 75bccacf6cSAneesh Kumar K.V } 76532decb7SAneesh Kumar K.V v9fs_path_read_lock(s); 77bed4352cSAneesh Kumar K.V v9fs_co_run_in_worker( 78bed4352cSAneesh Kumar K.V { 792289be19SAneesh Kumar K.V err = s->ops->lsetxattr(&s->ctx, path, 80bed4352cSAneesh Kumar K.V xattr_name->data, value, 81bed4352cSAneesh Kumar K.V size, flags); 82bed4352cSAneesh Kumar K.V if (err < 0) { 83bed4352cSAneesh Kumar K.V err = -errno; 84bed4352cSAneesh Kumar K.V } 85bed4352cSAneesh Kumar K.V }); 86532decb7SAneesh Kumar K.V v9fs_path_unlock(s); 87bed4352cSAneesh Kumar K.V return err; 88bed4352cSAneesh Kumar K.V } 89bed4352cSAneesh Kumar K.V 905bdade66SGreg Kurz int coroutine_fn v9fs_co_lremovexattr(V9fsPDU *pdu, V9fsPath *path, 91bed4352cSAneesh Kumar K.V V9fsString *xattr_name) 92bed4352cSAneesh Kumar K.V { 93bed4352cSAneesh Kumar K.V int err; 94bccacf6cSAneesh Kumar K.V V9fsState *s = pdu->s; 95bed4352cSAneesh Kumar K.V 96bccacf6cSAneesh Kumar K.V if (v9fs_request_cancelled(pdu)) { 97bccacf6cSAneesh Kumar K.V return -EINTR; 98bccacf6cSAneesh Kumar K.V } 99532decb7SAneesh Kumar K.V v9fs_path_read_lock(s); 100bed4352cSAneesh Kumar K.V v9fs_co_run_in_worker( 101bed4352cSAneesh Kumar K.V { 1022289be19SAneesh Kumar K.V err = s->ops->lremovexattr(&s->ctx, path, xattr_name->data); 103bed4352cSAneesh Kumar K.V if (err < 0) { 104bed4352cSAneesh Kumar K.V err = -errno; 105bed4352cSAneesh Kumar K.V } 106bed4352cSAneesh Kumar K.V }); 107532decb7SAneesh Kumar K.V v9fs_path_unlock(s); 108bed4352cSAneesh Kumar K.V return err; 109bed4352cSAneesh Kumar K.V } 110