Change Mounted to return the number of times mounted
podman unmount wants to know if the image is only mounted 1 time and refuse to unmount if the container state expects it to be mounted. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
46a8a1cddb
commit
1538971882
|
|
@ -88,7 +88,7 @@ func mounted(flags *mflag.FlagSet, action string, m storage.Store, args []string
|
|||
errText = fmt.Sprintf("%v", err)
|
||||
errors = true
|
||||
} else {
|
||||
if mounted {
|
||||
if mounted > 0 {
|
||||
fmt.Printf("%s mounted\n", arg)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
10
layers.go
10
layers.go
|
|
@ -213,8 +213,8 @@ type LayerStore interface {
|
|||
// Unmount unmounts a layer when it is no longer in use.
|
||||
Unmount(id string, force bool) (bool, error)
|
||||
|
||||
// Mounted returns whether or not the layer is mounted.
|
||||
Mounted(id string) (bool, error)
|
||||
// Mounted returns number of times the layer has been mounted.
|
||||
Mounted(id string) (int, error)
|
||||
|
||||
// ParentOwners returns the UIDs and GIDs of parents of the layer's mountpoint
|
||||
// for which the layer's UID and GID maps don't contain corresponding entries.
|
||||
|
|
@ -627,12 +627,12 @@ func (r *layerStore) Create(id string, parent *Layer, names []string, mountLabel
|
|||
return r.CreateWithFlags(id, parent, names, mountLabel, options, moreOptions, writeable, nil)
|
||||
}
|
||||
|
||||
func (r *layerStore) Mounted(id string) (bool, error) {
|
||||
func (r *layerStore) Mounted(id string) (int, error) {
|
||||
layer, ok := r.lookup(id)
|
||||
if !ok {
|
||||
return false, ErrLayerUnknown
|
||||
return 0, ErrLayerUnknown
|
||||
}
|
||||
return layer.MountCount > 0, nil
|
||||
return layer.MountCount, nil
|
||||
}
|
||||
|
||||
func (r *layerStore) Mount(id, mountLabel string) (string, error) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// Code generated by ffjson <https://github.com/pquerna/ffjson>. DO NOT EDIT.
|
||||
// source: ./layers.go
|
||||
// source: layers.go
|
||||
|
||||
package storage
|
||||
|
||||
|
|
|
|||
8
store.go
8
store.go
|
|
@ -265,8 +265,8 @@ type Store interface {
|
|||
// name, or a mount path. Returns whether or not the layer is still mounted.
|
||||
Unmount(id string, force bool) (bool, error)
|
||||
|
||||
// Unmount attempts to discover whether the specified id is mounted.
|
||||
Mounted(id string) (bool, error)
|
||||
// Mounted returns number of times the layer has been mounted.
|
||||
Mounted(id string) (int, error)
|
||||
|
||||
// Changes returns a summary of the changes which would need to be made
|
||||
// to one layer to make its contents the same as a second layer. If
|
||||
|
|
@ -2248,13 +2248,13 @@ func (s *store) Mount(id, mountLabel string) (string, error) {
|
|||
return "", ErrLayerUnknown
|
||||
}
|
||||
|
||||
func (s *store) Mounted(id string) (bool, error) {
|
||||
func (s *store) Mounted(id string) (int, error) {
|
||||
if layerID, err := s.ContainerLayerID(id); err == nil {
|
||||
id = layerID
|
||||
}
|
||||
rlstore, err := s.LayerStore()
|
||||
if err != nil {
|
||||
return false, err
|
||||
return 0, err
|
||||
}
|
||||
rlstore.Lock()
|
||||
defer rlstore.Unlock()
|
||||
|
|
|
|||
Loading…
Reference in New Issue