Skip to content

Commit

Permalink
vfs/setxattr: ignore all unsupported xattr flags on the MacOS platform (
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro authored and jiefenghuang committed Nov 29, 2024
1 parent e9b08ff commit d87d053
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion pkg/meta/utils_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ const (
XattrCreateOrReplace = 0
XattrCreate = sys.XATTR_CREATE
XattrReplace = sys.XATTR_REPLACE
XattrNoSecurity = sys.XATTR_NOSECURITY
)
1 change: 0 additions & 1 deletion pkg/meta/utils_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ const (
XattrCreateOrReplace = 0
XattrCreate = sys.XATTR_CREATE
XattrReplace = sys.XATTR_REPLACE
XattrNoSecurity = 8
)
1 change: 0 additions & 1 deletion pkg/meta/utils_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ const (
XattrCreateOrReplace = 0
XattrCreate = 1
XattrReplace = 2
XattrNoSecurity = 8
)
8 changes: 5 additions & 3 deletions pkg/vfs/vfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,8 @@ const (
xattrMaxSize = 65536
)

var macSupportFlags = meta.XattrCreateOrReplace | meta.XattrCreate | meta.XattrReplace

func (v *VFS) SetXattr(ctx Context, ino Ino, name string, value []byte, flags uint32) (err syscall.Errno) {
defer func() { logit(ctx, "setxattr", err, "(%d,%s,%d,%d)", ino, name, len(value), flags) }()
if IsSpecialNode(ino) {
Expand Down Expand Up @@ -1063,9 +1065,9 @@ func (v *VFS) SetXattr(ctx Context, ino Ino, name string, value []byte, flags ui
err = v.Meta.SetFacl(ctx, ino, aclType, rule)
v.invalidateAttr(ino)
} else {
// ignore NoSecurity flag
if runtime.GOOS == "darwin" && (flags&meta.XattrNoSecurity) != 0 {
flags &= ^uint32(meta.XattrNoSecurity)
// only retain supported flags
if runtime.GOOS == "darwin" {
flags &= uint32(macSupportFlags)
}
err = v.Meta.SetXattr(ctx, ino, name, value, flags)
}
Expand Down

0 comments on commit d87d053

Please sign in to comment.