From c494f3d90ac521345eed00be6784fe5e798d0bbc Mon Sep 17 00:00:00 2001 From: David Son Date: Tue, 16 Jul 2024 23:05:09 +0000 Subject: [PATCH] fs: properly handle ENOTSUP in copyXAttrs Filesystems without xattr support do not have any xattrs to copy. The syscall for this will return ENOTSUP to indicate this, but continuity will treat it as a regular error. This change will return nil if this call returns ENOTSUP. Signed-off-by: David Son --- fs/copy_linux.go | 4 ++++ fs/copy_unix.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/fs/copy_linux.go b/fs/copy_linux.go index 48ac3fbd..739461cb 100644 --- a/fs/copy_linux.go +++ b/fs/copy_linux.go @@ -17,6 +17,7 @@ package fs import ( + "errors" "fmt" "os" "syscall" @@ -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) diff --git a/fs/copy_unix.go b/fs/copy_unix.go index 2e25914d..2a2e1a57 100644 --- a/fs/copy_unix.go +++ b/fs/copy_unix.go @@ -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 { @@ -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)