2011-05-19 03:05:34 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Virtio 9p backend
|
|
|
|
*
|
|
|
|
* Copyright IBM, Corp. 2011
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
|
|
|
* the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fsdev/qemu-fsdev.h"
|
2012-12-17 21:20:00 +04:00
|
|
|
#include "qemu/thread.h"
|
2012-12-17 21:19:44 +04:00
|
|
|
#include "block/coroutine.h"
|
2011-05-19 03:05:34 +04:00
|
|
|
#include "virtio-9p-coth.h"
|
|
|
|
|
2011-08-02 10:06:17 +04:00
|
|
|
int v9fs_co_llistxattr(V9fsPDU *pdu, V9fsPath *path, void *value, size_t size)
|
2011-05-19 03:05:34 +04:00
|
|
|
{
|
|
|
|
int err;
|
2011-08-02 10:06:17 +04:00
|
|
|
V9fsState *s = pdu->s;
|
2011-05-19 03:05:34 +04:00
|
|
|
|
2011-08-02 10:06:17 +04:00
|
|
|
if (v9fs_request_cancelled(pdu)) {
|
|
|
|
return -EINTR;
|
|
|
|
}
|
2011-08-02 10:05:54 +04:00
|
|
|
v9fs_path_read_lock(s);
|
2011-05-19 03:05:34 +04:00
|
|
|
v9fs_co_run_in_worker(
|
|
|
|
{
|
2011-09-09 13:44:18 +04:00
|
|
|
err = s->ops->llistxattr(&s->ctx, path, value, size);
|
2011-05-19 03:05:34 +04:00
|
|
|
if (err < 0) {
|
|
|
|
err = -errno;
|
|
|
|
}
|
|
|
|
});
|
2011-08-02 10:05:54 +04:00
|
|
|
v9fs_path_unlock(s);
|
2011-05-19 03:05:34 +04:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-08-02 10:06:17 +04:00
|
|
|
int v9fs_co_lgetxattr(V9fsPDU *pdu, V9fsPath *path,
|
2011-05-19 03:05:34 +04:00
|
|
|
V9fsString *xattr_name,
|
|
|
|
void *value, size_t size)
|
|
|
|
{
|
|
|
|
int err;
|
2011-08-02 10:06:17 +04:00
|
|
|
V9fsState *s = pdu->s;
|
2011-05-19 03:05:34 +04:00
|
|
|
|
2011-08-02 10:06:17 +04:00
|
|
|
if (v9fs_request_cancelled(pdu)) {
|
|
|
|
return -EINTR;
|
|
|
|
}
|
2011-08-02 10:05:54 +04:00
|
|
|
v9fs_path_read_lock(s);
|
2011-05-19 03:05:34 +04:00
|
|
|
v9fs_co_run_in_worker(
|
|
|
|
{
|
2011-09-09 13:44:18 +04:00
|
|
|
err = s->ops->lgetxattr(&s->ctx, path,
|
2011-05-19 03:05:34 +04:00
|
|
|
xattr_name->data,
|
|
|
|
value, size);
|
|
|
|
if (err < 0) {
|
|
|
|
err = -errno;
|
|
|
|
}
|
|
|
|
});
|
2011-08-02 10:05:54 +04:00
|
|
|
v9fs_path_unlock(s);
|
2011-05-19 03:05:34 +04:00
|
|
|
return err;
|
|
|
|
}
|
2011-05-07 19:39:24 +04:00
|
|
|
|
2011-08-02 10:06:17 +04:00
|
|
|
int v9fs_co_lsetxattr(V9fsPDU *pdu, V9fsPath *path,
|
2011-05-07 19:39:24 +04:00
|
|
|
V9fsString *xattr_name, void *value,
|
|
|
|
size_t size, int flags)
|
|
|
|
{
|
|
|
|
int err;
|
2011-08-02 10:06:17 +04:00
|
|
|
V9fsState *s = pdu->s;
|
2011-05-07 19:39:24 +04:00
|
|
|
|
2011-08-02 10:06:17 +04:00
|
|
|
if (v9fs_request_cancelled(pdu)) {
|
|
|
|
return -EINTR;
|
|
|
|
}
|
2011-08-02 10:05:54 +04:00
|
|
|
v9fs_path_read_lock(s);
|
2011-05-07 19:39:24 +04:00
|
|
|
v9fs_co_run_in_worker(
|
|
|
|
{
|
2011-09-09 13:44:18 +04:00
|
|
|
err = s->ops->lsetxattr(&s->ctx, path,
|
2011-05-07 19:39:24 +04:00
|
|
|
xattr_name->data, value,
|
|
|
|
size, flags);
|
|
|
|
if (err < 0) {
|
|
|
|
err = -errno;
|
|
|
|
}
|
|
|
|
});
|
2011-08-02 10:05:54 +04:00
|
|
|
v9fs_path_unlock(s);
|
2011-05-07 19:39:24 +04:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-08-02 10:06:17 +04:00
|
|
|
int v9fs_co_lremovexattr(V9fsPDU *pdu, V9fsPath *path,
|
2011-05-07 19:39:24 +04:00
|
|
|
V9fsString *xattr_name)
|
|
|
|
{
|
|
|
|
int err;
|
2011-08-02 10:06:17 +04:00
|
|
|
V9fsState *s = pdu->s;
|
2011-05-07 19:39:24 +04:00
|
|
|
|
2011-08-02 10:06:17 +04:00
|
|
|
if (v9fs_request_cancelled(pdu)) {
|
|
|
|
return -EINTR;
|
|
|
|
}
|
2011-08-02 10:05:54 +04:00
|
|
|
v9fs_path_read_lock(s);
|
2011-05-07 19:39:24 +04:00
|
|
|
v9fs_co_run_in_worker(
|
|
|
|
{
|
2011-09-09 13:44:18 +04:00
|
|
|
err = s->ops->lremovexattr(&s->ctx, path, xattr_name->data);
|
2011-05-07 19:39:24 +04:00
|
|
|
if (err < 0) {
|
|
|
|
err = -errno;
|
|
|
|
}
|
|
|
|
});
|
2011-08-02 10:05:54 +04:00
|
|
|
v9fs_path_unlock(s);
|
2011-05-07 19:39:24 +04:00
|
|
|
return err;
|
|
|
|
}
|