Skip to content

Commit

Permalink
Fix unset xattr on darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
micbar committed Nov 10, 2021
1 parent 0c187f8 commit 1c6b067
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 8 deletions.
8 changes: 0 additions & 8 deletions pkg/storage/utils/decomposedfs/node/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,6 @@ func (p *Permissions) getUserAndPermissions(ctx context.Context, n *Node) (*user
}
return u, nil
}
func isNoData(err error) bool {
if xerr, ok := err.(*xattr.Error); ok {
if serr, ok2 := xerr.Err.(syscall.Errno); ok2 {
return serr == syscall.ENODATA
}
}
return false
}

// The os not exists error is buried inside the xattr error,
// so we cannot just use os.IsNotExists().
Expand Down
37 changes: 37 additions & 0 deletions pkg/storage/utils/decomposedfs/node/permissions_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2018-2021 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// In applying this license, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

//go:build darwin
// +build darwin

package node

import (
"syscall"

"github.com/pkg/xattr"
)

func isNoData(err error) bool {
if xerr, ok := err.(*xattr.Error); ok {
if serr, ok2 := xerr.Err.(syscall.Errno); ok2 {
return serr == syscall.ENOATTR
}
}
return false
}
37 changes: 37 additions & 0 deletions pkg/storage/utils/decomposedfs/node/permissions_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2018-2021 CERN
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// In applying this license, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

//go:build !darwin
// +build !darwin

package node

import (
"syscall"

"github.com/pkg/xattr"
)

func isNoData(err error) bool {
if xerr, ok := err.(*xattr.Error); ok {
if serr, ok2 := xerr.Err.(syscall.Errno); ok2 {
return serr == syscall.ENODATA
}
}
return false
}

0 comments on commit 1c6b067

Please sign in to comment.