From d090e452d4a0e30b59f983dfc5cde190b6088899 Mon Sep 17 00:00:00 2001 From: "M. Mohan Kumar" Date: Wed, 14 Dec 2011 13:58:46 +0530 Subject: hw/9pfs: Proxy getversion Add proxy getversion to get generation number Signed-off-by: M. Mohan Kumar Signed-off-by: Aneesh Kumar K.V --- hw/9pfs/virtio-9p-proxy.c | 32 ++++++++++++++++++++++++++++++++ hw/9pfs/virtio-9p-proxy.h | 1 + 2 files changed, 33 insertions(+) (limited to 'hw') diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c index 22e9b68..415bd21 100644 --- a/hw/9pfs/virtio-9p-proxy.c +++ b/hw/9pfs/virtio-9p-proxy.c @@ -243,6 +243,9 @@ static int v9fs_receive_response(V9fsProxy *proxy, int type, v9fs_string_free(&xattr); break; } + case T_GETVERSION: + proxy_unmarshal(reply, PROXY_HDR_SZ, "q", response); + break; default: return -1; } @@ -509,6 +512,14 @@ static int v9fs_request(V9fsProxy *proxy, int type, header.type = T_LREMOVEXATTR; } break; + case T_GETVERSION: + path = va_arg(ap, V9fsString *); + retval = proxy_marshal(iovec, PROXY_HDR_SZ, "s", path); + if (retval > 0) { + header.size = retval; + header.type = T_GETVERSION; + } + break; default: error_report("Invalid type %d\n", type); retval = -EINVAL; @@ -559,6 +570,7 @@ static int v9fs_request(V9fsProxy *proxy, int type, case T_LSTAT: case T_READLINK: case T_STATFS: + case T_GETVERSION: if (v9fs_receive_response(proxy, type, &retval, response) < 0) { goto close_error; } @@ -1064,6 +1076,25 @@ static int proxy_unlinkat(FsContext *ctx, V9fsPath *dir, return ret; } +static int proxy_ioc_getversion(FsContext *fs_ctx, V9fsPath *path, + mode_t st_mode, uint64_t *st_gen) +{ + int err; + + /* Do not try to open special files like device nodes, fifos etc + * we can get fd for regular files and directories only + */ + if (!S_ISREG(st_mode) && !S_ISDIR(st_mode)) { + return 0; + } + err = v9fs_request(fs_ctx->private, T_GETVERSION, st_gen, "s", path); + if (err < 0) { + errno = -err; + err = -1; + } + return err; +} + static int proxy_parse_opts(QemuOpts *opts, struct FsDriverEntry *fs) { const char *sock_fd = qemu_opt_get(opts, "sock_fd"); @@ -1098,6 +1129,7 @@ static int proxy_init(FsContext *ctx) qemu_mutex_init(&proxy->mutex); ctx->export_flags |= V9FS_PATHNAME_FSCONTEXT; + ctx->exops.get_st_gen = proxy_ioc_getversion; return 0; } diff --git a/hw/9pfs/virtio-9p-proxy.h b/hw/9pfs/virtio-9p-proxy.h index 7b3b0a9..005c1ad 100644 --- a/hw/9pfs/virtio-9p-proxy.h +++ b/hw/9pfs/virtio-9p-proxy.h @@ -58,6 +58,7 @@ enum { T_LLISTXATTR, T_LSETXATTR, T_LREMOVEXATTR, + T_GETVERSION, }; typedef struct { -- cgit v1.1