|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 13/29] tools/xenlogd: add 9pfs write request support
Add the write request of the 9pfs protocol.
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
tools/xenlogd/io.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/tools/xenlogd/io.c b/tools/xenlogd/io.c
index 6e92667fab..6b4692ca67 100644
--- a/tools/xenlogd/io.c
+++ b/tools/xenlogd/io.c
@@ -32,6 +32,7 @@
#define P9_CMD_WALK 110
#define P9_CMD_OPEN 112
#define P9_CMD_CREATE 114
+#define P9_CMD_WRITE 118
#define P9_CMD_CLUNK 120
#define P9_CMD_STAT 124
@@ -1010,6 +1011,51 @@ static void p9_create(device *device, struct p9_header
*hdr)
fill_buffer(device, hdr->cmd + 1, hdr->tag, "QU", &qid, &iounit);
}
+static void p9_write(device *device, struct p9_header *hdr)
+{
+ uint32_t fid;
+ uint64_t off;
+ unsigned int len;
+ uint32_t written;
+ void *buf;
+ struct p9_fid *fidp;
+ int ret;
+
+ ret = fill_data(device, "ULD", &fid, &off, &len, device->buffer);
+ if ( ret != 3 )
+ {
+ p9_error(device, hdr->tag, EINVAL);
+ return;
+ }
+
+ fidp = find_fid(device, fid);
+ if ( !fidp || !fidp->opened || fidp->isdir )
+ {
+ p9_error(device, hdr->tag, EBADF);
+ return;
+ }
+
+ buf = device->buffer;
+
+ while ( len != 0 )
+ {
+ ret = pwrite(fidp->fd, buf, len, off);
+ if ( ret < 0 )
+ break;
+ len -= ret;
+ buf += ret;
+ off += ret;
+ }
+
+ written = buf - device->buffer;
+ if ( written == 0 )
+ {
+ p9_error(device, hdr->tag, errno);
+ return;
+ }
+ fill_buffer(device, hdr->cmd + 1, hdr->tag, "U", &written);
+}
+
static void p9_clunk(device *device, struct p9_header *hdr)
{
uint32_t fid;
@@ -1182,6 +1228,10 @@ void *io_thread(void *arg)
p9_create(device, &hdr);
break;
+ case P9_CMD_WRITE:
+ p9_write(device, &hdr);
+ break;
+
case P9_CMD_CLUNK:
p9_clunk(device, &hdr);
break;
--
2.35.3
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |