On 07.11.23 15:10, Jason Andryuk wrote:
On Wed, Nov 1, 2023 at 5:54 AM Juergen Gross <jgr...@suse.com> wrote:Add the write request of the 9pfs protocol. Signed-off-by: Juergen Gross <jgr...@suse.com> --- 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@@ -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 )I think you want an additional check that the fidp is writable.
The open was done with the correct mode. If fidp isn't writable, the write() will fail with the correct errno. Juergen
OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key
OpenPGP_signature.asc
Description: OpenPGP digital signature