From 2f65426467b1505bddb90f7cb10f071607593679 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 15 Feb 2020 08:27:23 +0100 Subject: [PATCH] implement NoOpenSupport and NoOpendirSupport See also: https://github.com/torvalds/linux/commit/7678ac50615d9c7a491d9861e020e4f5f71b594c https://github.com/torvalds/linux/commit/d7afaec0b564f0609e116f562983b8e72fc3e9c9 https://github.com/torvalds/linux/commit/d9a9ea94f748f47b1d75c6c5e33edcf74476c445 --- connection.go | 14 +++++++++++ internal/fusekernel/fuse_kernel.go | 40 ++++++++++++++++-------------- mount_config.go | 12 +++++++++ 3 files changed, 47 insertions(+), 19 deletions(-) diff --git a/connection.go b/connection.go index d06171b..4b7a6be 100644 --- a/connection.go +++ b/connection.go @@ -149,6 +149,8 @@ func (c *Connection) Init() error { } cacheSymlinks := initOp.Flags&fusekernel.InitCacheSymlinks > 0 + noOpenSupport := initOp.Flags&fusekernel.InitNoOpenSupport > 0 + noOpendirSupport := initOp.Flags&fusekernel.InitNoOpendirSupport > 0 // Respond to the init op. initOp.Library = c.protocol @@ -171,6 +173,18 @@ func (c *Connection) Init() error { initOp.Flags |= fusekernel.InitCacheSymlinks } + // Tell the kernel to treat returning -ENOSYS on OpenFile as not needing + // OpenFile calls at all (Linux >= 3.16): + if c.cfg.EnableNoOpenSupport && noOpenSupport { + initOp.Flags |= fusekernel.InitNoOpenSupport + } + + // Tell the kernel to treat returning -ENOSYS on OpenDir as not needing + // OpenDir calls at all (Linux >= 5.1): + if c.cfg.EnableNoOpendirSupport && noOpendirSupport { + initOp.Flags |= fusekernel.InitNoOpendirSupport + } + c.Reply(ctx, nil) return nil } diff --git a/internal/fusekernel/fuse_kernel.go b/internal/fusekernel/fuse_kernel.go index f06a8ea..e87572b 100644 --- a/internal/fusekernel/fuse_kernel.go +++ b/internal/fusekernel/fuse_kernel.go @@ -248,25 +248,26 @@ var openResponseFlagNames = []flagName{ type InitFlags uint32 const ( - InitAsyncRead InitFlags = 1 << 0 - InitPosixLocks InitFlags = 1 << 1 - InitFileOps InitFlags = 1 << 2 - InitAtomicTrunc InitFlags = 1 << 3 - InitExportSupport InitFlags = 1 << 4 - InitBigWrites InitFlags = 1 << 5 - InitDontMask InitFlags = 1 << 6 - InitSpliceWrite InitFlags = 1 << 7 - InitSpliceMove InitFlags = 1 << 8 - InitSpliceRead InitFlags = 1 << 9 - InitFlockLocks InitFlags = 1 << 10 - InitHasIoctlDir InitFlags = 1 << 11 - InitAutoInvalData InitFlags = 1 << 12 - InitDoReaddirplus InitFlags = 1 << 13 - InitReaddirplusAuto InitFlags = 1 << 14 - InitAsyncDIO InitFlags = 1 << 15 - InitWritebackCache InitFlags = 1 << 16 - InitNoOpenSupport InitFlags = 1 << 17 - InitCacheSymlinks InitFlags = 1 << 23 + InitAsyncRead InitFlags = 1 << 0 + InitPosixLocks InitFlags = 1 << 1 + InitFileOps InitFlags = 1 << 2 + InitAtomicTrunc InitFlags = 1 << 3 + InitExportSupport InitFlags = 1 << 4 + InitBigWrites InitFlags = 1 << 5 + InitDontMask InitFlags = 1 << 6 + InitSpliceWrite InitFlags = 1 << 7 + InitSpliceMove InitFlags = 1 << 8 + InitSpliceRead InitFlags = 1 << 9 + InitFlockLocks InitFlags = 1 << 10 + InitHasIoctlDir InitFlags = 1 << 11 + InitAutoInvalData InitFlags = 1 << 12 + InitDoReaddirplus InitFlags = 1 << 13 + InitReaddirplusAuto InitFlags = 1 << 14 + InitAsyncDIO InitFlags = 1 << 15 + InitWritebackCache InitFlags = 1 << 16 + InitNoOpenSupport InitFlags = 1 << 17 + InitCacheSymlinks InitFlags = 1 << 23 + InitNoOpendirSupport InitFlags = 1 << 24 InitCaseSensitive InitFlags = 1 << 29 // OS X only InitVolRename InitFlags = 1 << 30 // OS X only @@ -298,6 +299,7 @@ var initFlagNames = []flagName{ {uint32(InitWritebackCache), "InitWritebackCache"}, {uint32(InitNoOpenSupport), "InitNoOpenSupport"}, {uint32(InitCacheSymlinks), "InitCacheSymlinks"}, + {uint32(InitNoOpendirSupport), "InitNoOpendirSupport"}, {uint32(InitCaseSensitive), "InitCaseSensitive"}, {uint32(InitVolRename), "InitVolRename"}, diff --git a/mount_config.go b/mount_config.go index 62e1d17..2b80237 100644 --- a/mount_config.go +++ b/mount_config.go @@ -139,6 +139,18 @@ type MountConfig struct { // target. EnableSymlinkCaching bool + // Linux only. + // + // Tell the kernel to treat returning -ENOSYS on OpenFile as not needing + // OpenFile calls at all (Linux >= 3.16): + EnableNoOpenSupport bool + + // Linux only. + // + // Tell the kernel to treat returning -ENOSYS on OpenDir as not needing + // OpenDir calls at all (Linux >= 5.1): + EnableNoOpendirSupport bool + // OS X only. // // The name of the mounted volume, as displayed in the Finder. If empty, a