Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 333031
b: refs/heads/master
c: 7a3f369
h: refs/heads/master
i:
  333029: c2fe3d2
  333027: a532bb4
  333023: b983b25
v: v3
  • Loading branch information
Paolo Bonzini authored and Nicholas Bellinger committed Sep 18, 2012
1 parent b89c792 commit d1c995a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ffe7b0e9326d9c68f5688bef691dd49f1e0d3651
refs/heads/master: 7a3f369ce31694017996524a1cdb08208a839077
17 changes: 7 additions & 10 deletions trunk/drivers/target/target_core_spc.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ static int spc_emulate_modesense(struct se_cmd *cmd)
unsigned char *rbuf;
int type = dev->transport->get_device_type(dev);
int ten = (cmd->t_task_cdb[0] == MODE_SENSE_10);
int offset = ten ? 8 : 4;
u32 offset = ten ? 8 : 4;
int length = 0;
unsigned char buf[SE_MODE_PAGE_BUF];

Expand Down Expand Up @@ -817,6 +817,7 @@ static int spc_emulate_modesense(struct se_cmd *cmd)
offset -= 2;
buf[0] = (offset >> 8) & 0xff;
buf[1] = offset & 0xff;
offset += 2;

if ((cmd->se_lun->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY) ||
(cmd->se_deve &&
Expand All @@ -826,13 +827,10 @@ static int spc_emulate_modesense(struct se_cmd *cmd)
if ((dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0) &&
(dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0))
spc_modesense_dpofua(&buf[3], type);

if ((offset + 2) > cmd->data_length)
offset = cmd->data_length;

} else {
offset -= 1;
buf[0] = offset & 0xff;
offset += 1;

if ((cmd->se_lun->lun_access & TRANSPORT_LUNFLAGS_READ_ONLY) ||
(cmd->se_deve &&
Expand All @@ -842,14 +840,13 @@ static int spc_emulate_modesense(struct se_cmd *cmd)
if ((dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0) &&
(dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0))
spc_modesense_dpofua(&buf[2], type);

if ((offset + 1) > cmd->data_length)
offset = cmd->data_length;
}

rbuf = transport_kmap_data_sg(cmd);
memcpy(rbuf, buf, offset);
transport_kunmap_data_sg(cmd);
if (rbuf) {
memcpy(rbuf, buf, min(offset, cmd->data_length));
transport_kunmap_data_sg(cmd);
}

target_complete_cmd(cmd, GOOD);
return 0;
Expand Down

0 comments on commit d1c995a

Please sign in to comment.