File: copy_nowindows.go

package info (click to toggle)
golang-github-tonistiigi-fsutil 0.0~git20200331.f427cf1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 400 kB
  • sloc: makefile: 7
file content (28 lines) | stat: -rw-r--r-- 729 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// +build !windows

package fs

import (
	"github.com/pkg/errors"

	"github.com/containerd/continuity/sysx"
)

// copyXAttrs requires xeh to be non-nil
func copyXAttrs(dst, src string, xeh XAttrErrorHandler) error {
	xattrKeys, err := sysx.LListxattr(src)
	if err != nil {
		return xeh(dst, src, "", errors.Wrapf(err, "failed to list xattrs on %s", src))
	}
	for _, xattr := range xattrKeys {
		data, err := sysx.LGetxattr(src, xattr)
		if err != nil {
			return xeh(dst, src, xattr, errors.Wrapf(err, "failed to get xattr %q on %s", xattr, src))
		}
		if err := sysx.LSetxattr(dst, xattr, data, 0); err != nil {
			return xeh(dst, src, xattr, errors.Wrapf(err, "failed to set xattr %q on %s", xattr, dst))
		}
	}

	return nil
}