Coverage Report - org.jscsi.target.scsi.cdb.Write6Cdb
 
Classes in this File Line Coverage Branch Coverage Complexity
Write6Cdb
0%
0/10
0%
0/4
1.6
 
 1  
 package org.jscsi.target.scsi.cdb;
 2  
 
 3  
 
 4  
 import java.nio.ByteBuffer;
 5  
 
 6  
 import org.jscsi.target.util.ReadWrite;
 7  
 
 8  
 
 9  
 /**
 10  
  * This class represents Command Descriptor Blocks for the <code>WRITE (6)</code> SCSI command.
 11  
  * <p>
 12  
  * The WRITE (6) command requests that the device server transfer the specified logical block(s) from the data-out
 13  
  * buffer and write them.
 14  
  * <p>
 15  
  * Each logical block transferred includes user data but does not include protection information. Each logical block
 16  
  * written includes user data and, if the medium is formatted with protection information enabled, protection
 17  
  * information.
 18  
  * <p>
 19  
  * A TRANSFER LENGTH field set to zero specifies that 256 logical blocks shall be written. Any other value specifies the
 20  
  * number of logical blocks that shall be written.
 21  
  * 
 22  
  * @author Andreas Ergenzinger
 23  
  */
 24  
 public class Write6Cdb extends WriteCdb {
 25  
 
 26  
     public Write6Cdb (ByteBuffer buffer) {
 27  0
         super(buffer);
 28  0
     }
 29  
 
 30  
     @Override
 31  
     protected long deserializeLogicalBlockAddress (ByteBuffer buffer) {
 32  
         // the first three bits of byte 1 are reserved, i.e. must be 0,
 33  
         // check that
 34  0
         final byte b = buffer.get(1);
 35  0
         if (((b >> 5) & 7) != 0) addIllegalFieldPointer(1);
 36  
 
 37  
         // read the field's value
 38  0
         return ((b & 31) << 16) | ReadWrite.readTwoByteInt(buffer, 2);
 39  
     }
 40  
 
 41  
     @Override
 42  
     protected int deserializeTransferLength (ByteBuffer buffer) {
 43  
         /*
 44  
          * A TRANSFER LENGTH field set to zero specifies that 256 logical blocks shall be written. Any other value
 45  
          * specifies the number of logical blocks that shall be written.
 46  
          */
 47  0
         final int value = ReadWrite.readOneByteInt(buffer, 4);
 48  0
         if (value == 0) return 256;
 49  0
         return value;
 50  
     }
 51  
 
 52  
     @Override
 53  
     protected int getLogicalBlockAddressFieldIndex () {
 54  0
         return 1;
 55  
     }
 56  
 
 57  
     @Override
 58  
     protected int getTransferLengthFieldIndex () {
 59  0
         return 4;
 60  
     }
 61  
 
 62  
 }