Merge pull request #2374 from giuseppe/look-mountpoint-in-mapped-layers

image: look for mountpoint in mapped layers too
This commit is contained in:
openshift-merge-bot[bot] 2025-03-26 10:12:58 +00:00 committed by GitHub
commit c3a3c62b3f
1 changed files with 17 additions and 19 deletions

View File

@ -798,27 +798,25 @@ func (i *Image) Mount(_ context.Context, mountOptions []string, mountLabel strin
// Mountpoint returns the path to image's mount point. The path is empty if
// the image is not mounted.
func (i *Image) Mountpoint() (string, error) {
mountedTimes, err := i.runtime.store.Mounted(i.TopLayer())
if err != nil || mountedTimes == 0 {
if errors.Is(err, storage.ErrLayerUnknown) {
// Can happen, Podman did it, but there's no
// explanation why.
err = nil
for _, layerID := range append([]string{i.TopLayer()}, i.storageImage.MappedTopLayers...) {
mountedTimes, err := i.runtime.store.Mounted(layerID)
if err != nil {
if errors.Is(err, storage.ErrLayerUnknown) {
// Can happen, Podman did it, but there's no
// explanation why.
continue
}
return "", err
}
if mountedTimes > 0 {
layer, err := i.runtime.store.Layer(layerID)
if err != nil {
return "", err
}
return filepath.EvalSymlinks(layer.MountPoint)
}
return "", err
}
layer, err := i.runtime.store.Layer(i.TopLayer())
if err != nil {
return "", err
}
mountPoint, err := filepath.EvalSymlinks(layer.MountPoint)
if err != nil {
return "", err
}
return mountPoint, nil
return "", nil
}
// Unmount the image. Use force to ignore the reference counter and forcefully