This also set the information field in sense to the remaining length. ssc_sense_data_build() is added to set up the information field. It would be better to replace sense_data_build with this. TODO: support descriptor format Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx> --- usr/bs_ssc.c | 23 +++++++++++++++++++++-- usr/ssc.c | 3 +++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/usr/bs_ssc.c b/usr/bs_ssc.c index a685673..bb5907a 100644 --- a/usr/bs_ssc.c +++ b/usr/bs_ssc.c @@ -39,6 +39,18 @@ #include "bs_ssc.h" #include "ssc.h" +static void ssc_sense_data_build(struct scsi_cmd *cmd, uint8_t key, + uint16_t asc, uint8_t *info, int info_len) +{ + /* TODO: support descriptor format */ + + sense_data_build(cmd, key, asc); + if (info_len) { + memcpy(cmd->sense_buffer + 2, info, 4); + cmd->sense_buffer[0] |= 0x80; + } +} + static inline uint32_t ssc_get_block_length(struct scsi_lu *lu) { return get_unaligned_be24(lu->mode_block_descriptor + 5); @@ -185,6 +197,8 @@ static int append_blk(struct scsi_cmd *cmd, uint8_t *data, } /* Write new EOD blk header */ + fsync(fd); + free(curr); return SAM_STAT_GOOD; @@ -193,6 +207,8 @@ failed_write: return SAM_STAT_CHECK_CONDITION; } +#define SENSE_FILEMARK 0x80 + static int prev_filemark(struct scsi_cmd *cmd) { struct ssc_info *ssc = dtype_priv(cmd->dev); @@ -325,9 +341,12 @@ static int resp_fixed_read(struct scsi_cmd *cmd, uint8_t *buf, uint32_t length) for (i = 0; i < count; i++) { if (ssc->c_blk->blk_type == BLK_FILEMARK) { + uint8_t info[4]; + eprintf("Oops - found filemark\n"); - sense_data_build(cmd, NO_SENSE, ASC_MARK); -/* FIXME: Need to update sense buffer with remaining byte count. */ + put_unaligned_be32(count - i, info); + ssc_sense_data_build(cmd, NO_SENSE | SENSE_FILEMARK, + ASC_MARK, info, sizeof(info)); goto rd_err; } diff --git a/usr/ssc.c b/usr/ssc.c index 2d45eb2..834ec16 100644 --- a/usr/ssc.c +++ b/usr/ssc.c @@ -125,6 +125,9 @@ static int ssc_lu_init(struct scsi_lu *lu) strncpy(lu->attrs.product_id, "VIRTUAL-TAPE", sizeof(lu->attrs.product_id)); + + /* use only fixed for now */ + lu->attrs.sense_format = 0; lu->attrs.version_desc[0] = 0x0200; /* SSC no version claimed */ lu->attrs.version_desc[1] = 0x0960; /* iSCSI */ lu->attrs.version_desc[2] = 0x0300; /* SPC-3 */ -- 1.5.6.5 -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html