remove the direct_io flag, as it is not well-supported on macOS

This commit is contained in:
chrislu 2024-11-07 14:18:59 -08:00
parent 88a1eee31c
commit 113c9ce6a8
3 changed files with 11 additions and 0 deletions

View File

@ -248,6 +248,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
Cipher: cipher, Cipher: cipher,
UidGidMapper: uidGidMapper, UidGidMapper: uidGidMapper,
DisableXAttr: *option.disableXAttr, DisableXAttr: *option.disableXAttr,
IsMacOs: runtime.GOOS == "darwin",
}) })
// create mount root // create mount root

View File

@ -46,6 +46,7 @@ type Option struct {
Umask os.FileMode Umask os.FileMode
Quota int64 Quota int64
DisableXAttr bool DisableXAttr bool
IsMacOs bool
MountUid uint32 MountUid uint32
MountGid uint32 MountGid uint32

View File

@ -2,6 +2,7 @@ package mount
import ( import (
"github.com/hanwen/go-fuse/v2/fuse" "github.com/hanwen/go-fuse/v2/fuse"
"github.com/seaweedfs/seaweedfs/weed/glog"
) )
/** /**
@ -66,6 +67,14 @@ func (wfs *WFS) Open(cancel <-chan struct{}, in *fuse.OpenIn, out *fuse.OpenOut)
if status == fuse.OK { if status == fuse.OK {
out.Fh = uint64(fileHandle.fh) out.Fh = uint64(fileHandle.fh)
out.OpenFlags = in.Flags out.OpenFlags = in.Flags
if wfs.option.IsMacOs {
// remove the direct_io flag, as it is not well-supported on macOS
// https://code.google.com/archive/p/macfuse/wikis/OPTIONS.wiki recommended to avoid the direct_io flag
if in.Flags&fuse.FOPEN_DIRECT_IO != 0 {
glog.V(4).Infof("macfuse direct_io mode %v => false\n", in.Flags&fuse.FOPEN_DIRECT_IO != 0)
out.OpenFlags &^= fuse.FOPEN_DIRECT_IO
}
}
// TODO https://github.com/libfuse/libfuse/blob/master/include/fuse_common.h#L64 // TODO https://github.com/libfuse/libfuse/blob/master/include/fuse_common.h#L64
} }
return status return status