mirror of
https://github.com/containers/podman.git
synced 2025-12-15 19:49:29 +08:00
vendor latest c/storage
To include the new fileutils.ReflinkOrCopy() function. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
37
vendor/github.com/containers/storage/drivers/overlay/overlay.go
generated
vendored
37
vendor/github.com/containers/storage/drivers/overlay/overlay.go
generated
vendored
@@ -36,7 +36,6 @@ import (
|
||||
"github.com/containers/storage/pkg/system"
|
||||
"github.com/containers/storage/pkg/unshare"
|
||||
units "github.com/docker/go-units"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
"github.com/opencontainers/selinux/go-selinux"
|
||||
"github.com/opencontainers/selinux/go-selinux/label"
|
||||
@@ -419,7 +418,7 @@ func Init(home string, options graphdriver.Options) (graphdriver.Driver, error)
|
||||
|
||||
if !opts.skipMountHome {
|
||||
if err := mount.MakePrivate(home); err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("overlay: failed to make mount private: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1343,7 +1342,7 @@ func (d *Driver) recreateSymlinks() error {
|
||||
return err
|
||||
}
|
||||
// Keep looping as long as we take some corrective action in each iteration
|
||||
var errs *multierror.Error
|
||||
var errs error
|
||||
madeProgress := true
|
||||
iterations := 0
|
||||
for madeProgress {
|
||||
@@ -1359,7 +1358,7 @@ func (d *Driver) recreateSymlinks() error {
|
||||
// Read the "link" file under each layer to get the name of the symlink
|
||||
data, err := os.ReadFile(path.Join(d.dir(dir.Name()), "link"))
|
||||
if err != nil {
|
||||
errs = multierror.Append(errs, fmt.Errorf("reading name of symlink for %q: %w", dir.Name(), err))
|
||||
errs = errors.Join(errs, fmt.Errorf("reading name of symlink for %q: %w", dir.Name(), err))
|
||||
continue
|
||||
}
|
||||
linkPath := path.Join(d.home, linkDir, strings.Trim(string(data), "\n"))
|
||||
@@ -1368,12 +1367,12 @@ func (d *Driver) recreateSymlinks() error {
|
||||
err = fileutils.Lexists(linkPath)
|
||||
if err != nil && os.IsNotExist(err) {
|
||||
if err := os.Symlink(path.Join("..", dir.Name(), "diff"), linkPath); err != nil {
|
||||
errs = multierror.Append(errs, err)
|
||||
errs = errors.Join(errs, err)
|
||||
continue
|
||||
}
|
||||
madeProgress = true
|
||||
} else if err != nil {
|
||||
errs = multierror.Append(errs, err)
|
||||
errs = errors.Join(errs, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
@@ -1384,7 +1383,7 @@ func (d *Driver) recreateSymlinks() error {
|
||||
// that each symlink we have corresponds to one.
|
||||
links, err := os.ReadDir(linkDirFullPath)
|
||||
if err != nil {
|
||||
errs = multierror.Append(errs, err)
|
||||
errs = errors.Join(errs, err)
|
||||
continue
|
||||
}
|
||||
// Go through all of the symlinks in the "l" directory
|
||||
@@ -1392,16 +1391,16 @@ func (d *Driver) recreateSymlinks() error {
|
||||
// Read the symlink's target, which should be "../$layer/diff"
|
||||
target, err := os.Readlink(filepath.Join(linkDirFullPath, link.Name()))
|
||||
if err != nil {
|
||||
errs = multierror.Append(errs, err)
|
||||
errs = errors.Join(errs, err)
|
||||
continue
|
||||
}
|
||||
targetComponents := strings.Split(target, string(os.PathSeparator))
|
||||
if len(targetComponents) != 3 || targetComponents[0] != ".." || targetComponents[2] != "diff" {
|
||||
errs = multierror.Append(errs, fmt.Errorf("link target of %q looks weird: %q", link, target))
|
||||
errs = errors.Join(errs, fmt.Errorf("link target of %q looks weird: %q", link, target))
|
||||
// force the link to be recreated on the next pass
|
||||
if err := os.Remove(filepath.Join(linkDirFullPath, link.Name())); err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
errs = multierror.Append(errs, fmt.Errorf("removing link %q: %w", link, err))
|
||||
errs = errors.Join(errs, fmt.Errorf("removing link %q: %w", link, err))
|
||||
} // else don’t report any error, but also don’t set madeProgress.
|
||||
continue
|
||||
}
|
||||
@@ -1417,7 +1416,7 @@ func (d *Driver) recreateSymlinks() error {
|
||||
// NOTE: If two or more links point to the same target, we will update linkFile
|
||||
// with every value of link.Name(), and set madeProgress = true every time.
|
||||
if err := os.WriteFile(linkFile, []byte(link.Name()), 0o644); err != nil {
|
||||
errs = multierror.Append(errs, fmt.Errorf("correcting link for layer %s: %w", targetID, err))
|
||||
errs = errors.Join(errs, fmt.Errorf("correcting link for layer %s: %w", targetID, err))
|
||||
continue
|
||||
}
|
||||
madeProgress = true
|
||||
@@ -1425,14 +1424,11 @@ func (d *Driver) recreateSymlinks() error {
|
||||
}
|
||||
iterations++
|
||||
if iterations >= maxIterations {
|
||||
errs = multierror.Append(errs, fmt.Errorf("reached %d iterations in overlay graph driver’s recreateSymlink, giving up", iterations))
|
||||
errs = errors.Join(errs, fmt.Errorf("reached %d iterations in overlay graph driver’s recreateSymlink, giving up", iterations))
|
||||
break
|
||||
}
|
||||
}
|
||||
if errs != nil {
|
||||
return errs.ErrorOrNil()
|
||||
}
|
||||
return nil
|
||||
return errs
|
||||
}
|
||||
|
||||
// Get creates and mounts the required file system for the given id and returns the mount path.
|
||||
@@ -2103,17 +2099,16 @@ func (g *overlayFileGetter) Get(path string) (io.ReadCloser, error) {
|
||||
return nil, fmt.Errorf("%s: %w", path, os.ErrNotExist)
|
||||
}
|
||||
|
||||
func (g *overlayFileGetter) Close() error {
|
||||
var errs *multierror.Error
|
||||
func (g *overlayFileGetter) Close() (errs error) {
|
||||
for _, f := range g.composefsMounts {
|
||||
if err := f.Close(); err != nil {
|
||||
errs = multierror.Append(errs, err)
|
||||
errs = errors.Join(errs, err)
|
||||
}
|
||||
if err := unix.Rmdir(f.Name()); err != nil {
|
||||
errs = multierror.Append(errs, err)
|
||||
errs = errors.Join(errs, err)
|
||||
}
|
||||
}
|
||||
return errs.ErrorOrNil()
|
||||
return errs
|
||||
}
|
||||
|
||||
// newStagingDir creates a new staging directory and returns the path to it.
|
||||
|
||||
Reference in New Issue
Block a user