daemon: rename vars that shadowed imports

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2026-01-21 16:36:05 +01:00
parent 2f6011c05f
commit e8f088caf7

View File

@@ -252,25 +252,23 @@ func (daemon *Daemon) registerMountPoints(ctr *container.Container, defaultReadO
return err
}
rwLayerOpts := &layer.CreateRWLayerOpts{
StorageOpt: ctr.HostConfig.StorageOpt,
}
// Hash the source and destination to create a safe, unique identifier for each mount point and container.
// This makes sure that the same image can be mounted multiple times with different destinations.
// We hash it so that the snapshot name is friendly to the underlying filesystem and doesn't exceed path length limits.
destHash := sha256.Sum256([]byte(ctr.ID + "-src=" + mp.Source + "-dst=" + mp.Destination))
layerName := hex.EncodeToString(destHash[:])
layer, err := daemon.imageService.CreateLayerFromImage(img, layerName, rwLayerOpts)
imgLayer, err := daemon.imageService.CreateLayerFromImage(img, layerName, &layer.CreateRWLayerOpts{
StorageOpt: ctr.HostConfig.StorageOpt,
})
if err != nil {
return err
}
metadata, err := layer.Metadata()
metadata, err := imgLayer.Metadata()
if err != nil {
return err
}
path, err := layer.Mount("")
srcPath, err := imgLayer.Mount("")
if err != nil {
return err
}
@@ -281,8 +279,8 @@ func (daemon *Daemon) registerMountPoints(ctr *container.Container, defaultReadO
mp.Name = mp.Spec.Source
mp.Spec.Source = img.ID().String()
mp.Source = path
mp.Layer = layer
mp.Source = srcPath
mp.Layer = imgLayer
mp.RW = false
case mounttypes.TypeTmpfs, mounttypes.TypeCluster, mounttypes.TypeNamedPipe:
// nothing to do