mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Update overlay2 to use naive diff for changes
The archive changes function is not implemented correctly to handle opaque directories. Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
parent
de0abf4315
commit
ac5d363e67
3 changed files with 2 additions and 40 deletions
|
|
@ -754,16 +754,5 @@ func (d *Driver) Diff(id, parent string) (io.ReadCloser, error) {
|
||||||
// Changes produces a list of changes between the specified layer and its
|
// Changes produces a list of changes between the specified layer and its
|
||||||
// parent layer. If parent is "", then all changes will be ADD changes.
|
// parent layer. If parent is "", then all changes will be ADD changes.
|
||||||
func (d *Driver) Changes(id, parent string) ([]archive.Change, error) {
|
func (d *Driver) Changes(id, parent string) ([]archive.Change, error) {
|
||||||
if useNaiveDiff(d.home) || !d.isParent(id, parent) {
|
return d.naiveDiff.Changes(id, parent)
|
||||||
return d.naiveDiff.Changes(id, parent)
|
|
||||||
}
|
|
||||||
// Overlay doesn't have snapshots, so we need to get changes from all parent
|
|
||||||
// layers.
|
|
||||||
diffPath := d.getDiffPath(id)
|
|
||||||
layers, err := d.getLowerDirs(id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return archive.OverlayChanges(layers, diffPath)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ func TestOverlayDiffApply10Files(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOverlayChanges(t *testing.T) {
|
func TestOverlayChanges(t *testing.T) {
|
||||||
skipIfNaive(t)
|
t.Skipf("Cannot run test with naive change algorithm")
|
||||||
graphtest.DriverTestChanges(t, driverName)
|
graphtest.DriverTestChanges(t, driverName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -284,30 +284,3 @@ func clen(n []byte) int {
|
||||||
}
|
}
|
||||||
return len(n)
|
return len(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OverlayChanges walks the path rw and determines changes for the files in the path,
|
|
||||||
// with respect to the parent layers
|
|
||||||
func OverlayChanges(layers []string, rw string) ([]Change, error) {
|
|
||||||
return changes(layers, rw, overlayDeletedFile, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func overlayDeletedFile(root, path string, fi os.FileInfo) (string, error) {
|
|
||||||
if fi.Mode()&os.ModeCharDevice != 0 {
|
|
||||||
s := fi.Sys().(*syscall.Stat_t)
|
|
||||||
if unix.Major(uint64(s.Rdev)) == 0 && unix.Minor(uint64(s.Rdev)) == 0 { // nolint: unconvert
|
|
||||||
return path, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if fi.Mode()&os.ModeDir != 0 {
|
|
||||||
opaque, err := system.Lgetxattr(filepath.Join(root, path), "trusted.overlay.opaque")
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
if len(opaque) == 1 && opaque[0] == 'y' {
|
|
||||||
return path, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "", nil
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue