mirror of
https://github.com/containers/podman.git
synced 2025-12-08 23:00:23 +08:00
Update vendor containers/(common,storage,buildah,image)
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
5
vendor/github.com/containers/storage/drivers/driver.go
generated
vendored
5
vendor/github.com/containers/storage/drivers/driver.go
generated
vendored
@@ -8,13 +8,12 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vbatts/tar-split/tar/storage"
|
||||
|
||||
"github.com/containers/storage/pkg/archive"
|
||||
"github.com/containers/storage/pkg/directory"
|
||||
"github.com/containers/storage/pkg/idtools"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vbatts/tar-split/tar/storage"
|
||||
)
|
||||
|
||||
// FsMagic unsigned id of the filesystem in use.
|
||||
|
||||
2
vendor/github.com/containers/storage/drivers/fsdiff.go
generated
vendored
2
vendor/github.com/containers/storage/drivers/fsdiff.go
generated
vendored
@@ -174,7 +174,7 @@ func (gdw *NaiveDiffDriver) ApplyDiff(id, parent string, options ApplyDiffOpts)
|
||||
defer driverPut(driver, id, &err)
|
||||
|
||||
defaultForceMask := os.FileMode(0700)
|
||||
var forceMask *os.FileMode = nil
|
||||
var forceMask *os.FileMode // = nil
|
||||
if runtime.GOOS == "darwin" {
|
||||
forceMask = &defaultForceMask
|
||||
}
|
||||
|
||||
97
vendor/github.com/containers/storage/drivers/overlay/mount.go
generated
vendored
97
vendor/github.com/containers/storage/drivers/overlay/mount.go
generated
vendored
@@ -8,14 +8,16 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/storage/pkg/reexec"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func init() {
|
||||
reexec.Register("storage-mountfrom", mountFromMain)
|
||||
reexec.Register("storage-mountfrom", mountOverlayFromMain)
|
||||
}
|
||||
|
||||
func fatal(err error) {
|
||||
@@ -31,7 +33,7 @@ type mountOptions struct {
|
||||
Flag uint32
|
||||
}
|
||||
|
||||
func mountFrom(dir, device, target, mType string, flags uintptr, label string) error {
|
||||
func mountOverlayFrom(dir, device, target, mType string, flags uintptr, label string) error {
|
||||
options := &mountOptions{
|
||||
Device: device,
|
||||
Target: target,
|
||||
@@ -67,7 +69,7 @@ func mountFrom(dir, device, target, mType string, flags uintptr, label string) e
|
||||
}
|
||||
|
||||
// mountfromMain is the entry-point for storage-mountfrom on re-exec.
|
||||
func mountFromMain() {
|
||||
func mountOverlayFromMain() {
|
||||
runtime.LockOSThread()
|
||||
flag.Parse()
|
||||
|
||||
@@ -77,11 +79,96 @@ func mountFromMain() {
|
||||
fatal(err)
|
||||
}
|
||||
|
||||
if err := os.Chdir(flag.Arg(0)); err != nil {
|
||||
// Mount the arguments passed from the specified directory. Some of the
|
||||
// paths mentioned in the values we pass to the kernel are relative to
|
||||
// the specified directory.
|
||||
homedir := flag.Arg(0)
|
||||
if err := os.Chdir(homedir); err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
|
||||
if err := unix.Mount(options.Device, options.Target, options.Type, uintptr(options.Flag), options.Label); err != nil {
|
||||
pageSize := unix.Getpagesize()
|
||||
if len(options.Label) < pageSize {
|
||||
if err := unix.Mount(options.Device, options.Target, options.Type, uintptr(options.Flag), options.Label); err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Those arguments still took up too much space. Open the diff
|
||||
// directories and use their descriptor numbers as lowers, using
|
||||
// /proc/self/fd as the current directory.
|
||||
|
||||
// Split out the various options, since we need to manipulate the
|
||||
// paths, but we don't want to mess with other options.
|
||||
var upperk, upperv, workk, workv, lowerk, lowerv, labelk, labelv, others string
|
||||
for _, arg := range strings.Split(options.Label, ",") {
|
||||
kv := strings.SplitN(arg, "=", 2)
|
||||
switch kv[0] {
|
||||
case "upperdir":
|
||||
upperk = "upperdir="
|
||||
upperv = kv[1]
|
||||
case "workdir":
|
||||
workk = "workdir="
|
||||
workv = kv[1]
|
||||
case "lowerdir":
|
||||
lowerk = "lowerdir="
|
||||
lowerv = kv[1]
|
||||
case "label":
|
||||
labelk = "label="
|
||||
labelv = kv[1]
|
||||
default:
|
||||
if others == "" {
|
||||
others = arg
|
||||
} else {
|
||||
others = others + "," + arg
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure upperdir, workdir, and the target are absolute paths.
|
||||
if upperv != "" && !filepath.IsAbs(upperv) {
|
||||
upperv = filepath.Join(homedir, upperv)
|
||||
}
|
||||
if workv != "" && !filepath.IsAbs(workv) {
|
||||
workv = filepath.Join(homedir, workv)
|
||||
}
|
||||
if !filepath.IsAbs(options.Target) {
|
||||
options.Target = filepath.Join(homedir, options.Target)
|
||||
}
|
||||
|
||||
// Get a descriptor for each lower, and use that descriptor's name as
|
||||
// the new value for the list of lowers, because it's shorter.
|
||||
if lowerv != "" {
|
||||
lowers := strings.Split(lowerv, ":")
|
||||
for i := range lowers {
|
||||
lowerFd, err := unix.Open(lowers[i], unix.O_RDONLY, 0)
|
||||
if err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
lowers[i] = fmt.Sprintf("%d", lowerFd)
|
||||
}
|
||||
lowerv = strings.Join(lowers, ":")
|
||||
}
|
||||
|
||||
// Reconstruct the Label field.
|
||||
options.Label = upperk + upperv + "," + workk + workv + "," + lowerk + lowerv + "," + labelk + labelv + "," + others
|
||||
options.Label = strings.ReplaceAll(options.Label, ",,", ",")
|
||||
|
||||
// Okay, try this, if we managed to make the arguments fit.
|
||||
var err error
|
||||
if len(options.Label) < pageSize {
|
||||
if err := os.Chdir("/proc/self/fd"); err != nil {
|
||||
fatal(err)
|
||||
}
|
||||
err = unix.Mount(options.Device, options.Target, options.Type, uintptr(options.Flag), options.Label)
|
||||
} else {
|
||||
err = fmt.Errorf("cannot mount layer, mount data %q too large %d >= page size %d", options.Label, len(options.Label), pageSize)
|
||||
}
|
||||
|
||||
// Clean up.
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "creating overlay mount to %s, mount_data=%q\n", options.Target, options.Label)
|
||||
fatal(err)
|
||||
}
|
||||
|
||||
|
||||
52
vendor/github.com/containers/storage/drivers/overlay/overlay.go
generated
vendored
52
vendor/github.com/containers/storage/drivers/overlay/overlay.go
generated
vendored
@@ -73,21 +73,23 @@ const (
|
||||
// or root directory. Mounts are always done relative to root and
|
||||
// referencing the symbolic links in order to ensure the number of
|
||||
// lower directories can fit in a single page for making the mount
|
||||
// syscall. A hard upper limit of 128 lower layers is enforced to ensure
|
||||
// syscall. A hard upper limit of 500 lower layers is enforced to ensure
|
||||
// that mounts do not fail due to length.
|
||||
|
||||
const (
|
||||
linkDir = "l"
|
||||
lowerFile = "lower"
|
||||
maxDepth = 128
|
||||
maxDepth = 500
|
||||
|
||||
// idLength represents the number of random characters
|
||||
// which can be used to create the unique link identifier
|
||||
// for every layer. If this value is too long then the
|
||||
// page size limit for the mount command may be exceeded.
|
||||
// The idLength should be selected such that following equation
|
||||
// is true (512 is a buffer for label metadata).
|
||||
// ((idLength + len(linkDir) + 1) * maxDepth) <= (pageSize - 512)
|
||||
// is true (512 is a buffer for label metadata, 128 is the
|
||||
// number of lowers we want to be able to use without having
|
||||
// to use bind mounts to get all the way to the kernel limit).
|
||||
// ((idLength + len(linkDir) + 1) * 128) <= (pageSize - 512)
|
||||
idLength = 26
|
||||
)
|
||||
|
||||
@@ -1376,27 +1378,9 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
|
||||
return "", errors.New("max depth exceeded")
|
||||
}
|
||||
|
||||
// absLowers is the list of lowers as absolute paths, which works well with additional stores.
|
||||
// absLowers is the list of lowers as absolute paths.
|
||||
absLowers := []string{}
|
||||
// relLowers is the list of lowers as paths relative to the driver's home directory.
|
||||
relLowers := []string{}
|
||||
|
||||
// Check if $link/../diff{1-*} exist. If they do, add them, in order, as the front of the lowers
|
||||
// lists that we're building. "diff" itself is the upper, so it won't be in the lists.
|
||||
link, err := os.ReadFile(path.Join(dir, "link"))
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return "", err
|
||||
}
|
||||
logrus.Warnf("Can't read parent link %q because it does not exist. Going through storage to recreate the missing links.", path.Join(dir, "link"))
|
||||
if err := d.recreateSymlinks(); err != nil {
|
||||
return "", fmt.Errorf("recreating the links: %w", err)
|
||||
}
|
||||
link, err = os.ReadFile(path.Join(dir, "link"))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
diffN := 1
|
||||
perms := defaultPerms
|
||||
if d.options.forceMask != nil {
|
||||
@@ -1410,7 +1394,6 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
|
||||
}
|
||||
for err == nil {
|
||||
absLowers = append(absLowers, filepath.Join(dir, nameWithSuffix("diff", diffN)))
|
||||
relLowers = append(relLowers, dumbJoin(linkDir, string(link), "..", nameWithSuffix("diff", diffN)))
|
||||
diffN++
|
||||
st, err = os.Stat(filepath.Join(dir, nameWithSuffix("diff", diffN)))
|
||||
if err == nil && !permsKnown {
|
||||
@@ -1435,6 +1418,7 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
|
||||
perms = os.FileMode(st2.Mode())
|
||||
permsKnown = true
|
||||
}
|
||||
l = lower
|
||||
break
|
||||
}
|
||||
lower = ""
|
||||
@@ -1459,12 +1443,10 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
|
||||
lower = newpath
|
||||
}
|
||||
absLowers = append(absLowers, lower)
|
||||
relLowers = append(relLowers, l)
|
||||
diffN = 1
|
||||
_, err = os.Stat(dumbJoin(lower, "..", nameWithSuffix("diff", diffN)))
|
||||
for err == nil {
|
||||
absLowers = append(absLowers, dumbJoin(lower, "..", nameWithSuffix("diff", diffN)))
|
||||
relLowers = append(relLowers, dumbJoin(l, "..", nameWithSuffix("diff", diffN)))
|
||||
diffN++
|
||||
_, err = os.Stat(dumbJoin(lower, "..", nameWithSuffix("diff", diffN)))
|
||||
}
|
||||
@@ -1472,7 +1454,6 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
|
||||
|
||||
if len(absLowers) == 0 {
|
||||
absLowers = append(absLowers, path.Join(dir, "empty"))
|
||||
relLowers = append(relLowers, path.Join(id, "empty"))
|
||||
}
|
||||
// user namespace requires this to move a directory from lower to upper.
|
||||
rootUID, rootGID, err := idtools.GetRootUIDGID(d.uidMaps, d.gidMaps)
|
||||
@@ -1606,28 +1587,23 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
|
||||
return nil
|
||||
}
|
||||
} else if len(mountData) >= pageSize {
|
||||
// Use relative paths and mountFrom when the mount data has exceeded
|
||||
// the page size. The mount syscall fails if the mount data cannot
|
||||
// fit within a page and relative links make the mount data much
|
||||
// smaller at the expense of requiring a fork exec to chroot.
|
||||
// Use mountFrom when the mount data has exceeded the page size. The mount syscall fails if
|
||||
// the mount data cannot fit within a page and relative links make the mount data much
|
||||
// smaller at the expense of requiring a fork exec to chdir().
|
||||
|
||||
workdir = path.Join(id, "work")
|
||||
//FIXME: We need to figure out to get this to work with additional stores
|
||||
if readWrite {
|
||||
diffDir := path.Join(id, "diff")
|
||||
opts = fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", strings.Join(relLowers, ":"), diffDir, workdir)
|
||||
opts = fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", strings.Join(absLowers, ":"), diffDir, workdir)
|
||||
} else {
|
||||
opts = fmt.Sprintf("lowerdir=%s:%s", diffDir, strings.Join(relLowers, ":"))
|
||||
opts = fmt.Sprintf("lowerdir=%s:%s", diffDir, strings.Join(absLowers, ":"))
|
||||
}
|
||||
if len(optsList) > 0 {
|
||||
opts = fmt.Sprintf("%s,%s", opts, strings.Join(optsList, ","))
|
||||
}
|
||||
mountData = label.FormatMountLabel(opts, options.MountLabel)
|
||||
if len(mountData) >= pageSize {
|
||||
return "", fmt.Errorf("cannot mount layer, mount label %q too large %d >= page size %d", options.MountLabel, len(mountData), pageSize)
|
||||
}
|
||||
mountFunc = func(source string, target string, mType string, flags uintptr, label string) error {
|
||||
return mountFrom(d.home, source, target, mType, flags, label)
|
||||
return mountOverlayFrom(d.home, source, target, mType, flags, label)
|
||||
}
|
||||
mountTarget = path.Join(id, "merged")
|
||||
}
|
||||
|
||||
3
vendor/github.com/containers/storage/drivers/template.go
generated
vendored
3
vendor/github.com/containers/storage/drivers/template.go
generated
vendored
@@ -1,9 +1,8 @@
|
||||
package graphdriver
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/containers/storage/pkg/idtools"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// TemplateDriver is just barely enough of a driver that we can implement a
|
||||
|
||||
2
vendor/github.com/containers/storage/drivers/vfs/driver.go
generated
vendored
2
vendor/github.com/containers/storage/drivers/vfs/driver.go
generated
vendored
@@ -194,7 +194,7 @@ func (d *Driver) create(id, parent string, opts *graphdriver.CreateOpts, ro bool
|
||||
if parent != "" {
|
||||
parentDir, err := d.Get(parent, graphdriver.MountOpts{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: %s", parent, err)
|
||||
return fmt.Errorf("%s: %w", parent, err)
|
||||
}
|
||||
if err := dirCopy(parentDir, dir); err != nil {
|
||||
return err
|
||||
|
||||
9
vendor/github.com/containers/storage/drivers/zfs/zfs_unsupported.go
generated
vendored
9
vendor/github.com/containers/storage/drivers/zfs/zfs_unsupported.go
generated
vendored
@@ -1,11 +1,4 @@
|
||||
//go:build !linux && !freebsd
|
||||
// +build !linux,!freebsd
|
||||
|
||||
package zfs
|
||||
|
||||
func checkRootdirFs(rootdir string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func getMountpoint(id string) string {
|
||||
return id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user