mirror of
https://github.com/containers/podman.git
synced 2025-09-16 14:17:38 +08:00
vendor: update c/storage to 26c561f9
update c/storage to commit 26c561f9a64585d9a25d340e1ae5479eca8008a1. It contains an important fix for partial pulls. [NO NEW TESTS NEEDED] Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
45
vendor/github.com/containers/storage/idset.go
generated
vendored
45
vendor/github.com/containers/storage/idset.go
generated
vendored
@ -1,6 +1,9 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/storage/pkg/idtools"
|
||||
"github.com/google/go-intervals/intervalset"
|
||||
"github.com/pkg/errors"
|
||||
@ -218,3 +221,45 @@ func maxInt(a, b int) int {
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func hasOverlappingRanges(mappings []idtools.IDMap) error {
|
||||
hostIntervals := intervalset.Empty()
|
||||
containerIntervals := intervalset.Empty()
|
||||
|
||||
var conflicts []string
|
||||
|
||||
for _, m := range mappings {
|
||||
c := interval{start: m.ContainerID, end: m.ContainerID + m.Size}
|
||||
h := interval{start: m.HostID, end: m.HostID + m.Size}
|
||||
|
||||
added := false
|
||||
overlaps := false
|
||||
|
||||
containerIntervals.IntervalsBetween(c, func(x intervalset.Interval) bool {
|
||||
overlaps = true
|
||||
return false
|
||||
})
|
||||
if overlaps {
|
||||
conflicts = append(conflicts, fmt.Sprintf("%v:%v:%v", m.ContainerID, m.HostID, m.Size))
|
||||
added = true
|
||||
}
|
||||
containerIntervals.Add(intervalset.NewSet([]intervalset.Interval{c}))
|
||||
|
||||
hostIntervals.IntervalsBetween(h, func(x intervalset.Interval) bool {
|
||||
overlaps = true
|
||||
return false
|
||||
})
|
||||
if overlaps && !added {
|
||||
conflicts = append(conflicts, fmt.Sprintf("%v:%v:%v", m.ContainerID, m.HostID, m.Size))
|
||||
}
|
||||
hostIntervals.Add(intervalset.NewSet([]intervalset.Interval{h}))
|
||||
}
|
||||
|
||||
if conflicts != nil {
|
||||
if len(conflicts) == 1 {
|
||||
return errors.Wrapf(ErrInvalidMappings, "the specified UID and/or GID mapping %s conflicts with other mappings", conflicts[0])
|
||||
}
|
||||
return errors.Wrapf(ErrInvalidMappings, "the specified UID and/or GID mappings %s conflict with other mappings", strings.Join(conflicts, ", "))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user