Class: MiqDisk
- Inherits:
-
Object
- Object
- MiqDisk
- Defined in:
- lib/disk/MiqDisk.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#blockSize ⇒ Object
Returns the value of attribute blockSize.
-
#dInfo ⇒ Object
Returns the value of attribute dInfo.
-
#diskType ⇒ Object
Returns the value of attribute diskType.
-
#endByteAddr ⇒ Object
readonly
Returns the value of attribute endByteAddr.
-
#fs ⇒ Object
Returns the value of attribute fs.
-
#hwId ⇒ Object
readonly
Returns the value of attribute hwId.
-
#lbaEnd ⇒ Object
readonly
Returns the value of attribute lbaEnd.
-
#lbaStart ⇒ Object
readonly
Returns the value of attribute lbaStart.
-
#logName ⇒ Object
readonly
Returns the value of attribute logName.
-
#partNum ⇒ Object
readonly
Returns the value of attribute partNum.
-
#partType ⇒ Object
readonly
Returns the value of attribute partType.
-
#pvObj ⇒ Object
Returns the value of attribute pvObj.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#startByteAddr ⇒ Object
readonly
Returns the value of attribute startByteAddr.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #diskSig ⇒ Object
- #getPartitions ⇒ Object
-
#initialize(dm, dInfo, pType, *lbaSE) ⇒ MiqDisk
constructor
A new instance of MiqDisk.
- #pushFormatSupport ⇒ Object
- #read(len) ⇒ Object
- #seek(amt, whence = IO::SEEK_SET) ⇒ Object
- #seekPos ⇒ Object
- #write(buf, len) ⇒ Object
Constructor Details
#initialize(dm, dInfo, pType, *lbaSE) ⇒ MiqDisk
Returns a new instance of MiqDisk.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/disk/MiqDisk.rb', line 37 def initialize(dm, dInfo, pType, *lbaSE) extend(dm) unless dm.nil? @dModule = dm @dInfo = dInfo @partType = pType @partNum = lbaSE.length == 3 ? lbaSE[2] : 0 @partitions = nil @pvObj = nil @fs = nil # the filesystem that resides on this disk if dInfo.lvObj @logName = "logical volume: #{dInfo.lvObj.vgObj.vgName}/#{dInfo.lvObj.lvName}" else @logName = "disk file: #{dInfo.fileName}" end @logName << " (partition: #{@partNum})" $log.debug "MiqDisk<#{object_id}> initialize, #{@logName}" d_init case lbaSE.length when 0 @lbaStart = 0 @lbaEnd = d_size when 1 @lbaStart = lbaSE[0] @lbaEnd = d_size else @lbaStart = lbaSE[0] @lbaEnd = lbaSE[1] + @lbaStart # lbaSE[1] is the partiton size in sectors end @startByteAddr = @lbaStart * @blockSize @endByteAddr = @lbaEnd * @blockSize @size = @endByteAddr - @startByteAddr @seekPos = @startByteAddr @dInfo.diskSig ||= getDiskSig if @partNum == 0 && !@dInfo.baseOnly @hwId = "#{@dInfo.hardwareId}:#{@partNum}" if @dInfo.hardwareId end |
Instance Attribute Details
#blockSize ⇒ Object
Returns the value of attribute blockSize.
5 6 7 |
# File 'lib/disk/MiqDisk.rb', line 5 def blockSize @blockSize end |
#dInfo ⇒ Object
Returns the value of attribute dInfo.
5 6 7 |
# File 'lib/disk/MiqDisk.rb', line 5 def dInfo @dInfo end |
#diskType ⇒ Object
Returns the value of attribute diskType.
5 6 7 |
# File 'lib/disk/MiqDisk.rb', line 5 def diskType @diskType end |
#endByteAddr ⇒ Object (readonly)
Returns the value of attribute endByteAddr.
6 7 8 |
# File 'lib/disk/MiqDisk.rb', line 6 def endByteAddr @endByteAddr end |
#fs ⇒ Object
Returns the value of attribute fs.
5 6 7 |
# File 'lib/disk/MiqDisk.rb', line 5 def fs @fs end |
#hwId ⇒ Object (readonly)
Returns the value of attribute hwId.
6 7 8 |
# File 'lib/disk/MiqDisk.rb', line 6 def hwId @hwId end |
#lbaEnd ⇒ Object (readonly)
Returns the value of attribute lbaEnd.
6 7 8 |
# File 'lib/disk/MiqDisk.rb', line 6 def lbaEnd @lbaEnd end |
#lbaStart ⇒ Object (readonly)
Returns the value of attribute lbaStart.
6 7 8 |
# File 'lib/disk/MiqDisk.rb', line 6 def lbaStart @lbaStart end |
#logName ⇒ Object (readonly)
Returns the value of attribute logName.
6 7 8 |
# File 'lib/disk/MiqDisk.rb', line 6 def logName @logName end |
#partNum ⇒ Object (readonly)
Returns the value of attribute partNum.
6 7 8 |
# File 'lib/disk/MiqDisk.rb', line 6 def partNum @partNum end |
#partType ⇒ Object (readonly)
Returns the value of attribute partType.
6 7 8 |
# File 'lib/disk/MiqDisk.rb', line 6 def partType @partType end |
#pvObj ⇒ Object
Returns the value of attribute pvObj.
5 6 7 |
# File 'lib/disk/MiqDisk.rb', line 5 def pvObj @pvObj end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
6 7 8 |
# File 'lib/disk/MiqDisk.rb', line 6 def size @size end |
#startByteAddr ⇒ Object (readonly)
Returns the value of attribute startByteAddr.
6 7 8 |
# File 'lib/disk/MiqDisk.rb', line 6 def startByteAddr @startByteAddr end |
Class Method Details
.getDisk(dInfo, probes = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/disk/MiqDisk.rb', line 8 def self.getDisk(dInfo, probes = nil) $log.debug "MiqDisk::getDisk: baseOnly = #{dInfo.baseOnly}" if $log if (dm = DiskProbe.getDiskMod(dInfo, probes)) d = new(dm, dInfo.clone, 0) if dInfo.baseOnly $log.debug "MiqDisk::getDisk: baseOnly = true, returning parent: #{d.getBase.dInfo.fileName}" if $log $log.debug "MiqDisk::getDisk: child (current) disk file: #{dInfo.fileName}" if $log return d.getBase else $log.debug "MiqDisk::getDisk: baseOnly = false, returning: #{dInfo.fileName}" if $log end return d end (nil) end |
.pushFormatSupportForDisk(disk, probes = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/disk/MiqDisk.rb', line 24 def self.pushFormatSupportForDisk(disk, probes = nil) if (dm = DiskProbe.getDiskModForDisk(disk, probes)) $log.debug "#{name}.pushFormatSupportForDisk: pushing #{dm.name} onto #{disk.logName}" di = disk.dInfo.clone di.downstreamDisk = disk d = new(dm, di, 0) disk.dInfo.upstreamDisk = d return d end $log.debug "#{name}.pushFormatSupportForDisk: no module to push for #{disk.logName}" disk end |
Instance Method Details
#close ⇒ Object
118 119 120 121 122 123 |
# File 'lib/disk/MiqDisk.rb', line 118 def close $log.debug "MiqDisk<#{object_id}> close, #{@logName}" if $log @partitions.each(&:close) if @partitions @partitions = nil d_close end |
#diskSig ⇒ Object
82 83 84 |
# File 'lib/disk/MiqDisk.rb', line 82 def diskSig @dInfo.diskSig ||= getDiskSig end |
#getPartitions ⇒ Object
86 87 88 |
# File 'lib/disk/MiqDisk.rb', line 86 def getPartitions discoverPartitions end |
#pushFormatSupport ⇒ Object
78 79 80 |
# File 'lib/disk/MiqDisk.rb', line 78 def pushFormatSupport self.class.pushFormatSupportForDisk(self) end |
#read(len) ⇒ Object
106 107 108 109 110 |
# File 'lib/disk/MiqDisk.rb', line 106 def read(len) rb = d_read(@seekPos, len) @seekPos += rb.length unless rb.nil? (rb) end |
#seek(amt, whence = IO::SEEK_SET) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/disk/MiqDisk.rb', line 94 def seek(amt, whence = IO::SEEK_SET) case whence when IO::SEEK_CUR @seekPos += amt when IO::SEEK_END @seekPos = @endByteAddr + amt when IO::SEEK_SET @seekPos = amt + @startByteAddr end @seekPos end |
#seekPos ⇒ Object
90 91 92 |
# File 'lib/disk/MiqDisk.rb', line 90 def seekPos @seekPos - @startByteAddr end |
#write(buf, len) ⇒ Object
112 113 114 115 116 |
# File 'lib/disk/MiqDisk.rb', line 112 def write(buf, len) nbytes = d_write(@seekPos, buf, len) @seekPos += nbytes (nbytes) end |