Class: UBLK::Target
- Inherits:
-
Object
- Object
- UBLK::Target
- Defined in:
- lib/ublk/target.rb,
sig/ublk.rbs
Instance Attribute Summary collapse
-
#depth ⇒ Integer
readonly
Returns the value of attribute depth.
-
#queues ⇒ Integer
readonly
Returns the value of attribute queues.
-
#size ⇒ Integer
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #discard(_offset, _length) ⇒ Integer
- #flush ⇒ Integer
-
#initialize(size:, queues: 1, depth: 128) ⇒ Target
constructor
A new instance of Target.
- #logical_block_size ⇒ Integer
- #physical_block_size ⇒ Integer
- #read(_offset, _length) ⇒ String
- #read_only? ⇒ Boolean
- #rotational? ⇒ Boolean
- #write(_offset, _data) ⇒ Integer
- #write_zeroes(_offset, _length) ⇒ Integer
Constructor Details
#initialize(size:, queues: 1, depth: 128) ⇒ Target
Returns a new instance of Target.
7 8 9 10 11 12 13 14 15 |
# File 'lib/ublk/target.rb', line 7 def initialize(size:, queues: 1, depth: 128) raise ArgumentError, "size must be a positive multiple of 512" unless size.is_a?(Integer) && size.positive? && (size % 512).zero? raise ArgumentError, "queues must be between 1 and 4096" unless queues.is_a?(Integer) && queues.between?(1, 4096) raise ArgumentError, "depth must be between 1 and 4096" unless depth.is_a?(Integer) && depth.between?(1, 4096) @size = size @queues = queues @depth = depth end |
Instance Attribute Details
#depth ⇒ Integer (readonly)
Returns the value of attribute depth.
5 6 7 |
# File 'lib/ublk/target.rb', line 5 def depth @depth end |
#queues ⇒ Integer (readonly)
Returns the value of attribute queues.
5 6 7 |
# File 'lib/ublk/target.rb', line 5 def queues @queues end |
#size ⇒ Integer (readonly)
Returns the value of attribute size.
5 6 7 |
# File 'lib/ublk/target.rb', line 5 def size @size end |
Instance Method Details
#discard(_offset, _length) ⇒ Integer
29 30 31 |
# File 'lib/ublk/target.rb', line 29 def discard(_offset, _length) raise Errno::EOPNOTSUPP end |
#flush ⇒ Integer
27 |
# File 'lib/ublk/target.rb', line 27 def flush = 0 |
#logical_block_size ⇒ Integer
37 |
# File 'lib/ublk/target.rb', line 37 def logical_block_size = 512 |
#physical_block_size ⇒ Integer
38 |
# File 'lib/ublk/target.rb', line 38 def physical_block_size = 4096 |
#read(_offset, _length) ⇒ String
17 18 19 |
# File 'lib/ublk/target.rb', line 17 def read(_offset, _length) raise NotImplementedError, "targets must implement #read" end |
#read_only? ⇒ Boolean
39 |
# File 'lib/ublk/target.rb', line 39 def read_only? = false |
#rotational? ⇒ Boolean
40 |
# File 'lib/ublk/target.rb', line 40 def rotational? = false |
#write(_offset, _data) ⇒ Integer
21 22 23 24 25 |
# File 'lib/ublk/target.rb', line 21 def write(_offset, _data) raise Errno::EROFS if read_only? raise NotImplementedError, "targets must implement #write" end |
#write_zeroes(_offset, _length) ⇒ Integer
33 34 35 |
# File 'lib/ublk/target.rb', line 33 def write_zeroes(_offset, _length) raise Errno::EOPNOTSUPP end |