Skip to content

Commit

Permalink
Change Mounted to return the number of times mounted
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rhatdan committed Jul 17, 2018
1 parent 46a8a1c commit 1538971
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmd/containers-storage/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
10 changes: 5 additions & 5 deletions layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion layers_ffjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 1538971

Please sign in to comment.