mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add DeviceSet.HasActivatedDevice()
This lets you see if a device has been activated
This commit is contained in:
parent
41399ac005
commit
395bce4c41
2 changed files with 22 additions and 0 deletions
|
@ -9,6 +9,7 @@ type DeviceSet interface {
|
|||
UnmountDevice(hash, path string) error
|
||||
HasDevice(hash string) bool
|
||||
HasInitializedDevice(hash string) bool
|
||||
HasActivatedDevice(hash string) bool
|
||||
Shutdown() error
|
||||
}
|
||||
|
||||
|
@ -61,6 +62,10 @@ func (wrapper *DeviceSetWrapper) HasInitializedDevice(hash string) bool {
|
|||
return wrapper.wrapped.HasInitializedDevice(wrapper.wrap(hash))
|
||||
}
|
||||
|
||||
func (wrapper *DeviceSetWrapper) HasActivatedDevice(hash string) bool {
|
||||
return wrapper.wrapped.HasActivatedDevice(wrapper.wrap(hash))
|
||||
}
|
||||
|
||||
func NewDeviceSetWrapper(wrapped DeviceSet, prefix string) DeviceSet {
|
||||
wrapper := &DeviceSetWrapper{
|
||||
wrapped: wrapped,
|
||||
|
|
|
@ -851,6 +851,23 @@ func (devices *DeviceSetDM) HasInitializedDevice(hash string) bool {
|
|||
return info != nil && info.Initialized
|
||||
}
|
||||
|
||||
func (devices *DeviceSetDM) HasActivatedDevice(hash string) bool {
|
||||
if err := devices.ensureInit(); err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
info := devices.Devices[hash]
|
||||
if info == nil {
|
||||
return false
|
||||
}
|
||||
name := info.Name()
|
||||
devinfo, _ := devices.getInfo(name)
|
||||
if devinfo != nil && devinfo.Exists != 0 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (devices *DeviceSetDM) SetInitialized(hash string) error {
|
||||
if err := devices.ensureInit(); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in a new issue