Exemplo n.º 1
0
Arquivo: bls.c Projeto: AlD/bareos
/*
 * We are only looking for labels or in particular Job Session records
 */
static bool jobs_cb(DCR *dcr, DEV_RECORD *rec)
{
   if (rec->FileIndex < 0) {
      dump_label_record(dcr->dev, rec, verbose);
   }
   rec->remainder = 0;
   return true;
}
Exemplo n.º 2
0
/*
 * Called here for each record from read_records()
 */
static bool record_cb(DCR *dcr, DEV_RECORD *rec)
{
    if (verbose && rec->FileIndex < 0) {
        dump_label_record(dcr->dev, rec, verbose);
        return true;
    }
    if (verbose) {
        char buf1[100], buf2[100];
        Pmsg6(000, "Record: FI=%s SessId=%d Strm=%s len=%u remlen=%d data_len=%d\n",
              FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
              stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_bytes, rec->remlen,
              rec->data_len);
    }

    /* File Attributes stream */
    if (rec->maskedStream == STREAM_UNIX_ATTRIBUTES ||
            rec->maskedStream == STREAM_UNIX_ATTRIBUTES_EX) {
        if (!unpack_attributes_record(jcr, rec->Stream, rec->data, rec->data_len, attr)) {
            if (!forge_on) {
                Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n"));
            } else {
                Emsg0(M_ERROR, 0, _("Attrib unpack error!\n"));
            }
            num_files++;
            return true;
        }

        attr->data_stream = decode_stat(attr->attr, &attr->statp, sizeof(attr->statp), &attr->LinkFI);
        build_attr_output_fnames(jcr, attr);

        if (file_is_included(ff, attr->fname) && !file_is_excluded(ff, attr->fname)) {
            if (verbose) {
                Pmsg5(000, _("FileIndex=%d VolSessionId=%d VolSessionTime=%d Stream=%d DataLen=%d\n"),
                      rec->FileIndex, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len);
            }
            print_ls_output(jcr, attr);
            num_files++;
        }
    } else if (rec->Stream == STREAM_PLUGIN_NAME) {
        char data[100];
        int len = MIN(rec->data_len+1, sizeof(data));
        bstrncpy(data, rec->data, len);
        Dmsg1(100, "Plugin data: %s\n", data);
    } else if (rec->Stream == STREAM_RESTORE_OBJECT) {
        Dmsg0(100, "Restore Object record\n");
    }

    return true;
}
Exemplo n.º 3
0
/*
 * read_records() calls back here for each record it gets
 */
static bool record_cb(DCR *in_dcr, DEV_RECORD *rec)
{
   if (list_records) {
      Pmsg5(000, _("Record: SessId=%u SessTim=%u FileIndex=%d Stream=%d len=%u\n"),
            rec->VolSessionId, rec->VolSessionTime, rec->FileIndex,
            rec->Stream, rec->data_len);
   }
   /*
    * Check for Start or End of Session Record
    *
    */
   if (rec->FileIndex < 0) {
      get_session_record(in_dcr->dev, rec, &sessrec);

      if (verbose > 1) {
         dump_label_record(in_dcr->dev, rec, 1);
      }
      switch (rec->FileIndex) {
      case PRE_LABEL:
         Pmsg0(000, _("Volume is prelabeled. This volume cannot be copied.\n"));
         return false;
      case VOL_LABEL:
         Pmsg0(000, _("Volume label not copied.\n"));
         return true;
      case SOS_LABEL:
         if (bsr && rec->match_stat < 1) {
            /* Skipping record, because does not match BSR filter */
            if (verbose) {
             Pmsg0(-1, _("Copy skipped. Record does not match BSR filter.\n"));
            }
         } else {
            jobs++;
         }
         break;
      case EOS_LABEL:
         if (bsr && rec->match_stat < 1) {
            /* Skipping record, because does not match BSR filter */
           return true;
        }
         while (!write_record_to_block(out_block, rec)) {
            Dmsg2(150, "!write_record_to_block data_len=%d rem=%d\n", rec->data_len,
                       rec->remainder);
            if (!write_block_to_device(out_jcr->dcr)) {
               Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
                  out_dev->print_name(), out_dev->bstrerror());
               Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
                     out_dev->bstrerror());
               return false;
            }
         }
         if (!write_block_to_device(out_jcr->dcr)) {
            Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
               out_dev->print_name(), out_dev->bstrerror());
            Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
                  out_dev->bstrerror());
            return false;
         }
         return true;
      case EOM_LABEL:
         Pmsg0(000, _("EOM label not copied.\n"));
         return true;
      case EOT_LABEL:              /* end of all tapes */
         Pmsg0(000, _("EOT label not copied.\n"));
         return true;
      default:
         return true;
      }
   }

   /*  Write record */
   if (bsr && rec->match_stat < 1) {
      /* Skipping record, because does not match BSR filter */
      return true;
   }
   records++;
   while (!write_record_to_block(out_block, rec)) {
      Dmsg2(150, "!write_record_to_block data_len=%d rem=%d\n", rec->data_len,
                 rec->remainder);
      if (!write_block_to_device(out_jcr->dcr)) {
         Dmsg2(90, "Got write_block_to_dev error on device %s: ERR=%s\n",
            out_dev->print_name(), out_dev->bstrerror());
         Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"),
               out_dev->bstrerror());
         return false;
      }
   }
   return true;
}