Skip to content

Commit c494f3d

Browse files
committedJul 25, 2024·
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 <davbson@amazon.com>
1 parent 50fa7de commit c494f3d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed
 

‎fs/copy_linux.go

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package fs
1818

1919
import (
20+
"errors"
2021
"fmt"
2122
"os"
2223
"syscall"
@@ -64,6 +65,9 @@ func copyFileInfo(fi os.FileInfo, src, name string) error {
6465
func copyXAttrs(dst, src string, excludes map[string]struct{}, errorHandler XAttrErrorHandler) error {
6566
xattrKeys, err := sysx.LListxattr(src)
6667
if err != nil {
68+
if errors.Is(err, unix.ENOTSUP) {
69+
return nil
70+
}
6771
e := fmt.Errorf("failed to list xattrs on %s: %w", src, err)
6872
if errorHandler != nil {
6973
e = errorHandler(dst, src, "", e)

‎fs/copy_unix.go

+5
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
package fs
2121

2222
import (
23+
"errors"
2324
"fmt"
2425
"os"
2526
"runtime"
2627
"syscall"
2728

2829
"github.com/containerd/continuity/sysx"
30+
"golang.org/x/sys/unix"
2931
)
3032

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

0 commit comments

Comments
 (0)
Please sign in to comment.