summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/fuse/dev.go
diff options
context:
space:
mode:
authorJinmou Li <jinmli@google.com>2020-09-01 01:49:57 +0000
committerAndrei Vagin <avagin@gmail.com>2020-09-16 12:19:30 -0700
commit98faed55e682cf34bb713c37b063a7d1da5e8352 (patch)
tree1301aecbd534cb4eac712cf65e808914d3157559 /pkg/sentry/fsimpl/fuse/dev.go
parent18f1e1c91b05059c333197a2a6198716c12508e7 (diff)
Implement FUSE_WRITE
This commit adds basic write(2) support for FUSE.
Diffstat (limited to 'pkg/sentry/fsimpl/fuse/dev.go')
-rw-r--r--pkg/sentry/fsimpl/fuse/dev.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/pkg/sentry/fsimpl/fuse/dev.go b/pkg/sentry/fsimpl/fuse/dev.go
index c53a38021..6022593d6 100644
--- a/pkg/sentry/fsimpl/fuse/dev.go
+++ b/pkg/sentry/fsimpl/fuse/dev.go
@@ -152,7 +152,7 @@ func (fd *DeviceFD) readLocked(ctx context.Context, dst usermem.IOSequence, opts
for !fd.queue.Empty() {
req = fd.queue.Front()
- if int64(req.hdr.Len) <= dst.NumBytes() {
+ if int64(req.hdr.Len)+int64(len(req.payload)) <= dst.NumBytes() {
break
}
@@ -191,6 +191,17 @@ func (fd *DeviceFD) readLocked(ctx context.Context, dst usermem.IOSequence, opts
return 0, syserror.EIO
}
+ if req.hdr.Opcode == linux.FUSE_WRITE {
+ written, err := dst.DropFirst(n).CopyOut(ctx, req.payload)
+ if err != nil {
+ return 0, err
+ }
+ if written != len(req.payload) {
+ return 0, syserror.EIO
+ }
+ n += int(written)
+ }
+
// Fully done with this req, remove it from the queue.
fd.queue.Remove(req)
if req.hdr.Opcode == linux.FUSE_RELEASE {