cmount: ignore com.apple.* xattrs on the macOS FSKit backend
This commit is contained in:
1 parent
77ec281072
commit
0cb6ddada9
1 file changed
+29
@@ -536,27 +536,56 @@ func (fsys *FS) Fsyncdir(path string, datasync bool, fh uint64) (errc int) {
|
||||
return 0
|
||||
}
|
||||
|
||||
// #9908: simulate macFUSE behaviour (discard setxattr calls) - otherwise Finder cannot copy files onto the mount
|
||||
func shouldIgnoreAppleXattr(opt *mountlib.Options) bool {
|
||||
if !opt.NoAppleXattr {
|
||||
return false
|
||||
}
|
||||
if runtime.GOOS != "darwin" {
|
||||
return false
|
||||
}
|
||||
// only flip the behaviour on FSKit
|
||||
for _, o := range opt.ExtraOptions {
|
||||
if strings.TrimSpace(o) == "backend=fskit" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Setxattr sets extended attributes.
|
||||
func (fsys *FS) Setxattr(path string, name string, value []byte, flags int) (errc int) {
|
||||
defer log.Trace(path, "name=%q, value=%q, flags=%d", name, value, flags)("errc=%d", &errc)
|
||||
if shouldIgnoreAppleXattr(fsys.opt) && strings.HasPrefix(name, "com.apple.") {
|
||||
return 0
|
||||
}
|
||||
return -fuse.ENOSYS
|
||||
}
|
||||
|
||||
// Getxattr gets extended attributes.
|
||||
func (fsys *FS) Getxattr(path string, name string) (errc int, value []byte) {
|
||||
defer log.Trace(path, "name=%q", name)("errc=%d, value=%q", &errc, &value)
|
||||
if shouldIgnoreAppleXattr(fsys.opt) && strings.HasPrefix(name, "com.apple.") {
|
||||
return -fuse.ENOATTR, nil
|
||||
}
|
||||
return -fuse.ENOSYS, nil
|
||||
}
|
||||
|
||||
// Removexattr removes extended attributes.
|
||||
func (fsys *FS) Removexattr(path string, name string) (errc int) {
|
||||
defer log.Trace(path, "name=%q", name)("errc=%d", &errc)
|
||||
if shouldIgnoreAppleXattr(fsys.opt) && strings.HasPrefix(name, "com.apple.") {
|
||||
return 0
|
||||
}
|
||||
return -fuse.ENOSYS
|
||||
}
|
||||
|
||||
// Listxattr lists extended attributes.
|
||||
func (fsys *FS) Listxattr(path string, fill func(name string) bool) (errc int) {
|
||||
defer log.Trace(path, "fill=%p", fill)("errc=%d", &errc)
|
||||
if shouldIgnoreAppleXattr(fsys.opt) {
|
||||
return 0
|
||||
}
|
||||
return -fuse.ENOSYS
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user