disk: new method for finding Mountable entities with a given mountpoint
This commit is contained in:
parent
6fc993d03c
commit
3f38602896
1 changed files with 12 additions and 0 deletions
|
|
@ -428,3 +428,15 @@ func forEachMountable(c Container, path []Entity, cb MountableCallback) error {
|
|||
func (pt *PartitionTable) ForEachMountable(cb MountableCallback) error {
|
||||
return forEachMountable(pt, []Entity{pt}, cb)
|
||||
}
|
||||
|
||||
// FindMountable returns the Mountable entity with the given mountpoint in the
|
||||
// PartitionTable. Returns nil if no Entity has the target as a Mountpoint.
|
||||
func (pt *PartitionTable) FindMountable(mountpoint string) Mountable {
|
||||
path := entityPath(pt, mountpoint)
|
||||
|
||||
if len(path) == 0 {
|
||||
return nil
|
||||
}
|
||||
// first path element is guaranteed to be Mountable
|
||||
return path[0].(Mountable)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue