本文整理汇总了C++中MHVTL_DBG函数的典型用法代码示例。如果您正苦于以下问题:C++ MHVTL_DBG函数的具体用法?C++ MHVTL_DBG怎么用?C++ MHVTL_DBG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MHVTL_DBG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: skip_to_next_header
static int skip_to_next_header(uint8_t *sam_stat)
{
MHVTL_DBG(1, "skip_to_next_header");
if (raw_pos.hdr.blk_type == B_EOD) {
sam_blank_check(E_END_OF_DATA, sam_stat);
MHVTL_DBG(1, "End of data detected while forward SPACEing!!");
return -1;
}
if (raw_pos.next_blk != lseek64(datafile, raw_pos.next_blk, SEEK_SET)) {
sam_medium_error(E_SEQUENTIAL_POSITION_ERR, sam_stat);
MHVTL_DBG(1, "Unable to seek to next block header");
return -1;
}
if (read_header(&raw_pos, sam_stat)) {
sam_medium_error(E_SEQUENTIAL_POSITION_ERR, sam_stat);
MHVTL_DBG(1, "Unable to read next block header");
return -1;
}
/* Position to start of header (rewind over header) */
if (raw_pos.curr_blk != position_to_curr_header(sam_stat)) {
sam_medium_error(E_SEQUENTIAL_POSITION_ERR, sam_stat);
MHVTL_DBG(1, "Error position in datafile. Offset: %" PRId64,
raw_pos.curr_blk);
return -1;
}
return 0;
}
示例2: position_to_block
int position_to_block(uint32_t blk_number, uint8_t *sam_stat)
{
if (!tape_loaded(sam_stat))
return -1;
MHVTL_DBG(2, "Position to block %d", blk_number);
if (mam.MediumType == MEDIA_TYPE_WORM)
OK_to_write = 0;
if (blk_number > eod_blk_number) {
sam_blank_check(E_END_OF_DATA, sam_stat);
MHVTL_DBG(1, "End of data detected while positioning");
return position_to_eod(sam_stat);
}
/* Treat a position to block zero specially, as it has different
semantics than other blocks when the tape is WORM.
*/
if (blk_number == 0)
return rewind_tape(sam_stat);
else
return read_header(blk_number, sam_stat);
}
示例3: ssc_write_attributes
uint8_t ssc_write_attributes(struct scsi_cmd *cmd)
{
int sz;
struct priv_lu_ssc *lu_priv;
uint8_t *sam_stat;
lu_priv = cmd->lu->lu_private;
sam_stat = &cmd->dbuf_p->sam_stat;
MHVTL_DBG(1, "Write Attributes (%ld) **", (long)cmd->dbuf_p->serialNo);
switch (lu_priv->tapeLoaded) {
case TAPE_UNLOADED:
mkSenseBuf(NOT_READY, E_MEDIUM_NOT_PRESENT, sam_stat);
return SAM_STAT_CHECK_CONDITION;
break;
case TAPE_LOADED:
cmd->dbuf_p->sz = get_unaligned_be32(&cmd->scb[10]);
sz = retrieve_CDB_data(cmd->cdev, cmd->dbuf_p);
MHVTL_DBG(1, " --> Expected to read %d bytes"
", read %d", cmd->dbuf_p->sz, sz);
if (resp_write_attribute(cmd) > 0)
rewriteMAM(sam_stat);
break;
default:
mkSenseBuf(NOT_READY, E_MEDIUM_FMT_CORRUPT, sam_stat);
return SAM_STAT_CHECK_CONDITION;
break;
}
return SAM_STAT_GOOD;
}
示例4: ssc_report_density_support
uint8_t ssc_report_density_support(struct scsi_cmd *cmd)
{
struct priv_lu_ssc *lu_priv;
uint8_t *sam_stat;
uint8_t media;
lu_priv = cmd->lu->lu_private;
sam_stat = &cmd->dbuf_p->sam_stat;
media = cmd->scb[1] & 0x01;
cmd->dbuf_p->sz = 0;
MHVTL_DBG(1, "Report %s Density Support (%ld) **",
(media) ? "mounted Media" : "Drive",
(long)cmd->dbuf_p->serialNo);
if (cmd->scb[1] & 0x02) { /* Don't support Medium Type (yet) */
MHVTL_DBG(1, "Medium Type - not currently supported");
mkSenseBuf(ILLEGAL_REQUEST, E_INVALID_FIELD_IN_CDB, sam_stat);
return SAM_STAT_CHECK_CONDITION;
}
if (media == 1 && lu_priv->tapeLoaded != TAPE_LOADED) {
MHVTL_DBG(1, "Media has to be mounted to return media density");
mkSenseBuf(NOT_READY, E_MEDIUM_NOT_PRESENT, sam_stat);
return SAM_STAT_CHECK_CONDITION;
}
cmd->dbuf_p->sz = get_unaligned_be16(&cmd->scb[7]);
cmd->dbuf_p->sz = resp_report_density(lu_priv, media, cmd->dbuf_p);
return SAM_STAT_GOOD;
}
示例5: ssc_allow_overwrite
uint8_t ssc_allow_overwrite(struct scsi_cmd *cmd)
{
uint8_t *cdb = cmd->scb;
uint8_t allow_overwrite = cdb[2] & 0x0f;
uint8_t partition = cdb[3];
uint8_t *sam_stat = &cmd->dbuf_p->sam_stat;
uint8_t ret_stat = SAM_STAT_GOOD;
uint64_t allow_overwrite_block;
struct priv_lu_ssc *lu_ssc;
lu_ssc = cmd->lu->lu_private;
if (allow_overwrite > 2) /* Truncate bad values 3 to 15 -> '3' */
allow_overwrite = 3;
MHVTL_DBG(1, "ALLOW OVERWRITE (%ld) : %s **",
(long)cmd->dbuf_p->serialNo,
allow_overwrite_desc[allow_overwrite].desc);
lu_ssc->allow_overwrite = FALSE;
switch (allow_overwrite) {
case 0:
break;
case 1: /* current position */
if (partition) { /* Paritions not supported at this stage */
MHVTL_LOG("Partitions not implemented at this time");
mkSenseBuf(ILLEGAL_REQUEST,
E_INVALID_FIELD_IN_CDB,
sam_stat);
return SAM_STAT_CHECK_CONDITION;
}
allow_overwrite_block = get_unaligned_be64(&cdb[4]);
MHVTL_DBG(1, "Allow overwrite block: %lld",
(long long)allow_overwrite_block);
if (allow_overwrite_block == current_tape_block()) {
lu_ssc->allow_overwrite_block = allow_overwrite_block;
lu_ssc->allow_overwrite = TRUE;
} else {
/* Set allow_overwrite position to an invalid number */
lu_ssc->allow_overwrite_block = 0;
lu_ssc->allow_overwrite_block--;
mkSenseBuf(ILLEGAL_REQUEST,
E_SEQUENTIAL_POSITIONING_ERROR,
sam_stat);
ret_stat = SAM_STAT_CHECK_CONDITION;
}
break;
case 2:
lu_ssc->allow_overwrite = 2;
break;
default:
mkSenseBuf(ILLEGAL_REQUEST, E_INVALID_FIELD_IN_CDB, sam_stat);
ret_stat = SAM_STAT_CHECK_CONDITION;
break;
}
return ret_stat;
}
示例6: rewind_tape
/*
* Rewind to beginning of data file and the position to first data header.
*
* Return 0 -> Not loaded.
* 1 -> Load OK
* 2 -> format corrupt.
*/
int rewind_tape(uint8_t *sam_stat)
{
MHVTL_DBG(1, "rewind_tape");
if (rawRewind(sam_stat)) {
sam_medium_error(E_MEDIUM_FMT_CORRUPT, sam_stat);
return 2;
}
if (raw_pos.hdr.blk_type != B_BOT) {
sam_medium_error(E_MEDIUM_FMT_CORRUPT, sam_stat);
return 2;
}
if (skip_to_next_header(sam_stat))
return 2;
switch (MediumType) {
case MEDIA_TYPE_CLEAN:
OK_to_write = 0;
break;
case MEDIA_TYPE_WORM:
/* Special condition...
* If we
* - rewind,
* - write filemark
* - EOD
* We set this as writable media as the tape is blank.
*/
if (raw_pos.hdr.blk_type != B_EOD)
OK_to_write = 0;
/* Check that this header is a filemark and the next header
* is End of Data. If it is, we are OK to write
*/
if (raw_pos.hdr.blk_type == B_FILEMARK) {
skip_to_next_header(sam_stat);
if (raw_pos.hdr.blk_type == B_EOD)
OK_to_write = 1;
}
/* Now we have to go thru thru the rewind again.. */
if (rawRewind(sam_stat)) {
sam_medium_error(E_MEDIUM_FMT_CORRUPT,
sam_stat);
return 2;
}
/* No need to do all previous error checking... */
skip_to_next_header(sam_stat);
break;
case MEDIA_TYPE_DATA:
OK_to_write = 1; /* Reset flag to OK. */
break;
}
MHVTL_DBG(1, "Media is %s",
(OK_to_write) ? "writable" : "not writable");
return 1;
}
示例7: init_ult_mode_pages
/*
* Initialise structure data for mode pages.
* - Allocate memory for each mode page & init to 0
* - Set up size of mode page
* - Set initial values of mode pages
*
* Return void - Nothing
*/
static void init_ult_mode_pages(struct lu_phy_attr *lu, struct mode *m)
{
struct mode *mp;
MHVTL_DBG(3, "+++ Trace mode pages at %p +++", sm);
mp = alloc_mode_page(m, 0x24, 0, 6);
MHVTL_DBG(3, "smp: %p", mp);
}
示例8: position_blocks_forw
int
position_blocks_forw(uint32_t count, uint8_t *sam_stat)
{
uint32_t residual;
uint32_t blk_target;
unsigned int i;
if (!tape_loaded(sam_stat)) {
return -1;
}
if (mam.MediumType == MEDIA_TYPE_WORM)
OK_to_write = 0;
blk_target = raw_pos.hdr.blk_number + count;
/* Find the first filemark forward from our current position, if any. */
for (i = 0; i < meta.filemark_count; i++) {
MHVTL_DBG(3, "filemark at %ld", (unsigned long)filemarks[i]);
if (filemarks[i] >= raw_pos.hdr.blk_number) {
break;
}
}
/* If there is one, see if it is between our current position and our
desired destination.
*/
if (i < meta.filemark_count) {
if (filemarks[i] >= blk_target) {
return position_to_block(blk_target, sam_stat);
}
residual = blk_target - raw_pos.hdr.blk_number + 1;
if (read_header(filemarks[i] + 1, sam_stat)) {
return -1;
}
MHVTL_DBG(1, "Filemark encountered: block %d", filemarks[i]);
mkSenseBuf(NO_SENSE | SD_FILEMARK, E_MARK, sam_stat);
put_unaligned_be32(residual, &sense[3]);
return -1;
}
if (blk_target > eod_blk_number) {
residual = blk_target - eod_blk_number;
if (read_header(eod_blk_number, sam_stat)) {
return -1;
}
MHVTL_DBG(1, "EOD encountered");
mkSenseBuf(BLANK_CHECK, E_END_OF_DATA, sam_stat);
put_unaligned_be32(residual, &sense[3]);
return -1;
}
return position_to_block(blk_target, sam_stat);
}
示例9: ssc_write_6
uint8_t ssc_write_6(struct scsi_cmd *cmd)
{
uint8_t *cdb = cmd->scb;
struct vtl_ds *dbuf_p;
struct priv_lu_ssc *lu_ssc;
int count;
int sz;
int k;
int retval = 0;
lu_ssc = cmd->lu->lu_private;
dbuf_p = cmd->dbuf_p;
current_state = MHVTL_STATE_WRITING;
if (cdb[1] & FIXED) { /* If Fixed block writes */
count = get_unaligned_be24(&cdb[2]);
sz = get_unaligned_be24(&modeBlockDescriptor[5]);
MHVTL_DBG(last_cmd == WRITE_6 ? 2 : 1,
"WRITE_6: %d blks of %d bytes (%ld) **",
count,
sz,
(long)dbuf_p->serialNo);
} else { /* else - Variable Block writes */
count = 1;
sz = get_unaligned_be24(&cdb[2]);
MHVTL_DBG(last_cmd == WRITE_6 ? 2 : 1,
"WRITE_6: %d bytes (%ld) **",
sz,
(long)dbuf_p->serialNo);
}
/* FIXME: Should handle this instead of 'check & warn' */
if ((sz * count) > lu_ssc->bufsize)
MHVTL_DBG(1,
"Fatal: bufsize %d, requested write of %d bytes",
lu_ssc->bufsize, sz);
/* Retrieve data from kernel */
dbuf_p->sz = sz * count;
retrieve_CDB_data(cmd->cdev, dbuf_p);
if (!lu_ssc->pm->check_restrictions(cmd))
return SAM_STAT_CHECK_CONDITION;
if (OK_to_write) {
for (k = 0; k < count; k++) {
retval = writeBlock(cmd, sz);
dbuf_p->data += retval;
/* If sam_stat != SAM_STAT_GOOD, return */
if (cmd->dbuf_p->sam_stat)
return cmd->dbuf_p->sam_stat;
}
}
return SAM_STAT_GOOD;
}
示例10: check_for_overwrite
static int
check_for_overwrite(uint8_t *sam_stat)
{
uint32_t blk_number;
uint64_t data_offset;
unsigned int i;
if (raw_pos.hdr.blk_type == B_EOD) {
return 0;
}
MHVTL_DBG(2, "At block %ld", (unsigned long)raw_pos.hdr.blk_number);
/* We aren't at EOD so we are performing a rewrite. Truncate
the data and index files back to the current length.
*/
blk_number = raw_pos.hdr.blk_number;
data_offset = raw_pos.data_offset;
if (ftruncate(indxfile, blk_number * sizeof(raw_pos))) {
mkSenseBuf(MEDIUM_ERROR, E_WRITE_ERROR, sam_stat);
MHVTL_ERR("Index file ftruncate failure, pos: "
"%" PRId64 ": %s",
(uint64_t)blk_number * sizeof(raw_pos),
strerror(errno));
return -1;
}
if (ftruncate(datafile, data_offset)) {
mkSenseBuf(MEDIUM_ERROR, E_WRITE_ERROR, sam_stat);
MHVTL_ERR("Data file ftruncate failure, pos: "
"%" PRId64 ": %s", data_offset,
strerror(errno));
return -1;
}
/* Update the filemark map removing any filemarks which will be
overwritten. Rewrite the filemark map so that the on-disk image
of the map is consistent with the new sizes of the other two files.
*/
for (i = 0; i < meta.filemark_count; i++) {
MHVTL_DBG(2, "filemarks[%d] %d", i, filemarks[i]);
if (filemarks[i] >= blk_number) {
MHVTL_DBG(2, "Setting filemark_count from %d to %d",
meta.filemark_count, i);
meta.filemark_count = i;
return rewrite_meta_file();
}
}
return 0;
}
示例11: ssc_spin
uint8_t ssc_spin(struct scsi_cmd *cmd)
{
MHVTL_DBG(1, "Security Protocol In (%ld) **",
(long)cmd->dbuf_p->serialNo);
return resp_spin(cmd);
}
示例12: add_mode_transport_geometry
/*
* Transport Geometry Parameters mode page
* SMC-3 7.3.4
*/
int add_mode_transport_geometry(struct lu_phy_attr *lu)
{
struct list_head *mode_pg;
struct mode *mp;
uint8_t pcode;
uint8_t subpcode;
uint8_t size;
mode_pg = &lu->mode_pg;
pcode = MODE_TRANSPORT_GEOMETRY;
subpcode = 0;
size = 4;
MHVTL_DBG(3, "Adding mode page %s (%02x/%02x)",
mode_transport_geometry, pcode, subpcode);
mp = alloc_mode_page(mode_pg, pcode, subpcode, size);
if (!mp)
return -ENOMEM;
mp->pcodePointer[0] = pcode;
mp->pcodePointer[1] = size
- sizeof(mp->pcodePointer[0])
- sizeof(mp->pcodePointer[1]);
/* And copy pcode/size into bitmap structure */
mp->pcodePointerBitMap[0] = mp->pcodePointer[0];
mp->pcodePointerBitMap[1] = mp->pcodePointer[1];
mp->description = mode_transport_geometry;
return 0;
}
示例13: add_mode_power_condition
int add_mode_power_condition(struct lu_phy_attr *lu)
{
struct list_head *mode_pg;
struct mode *mp;
uint8_t pcode;
uint8_t subpcode;
uint8_t size;
mode_pg = &lu->mode_pg;
pcode = MODE_POWER_CONDITION;
subpcode = 0;
size = 0x26;
MHVTL_DBG(3, "Adding mode page %s (%02x/%02x)",
mode_power_condition, pcode, subpcode);
mp = alloc_mode_page(mode_pg, pcode, subpcode, size);
if (!mp)
return -ENOMEM;
mp->pcodePointer[0] = pcode;
mp->pcodePointer[1] = size
- sizeof(mp->pcodePointer[0])
- sizeof(mp->pcodePointer[1]);
/* And copy pcode/size into bitmap structure */
mp->pcodePointerBitMap[0] = mp->pcodePointer[0];
mp->pcodePointerBitMap[1] = mp->pcodePointer[1];
mp->description = mode_power_condition;
return 0;
}
示例14: ssc_erase
uint8_t ssc_erase(struct scsi_cmd *cmd)
{
struct priv_lu_ssc *lu_priv;
uint8_t *sam_stat;
lu_priv = cmd->lu->lu_private;
sam_stat = &cmd->dbuf_p->sam_stat;
MHVTL_DBG(1, "Erasing (%ld) **", (long)cmd->dbuf_p->serialNo);
current_state = MHVTL_STATE_ERASE;
if (!lu_priv->pm->check_restrictions(cmd))
return SAM_STAT_CHECK_CONDITION;
if (c_pos->blk_number != 0) {
MHVTL_LOG("Not at BOT.. Can't erase unless at BOT");
mkSenseBuf(NOT_READY, E_INVALID_FIELD_IN_CDB, sam_stat);
return SAM_STAT_CHECK_CONDITION;
}
if (OK_to_write)
format_tape(sam_stat);
else {
MHVTL_LOG("Attempt to erase Write-protected media");
mkSenseBuf(NOT_READY, E_MEDIUM_OVERWRITE_ATTEMPTED, sam_stat);
return SAM_STAT_CHECK_CONDITION;
}
return SAM_STAT_GOOD;
}
示例15: ssc_read_media_sn
uint8_t ssc_read_media_sn(struct scsi_cmd *cmd)
{
struct priv_lu_ssc *lu_priv;
uint8_t *sam_stat;
lu_priv = cmd->lu->lu_private;
sam_stat = &cmd->dbuf_p->sam_stat;
MHVTL_DBG(1, "Read Medium Serial No. (%ld) **",
(long)cmd->dbuf_p->serialNo);
switch (lu_priv->tapeLoaded) {
case TAPE_LOADED:
cmd->dbuf_p->sz = resp_read_media_serial(lu_priv->mediaSerialNo,
cmd->dbuf_p->data,
sam_stat);
break;
case TAPE_UNLOADED:
mkSenseBuf(NOT_READY, E_MEDIUM_NOT_PRESENT, sam_stat);
return SAM_STAT_CHECK_CONDITION;
break;
default:
mkSenseBuf(NOT_READY, E_MEDIUM_FMT_CORRUPT, sam_stat);
return SAM_STAT_CHECK_CONDITION;
break;
}
return *sam_stat;
}