summaryrefslogtreecommitdiff
path: root/pkg/domain/infra/abi/archive.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-01-22 15:38:51 +0100
committerValentin Rothberg <rothberg@redhat.com>2021-01-26 09:01:33 +0100
commit7b186dcb9e79c15a4d5506db8922281cd8034a58 (patch)
tree24eed190348a717bf19273ed31f9c2a3c40178dc /pkg/domain/infra/abi/archive.go
parent6ba8819d336ed3514b57c5818123ddfac80555ef (diff)
downloadpodman-7b186dcb9e79c15a4d5506db8922281cd8034a58.tar.gz
podman-7b186dcb9e79c15a4d5506db8922281cd8034a58.tar.bz2
podman-7b186dcb9e79c15a4d5506db8922281cd8034a58.zip
libpod: add (*Container).ResolvePath()
Add an API to libpod to resolve a path on the container. We can refactor the code that was originally written for copy. Other functions are requiring a proper path resolution, so libpod seems like a reasonable home for sharing that code. Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg/domain/infra/abi/archive.go')
-rw-r--r--pkg/domain/infra/abi/archive.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/pkg/domain/infra/abi/archive.go b/pkg/domain/infra/abi/archive.go
index 809813756..c64dfb02a 100644
--- a/pkg/domain/infra/abi/archive.go
+++ b/pkg/domain/infra/abi/archive.go
@@ -26,13 +26,18 @@ func (ic *ContainerEngine) ContainerCopyFromArchive(ctx context.Context, nameOrI
return nil, err
}
+ containerMountPoint, err := container.Mount()
+ if err != nil {
+ return nil, err
+ }
+
unmount := func() {
if err := container.Unmount(false); err != nil {
logrus.Errorf("Error unmounting container: %v", err)
}
}
- _, resolvedRoot, resolvedContainerPath, err := ic.containerStat(container, containerPath)
+ _, resolvedRoot, resolvedContainerPath, err := ic.containerStat(container, containerMountPoint, containerPath)
if err != nil {
unmount()
return nil, err
@@ -71,6 +76,11 @@ func (ic *ContainerEngine) ContainerCopyToArchive(ctx context.Context, nameOrID
return nil, err
}
+ containerMountPoint, err := container.Mount()
+ if err != nil {
+ return nil, err
+ }
+
unmount := func() {
if err := container.Unmount(false); err != nil {
logrus.Errorf("Error unmounting container: %v", err)
@@ -83,7 +93,7 @@ func (ic *ContainerEngine) ContainerCopyToArchive(ctx context.Context, nameOrID
containerPath = "/."
}
- _, resolvedRoot, resolvedContainerPath, err := ic.containerStat(container, containerPath)
+ _, resolvedRoot, resolvedContainerPath, err := ic.containerStat(container, containerMountPoint, containerPath)
if err != nil {
unmount()
return nil, err