static inline ssize_t write_data_to_block(DEV_BLOCK *block, const DEV_RECORD *rec) { uint32_t len; len = MIN(rec->remainder, block_write_navail(block)); memcpy(block->bufp, ((unsigned char *)rec->data) + (rec->data_len - rec->remainder), len); block->bufp += len; block->binbuf += len; #ifdef xxxxxSMCHECK if (!sm_check_rtn(__FILE__, __LINE__, False)) { /* * We damaged a buffer */ Dmsg7(0, "Damaged block FI=%s SessId=%d Strm=%s datalen=%d\n" "len=%d rem=%d remainder=%d\n", FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId, stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len, len, block_write_navail(block), rec->remainder); Dmsg5(0, "Damaged block: bufp=%x binbuf=%d buf_len=%d rem=%d moved=%d\n", block->bufp, block->binbuf, block->buf_len, block_write_navail(block), len); Dmsg2(0, "Damaged block: buf=%x binbuffrombuf=%d \n", block->buf, block->bufp-block->buf); Emsg0(M_ABORT, 0, _("Damaged buffer\n")); } #endif return len; }
/* SM_CHECK -- Check the buffers and dump if any damage exists. */ void sm_check(const char *fname, int lineno, bool bufdump) { if (!sm_check_rtn(fname, lineno, bufdump)) { smart_alloc_msg(__FILE__, __LINE__, _("Damaged buffer found. Called from %s:%d\n"), get_basename(fname), (uint32_t)lineno); } }
/* SM_CHECK -- Check the buffers and dump if any damage exists. */ void sm_check(const char *fname, int lineno, bool bufdump) { if (!sm_check_rtn(fname, lineno, bufdump)) { Emsg2(M_ABORT, 0, _("Damaged buffer found. Called from %s:%d\n"), get_basename(fname), (uint32_t)lineno); } }
static inline bool write_data_to_block(DEV_BLOCK *block, DEV_RECORD *rec) { rec->remlen = block->buf_len - block->binbuf; /* * Write as much of data as possible */ if (rec->remlen >= rec->remainder) { memcpy(block->bufp, rec->data + (rec->data_len - rec->remainder), rec->remainder); block->bufp += rec->remainder; block->binbuf += rec->remainder; } else { memcpy(block->bufp, rec->data + (rec->data_len - rec->remainder), rec->remlen); #ifdef xxxxxSMCHECK if (!sm_check_rtn(__FILE__, __LINE__, False)) { /* * We damaged a buffer */ Dmsg6(0, "Damaged block FI=%s SessId=%d Strm=%s len=%d\n" "rem=%d remainder=%d\n", FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId, stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len, rec->remlen, rec->remainder); Dmsg5(0, "Damaged block: bufp=%x binbuf=%d buf_len=%d rem=%d moved=%d\n", block->bufp, block->binbuf, block->buf_len, block->buf_len-block->binbuf, rec->remlen); Dmsg2(0, "Damaged block: buf=%x binbuffrombuf=%d \n", block->buf, block->bufp-block->buf); Emsg0(M_ABORT, 0, _("Damaged buffer\n")); } #endif block->bufp += rec->remlen; block->binbuf += rec->remlen; rec->remainder -= rec->remlen; return false; /* did partial transfer */ } return true; }