Skip to content

Commit

Permalink
ssc: REPORT POSITION - Add support for 'long' format
Browse files Browse the repository at this point in the history
  • Loading branch information
markh794 committed Mar 18, 2013
1 parent 53fb9aa commit 8b5618c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
16 changes: 15 additions & 1 deletion usr/ssc.c
Expand Up @@ -1156,10 +1156,24 @@ uint8_t ssc_read_position(struct scsi_cmd *cmd)

switch (lu_priv->tapeLoaded) {
case TAPE_LOADED:
if ((service_action == 0) || (service_action == 1))
switch (service_action) {
case 0:
case 1:
cmd->dbuf_p->sz = resp_read_position(c_pos->blk_number,
cmd->dbuf_p->data,
sam_stat);
break;
case 6:
cmd->dbuf_p->sz =
resp_read_position_long(c_pos->blk_number,
cmd->dbuf_p->data,
sam_stat);
break;
default:
mkSenseBuf(ILLEGAL_REQUEST, E_INVALID_FIELD_IN_CDB,
sam_stat);
return SAM_STAT_CHECK_CONDITION;
}
break;
case TAPE_UNLOADED:
mkSenseBuf(NOT_READY, E_MEDIUM_NOT_PRESENT, sam_stat);
Expand Down
18 changes: 5 additions & 13 deletions usr/vtllib.c
Expand Up @@ -256,17 +256,11 @@ int resp_read_position_long(loff_t pos, uint8_t *buf, uint8_t *sam_stat)
buf[0] = 0x80; /* Begining of Partition */

/* partition should be zero, as we only support one */
buf[4] = (partition >> 24);
buf[5] = (partition >> 16);
buf[6] = (partition >> 8);
buf[7] = partition;
put_unaligned_be32(partition, &buf[4]);

/* we don't know logical field identifier */
/* FIXME: this code is wrong -- pos should be returned in [8 - 15] */
buf[8] = buf[9] = (pos >> 16);
buf[6] = buf[10] = (pos >> 8);
buf[7] = buf[11] = pos;
put_unaligned_be64(pos, &buf[8]);

MHVTL_DBG(1, "Positioned at block %ld", (long)pos);
return READ_POSITION_LONG_LEN;
}

Expand All @@ -279,10 +273,8 @@ int resp_read_position(loff_t pos, uint8_t *buf, uint8_t *sam_stat)
if ((pos == 0) || (pos == 1))
buf[0] = 0x80; /* Begining of Partition */

buf[4] = buf[8] = (pos >> 24);
buf[5] = buf[9] = (pos >> 16);
buf[6] = buf[10] = (pos >> 8);
buf[7] = buf[11] = pos;
put_unaligned_be32(pos, &buf[4]);
put_unaligned_be32(pos, &buf[8]);
MHVTL_DBG(1, "Positioned at block %ld", (long)pos);

return READ_POSITION_LEN;
Expand Down

0 comments on commit 8b5618c

Please sign in to comment.