diff --git a/cmd/containers-storage/mount.go b/cmd/containers-storage/mount.go index 7416ea70de..29e04f64c5 100644 --- a/cmd/containers-storage/mount.go +++ b/cmd/containers-storage/mount.go @@ -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) } } diff --git a/layers.go b/layers.go index 4baa5f1862..6760996d6b 100644 --- a/layers.go +++ b/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) { diff --git a/layers_ffjson.go b/layers_ffjson.go index 09b5d0f33e..125b5d8c97 100644 --- a/layers_ffjson.go +++ b/layers_ffjson.go @@ -1,5 +1,5 @@ // Code generated by ffjson . DO NOT EDIT. -// source: ./layers.go +// source: layers.go package storage diff --git a/store.go b/store.go index 41b66a356f..bdfbb1c2cb 100644 --- a/store.go +++ b/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()