Skip to content

image: look for mountpoint in mapped layers too #2374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions libimage/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,27 +789,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
Expand Down