mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-04 04:31:28 +00:00
devicemapper: Create a method to get device info with deferred remove field
Deferred reove functionality was added to library later. So in old version of library it did not report deferred_remove field. Create a new function which also gets deferred_remove field and it will be called only on newer version of library. Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
@@ -87,16 +87,17 @@ type (
|
||||
Device []uint64
|
||||
}
|
||||
Info struct {
|
||||
Exists int
|
||||
Suspended int
|
||||
LiveTable int
|
||||
InactiveTable int
|
||||
OpenCount int32
|
||||
EventNr uint32
|
||||
Major uint32
|
||||
Minor uint32
|
||||
ReadOnly int
|
||||
TargetCount int32
|
||||
Exists int
|
||||
Suspended int
|
||||
LiveTable int
|
||||
InactiveTable int
|
||||
OpenCount int32
|
||||
EventNr uint32
|
||||
Major uint32
|
||||
Minor uint32
|
||||
ReadOnly int
|
||||
TargetCount int32
|
||||
DeferredRemove int
|
||||
}
|
||||
TaskType int
|
||||
AddNodeType int
|
||||
@@ -222,6 +223,14 @@ func (t *Task) GetInfo() (*Info, error) {
|
||||
return info, nil
|
||||
}
|
||||
|
||||
func (t *Task) GetInfoWithDeferred() (*Info, error) {
|
||||
info := &Info{}
|
||||
if res := DmTaskGetInfoWithDeferred(t.unmanaged, info); res != 1 {
|
||||
return nil, ErrTaskGetInfo
|
||||
}
|
||||
return info, nil
|
||||
}
|
||||
|
||||
func (t *Task) GetDriverVersion() (string, error) {
|
||||
res := DmTaskGetDriverVersion(t.unmanaged)
|
||||
if res == "" {
|
||||
@@ -531,6 +540,17 @@ func GetInfo(name string) (*Info, error) {
|
||||
return task.GetInfo()
|
||||
}
|
||||
|
||||
func GetInfoWithDeferred(name string) (*Info, error) {
|
||||
task, err := TaskCreateNamed(DeviceInfo, name)
|
||||
if task == nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := task.Run(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return task.GetInfoWithDeferred()
|
||||
}
|
||||
|
||||
func GetDriverVersion() (string, error) {
|
||||
task := TaskCreate(DeviceVersion)
|
||||
if task == nil {
|
||||
|
||||
Reference in New Issue
Block a user