mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
api/types: move ContainerPathStat to api/types/container
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/moby/sys/symlink"
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
containertypes "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/container"
|
||||
"github.com/docker/docker/internal/compatcontext"
|
||||
"github.com/docker/docker/internal/mounttree"
|
||||
@@ -54,19 +54,19 @@ type containerFSView struct {
|
||||
}
|
||||
|
||||
// openContainerFS opens a new view of the container's filesystem.
|
||||
func (daemon *Daemon) openContainerFS(container *container.Container) (_ *containerFSView, err error) {
|
||||
func (daemon *Daemon) openContainerFS(ctr *container.Container) (_ *containerFSView, err error) {
|
||||
ctx := context.TODO()
|
||||
|
||||
if err := daemon.Mount(container); err != nil {
|
||||
if err := daemon.Mount(ctr); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
_ = daemon.Unmount(container)
|
||||
_ = daemon.Unmount(ctr)
|
||||
}
|
||||
}()
|
||||
|
||||
mounts, cleanup, err := daemon.setupMounts(ctx, container)
|
||||
mounts, cleanup, err := daemon.setupMounts(ctx, ctr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -74,7 +74,7 @@ func (daemon *Daemon) openContainerFS(container *container.Container) (_ *contai
|
||||
ctx := compatcontext.WithoutCancel(ctx)
|
||||
cleanup(ctx)
|
||||
if err != nil {
|
||||
_ = container.UnmountVolumes(ctx, daemon.LogVolumeEvent)
|
||||
_ = ctr.UnmountVolumes(ctx, daemon.LogVolumeEvent)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -89,7 +89,7 @@ func (daemon *Daemon) openContainerFS(container *container.Container) (_ *contai
|
||||
return err
|
||||
}
|
||||
for _, m := range mounts {
|
||||
dest, err := container.GetResourcePath(m.Destination)
|
||||
dest, err := ctr.GetResourcePath(m.Destination)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -147,7 +147,7 @@ func (daemon *Daemon) openContainerFS(container *container.Container) (_ *contai
|
||||
}
|
||||
}
|
||||
|
||||
return mounttree.SwitchRoot(container.BaseFS)
|
||||
return mounttree.SwitchRoot(ctr.BaseFS)
|
||||
},
|
||||
func() {
|
||||
defer close(done)
|
||||
@@ -168,7 +168,7 @@ func (daemon *Daemon) openContainerFS(container *container.Container) (_ *contai
|
||||
}
|
||||
vw := &containerFSView{
|
||||
d: daemon,
|
||||
ctr: container,
|
||||
ctr: ctr,
|
||||
todo: todo,
|
||||
done: done,
|
||||
}
|
||||
@@ -219,8 +219,8 @@ func (vw *containerFSView) Close() error {
|
||||
|
||||
// Stat returns the metadata for path, relative to the current working directory
|
||||
// of vw inside the container filesystem view.
|
||||
func (vw *containerFSView) Stat(ctx context.Context, path string) (*types.ContainerPathStat, error) {
|
||||
var stat *types.ContainerPathStat
|
||||
func (vw *containerFSView) Stat(ctx context.Context, path string) (*containertypes.PathStat, error) {
|
||||
var stat *containertypes.PathStat
|
||||
err := vw.RunInFS(ctx, func() error {
|
||||
lstat, err := os.Lstat(path)
|
||||
if err != nil {
|
||||
@@ -235,7 +235,7 @@ func (vw *containerFSView) Stat(ctx context.Context, path string) (*types.Contai
|
||||
return err
|
||||
}
|
||||
}
|
||||
stat = &types.ContainerPathStat{
|
||||
stat = &containertypes.PathStat{
|
||||
Name: filepath.Base(path),
|
||||
Size: lstat.Size(),
|
||||
Mode: lstat.Mode(),
|
||||
|
||||
Reference in New Issue
Block a user