Skip to content

Commit

Permalink
Merge pull request #245 from sondavidb/properly-handle-fs-without-xattrs
Browse files Browse the repository at this point in the history
fs: properly handle ENOTSUP in copyXAttrs
  • Loading branch information
AkihiroSuda authored Oct 26, 2024
2 parents cb01a52 + c494f3d commit 75b1c65
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/copy_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package fs

import (
"errors"
"fmt"
"os"
"syscall"
Expand Down Expand Up @@ -64,6 +65,9 @@ func copyFileInfo(fi os.FileInfo, src, name string) error {
func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error {
xattrKeys, err := sysx.LListxattr(src)
if err != nil {
if errors.Is(err, unix.ENOTSUP) {
return nil
}
e := fmt.Errorf("failed to list xattrs on %s: %w", src, err)
if errorHandler != nil {
e = errorHandler(dst, src, "", e)
Expand Down
5 changes: 5 additions & 0 deletions fs/copy_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
package fs

import (
"errors"
"fmt"
"os"
"runtime"
"syscall"

"github.com/containerd/continuity/sysx"
"golang.org/x/sys/unix"
)

func copyFileInfo(fi os.FileInfo, src, name string) error {
Expand Down Expand Up @@ -67,6 +69,9 @@ func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAtt
// On darwin, character devices do not permit listing xattrs
return nil
}
if errors.Is(err, unix.ENOTSUP) {
return nil
}
e := fmt.Errorf("failed to list xattrs on %s: %w", src, err)
if errorHandler != nil {
e = errorHandler(dst, src, "", e)
Expand Down

0 comments on commit 75b1c65

Please sign in to comment.