mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Implement container.ExportRW() on device-mapper
This commit is contained in:
parent
223280f319
commit
94fa3c7bb5
2 changed files with 40 additions and 1 deletions
10
container.go
10
container.go
|
@ -1110,7 +1110,15 @@ func (container *Container) Resize(h, w int) error {
|
|||
}
|
||||
|
||||
func (container *Container) ExportRw() (Archive, error) {
|
||||
return Tar(container.rwPath(), Uncompressed)
|
||||
if err := container.EnsureMounted(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
image, err := container.GetImage()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return image.ExportChanges(container.runtime, container.RootfsPath(), container.rwPath(), container.ID)
|
||||
}
|
||||
|
||||
func (container *Container) RwChecksum() (string, error) {
|
||||
|
|
31
image.go
31
image.go
|
@ -523,6 +523,37 @@ func (image *Image) Changes(runtime *Runtime, root, rw, id string) ([]Change, er
|
|||
return nil, fmt.Errorf("No supported Changes implementation")
|
||||
}
|
||||
|
||||
func (image *Image) ExportChanges(runtime *Runtime, root, rw, id string) (Archive, error) {
|
||||
switch runtime.GetMountMethod() {
|
||||
case MountMethodAUFS:
|
||||
return Tar(rw, Uncompressed)
|
||||
|
||||
case MountMethodDeviceMapper:
|
||||
changes, err := image.Changes(runtime, root, rw, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
files := make([]string, 0)
|
||||
deletions := make([]string, 0)
|
||||
for _, change := range changes {
|
||||
if change.Kind == ChangeModify || change.Kind == ChangeAdd {
|
||||
files = append(files, change.Path)
|
||||
}
|
||||
if change.Kind == ChangeDelete {
|
||||
base := filepath.Base(change.Path)
|
||||
dir := filepath.Dir(change.Path)
|
||||
deletions = append(deletions, filepath.Join(dir, ".wh."+base))
|
||||
}
|
||||
}
|
||||
|
||||
return TarFilter(root, Uncompressed, files, false, deletions)
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("No supported Changes implementation")
|
||||
}
|
||||
|
||||
|
||||
func (image *Image) ShortID() string {
|
||||
return utils.TruncateID(image.ID)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue