diff --git a/conversions.go b/conversions.go index b1246bc..b30a643 100644 --- a/conversions.go +++ b/conversions.go @@ -561,6 +561,10 @@ func (c *Connection) kernelResponseForOp( out.OpenFlags |= uint32(fusekernel.OpenKeepCache) } + if o.UseDirectIO { + out.OpenFlags |= uint32(fusekernel.OpenDirectIO) + } + case *fuseops.ReadFileOp: // convertInMessage already set up the destination buffer to be at the end // of the out message. We need only shrink to the right size based on how diff --git a/fuseops/ops.go b/fuseops/ops.go index 609249f..cd99141 100644 --- a/fuseops/ops.go +++ b/fuseops/ops.go @@ -564,6 +564,15 @@ type OpenFileOp struct { // is set to true, regardless of its value, at least for files opened in the // same mode. (Cf. https://github.com/osxfuse/osxfuse/issues/223) KeepPageCache bool + + // Whether to use direct IO for this file handle. By default, the kernel + // suppresses what it sees as redundant operations (including reads beyond + // the precomputed EOF). + // + // Enabling direct IO ensures that all client operations reach the fuse + // layer. This allows for filesystems whose file sizes are not known in + // advance, for example, because contents are generated on the fly. + UseDirectIO bool } // Read data from a file previously opened with CreateFile or OpenFile.