Skip to content

Commit

Permalink
Merge pull request #913 from giuseppe/fix-check-for-rootless-metacopy
Browse files Browse the repository at this point in the history
overlay: check for unix.ENOTSUP
  • Loading branch information
vrothberg authored May 20, 2021
2 parents abcafb2 + 0c5ccab commit 13468cb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/overlay/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/containers/storage/pkg/ioutils"
"github.com/containers/storage/pkg/mount"
"github.com/containers/storage/pkg/system"
"github.com/containers/storage/pkg/unshare"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
Expand Down Expand Up @@ -141,6 +142,9 @@ func doesMetacopy(d, mountOpts string) (bool, error) {
}
// Mount using the mandatory options and configured options
opts := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", path.Join(td, "l1"), path.Join(td, "l2"), path.Join(td, "work"))
if unshare.IsRootless() {
opts = fmt.Sprintf("%s,userxattr", opts)
}
flags, data := mount.ParseOptions(mountOpts)
if data != "" {
opts = fmt.Sprintf("%s,%s", opts, data)
Expand All @@ -164,6 +168,10 @@ func doesMetacopy(d, mountOpts string) (bool, error) {
}
metacopy, err := system.Lgetxattr(filepath.Join(td, "l2", "f"), archive.GetOverlayXattrName("metacopy"))
if err != nil {
if errors.Is(err, unix.ENOTSUP) {
logrus.Info("metacopy option not supported")
return false, nil
}
return false, errors.Wrap(err, "metacopy flag was not set on file in upper layer")
}
return metacopy != nil, nil
Expand Down

0 comments on commit 13468cb

Please sign in to comment.