Merge pull request #2374 from giuseppe/look-mountpoint-in-mapped-layers
image: look for mountpoint in mapped layers too
This commit is contained in:
commit
c3a3c62b3f
|
|
@ -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
|
// Mountpoint returns the path to image's mount point. The path is empty if
|
||||||
// the image is not mounted.
|
// the image is not mounted.
|
||||||
func (i *Image) Mountpoint() (string, error) {
|
func (i *Image) Mountpoint() (string, error) {
|
||||||
mountedTimes, err := i.runtime.store.Mounted(i.TopLayer())
|
for _, layerID := range append([]string{i.TopLayer()}, i.storageImage.MappedTopLayers...) {
|
||||||
if err != nil || mountedTimes == 0 {
|
mountedTimes, err := i.runtime.store.Mounted(layerID)
|
||||||
if errors.Is(err, storage.ErrLayerUnknown) {
|
if err != nil {
|
||||||
// Can happen, Podman did it, but there's no
|
if errors.Is(err, storage.ErrLayerUnknown) {
|
||||||
// explanation why.
|
// Can happen, Podman did it, but there's no
|
||||||
err = nil
|
// 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
|
|
||||||
}
|
}
|
||||||
|
return "", nil
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unmount the image. Use force to ignore the reference counter and forcefully
|
// Unmount the image. Use force to ignore the reference counter and forcefully
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue