src/stored/label.c
bool write_session_label(DCR *dcr, int label)
{
   JCR *jcr = dcr->jcr;
   DEVICE *dev = dcr->dev;
   DEV_RECORD *rec;
   DEV_BLOCK *block = dcr->block;
   char buf1[100], buf2[100];

   Enter(100);
   dev->Lock();
   Dmsg2(140, "=== write_session_label label=%d Vol=%s.\n", label, dev->getVolCatName());
   if (!check_for_newvol_or_newfile(dcr)) {
      Pmsg0(000, "ERR: !check_for_new_vol_or_newfile\n");
      dev->Unlock();
      return false;
   }

   rec = new_record();
   Dmsg1(130, "session_label record=%x\n", rec);
   switch (label) {
   case SOS_LABEL:
      set_start_vol_position(dcr);
      break;
   case EOS_LABEL:
      dcr->EndAddr = dev->get_full_addr();
      break;
   default:
      Jmsg1(jcr, M_ABORT, 0, _("Bad Volume session label request=%d\n"), label);
      break;
   }

   create_session_label(dcr, rec, label);
   rec->FileIndex = label;
   dev->Unlock();

   /*
    * We guarantee that the session record can totally fit
    *  into a block. If not, write the block, and put it in
    *  the next block. Having the sesssion record totally in
    *  one block makes reading them much easier (no need to
    *  read the next block).
    */
   if (!can_write_record_to_block(block, rec)) {
      Dmsg0(150, "Cannot write session label to block.\n");
      if (!dcr->write_block_to_device()) {
         Dmsg0(130, "Got session label write_block_to_dev error.\n");
         free_record(rec);
         Leave(100);
         return false;
      }
   }
   /*
    * We use write_record() because it handles the case that
    *  the maximum user size has been reached.
    */
   if (!dcr->write_record(rec)) {
      Dmsg0(150, "Bad return from write_record\n");
      free_record(rec);
      Leave(100);
      return false;
   }

   Dmsg6(150, "Write sesson_label record JobId=%d FI=%s SessId=%d Strm=%s len=%d "
             "remainder=%d\n", jcr->JobId,
      FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
      stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len,
      rec->remainder);

   free_record(rec);
   Dmsg2(150, "Leave write_session_label Block=%u File=%u\n",
      dev->get_block_num(), dev->get_file());
   Leave(100);
   return true;
}
/* Write session (Job) label
 *  Returns: false on failure
 *           true  on success
 */
Write session (Job) label
Returns: false on failure
true  on success
Write session ( Job ) label Returns : false on failure true on success
bool write_session_label(DCR *dcr, int label)
{
   JCR *jcr = dcr->jcr;
   DEVICE *dev = dcr->dev;
   DEV_RECORD *rec;
   DEV_BLOCK *block = dcr->block;
   char buf1[100], buf2[100];
   Enter(100);
   dev->Lock();
   Dmsg2(140, "=== write_session_label label=%d Vol=%s.\n", label, dev->getVolCatName());
   if (!check_for_newvol_or_newfile(dcr)) {
      Pmsg0(000, "ERR: !check_for_new_vol_or_newfile\n");
      dev->Unlock();
      return false;
   }
   rec = new_record();
   Dmsg1(130, "session_label record=%x\n", rec);
   switch (label) {
   case SOS_LABEL:
      set_start_vol_position(dcr);
      break;
   case EOS_LABEL:
      dcr->EndAddr = dev->get_full_addr();
      break;
   default:
      Jmsg1(jcr, M_ABORT, 0, _("Bad Volume session label request=%d\n"), label);
      break;
   }
   create_session_label(dcr, rec, label);
   rec->FileIndex = label;
   dev->Unlock();
   if (!can_write_record_to_block(block, rec)) {
      Dmsg0(150, "Cannot write session label to block.\n");
      if (!dcr->write_block_to_device()) {
         Dmsg0(130, "Got session label write_block_to_dev error.\n");
         free_record(rec);
         Leave(100);
         return false;
      }
   }
   if (!dcr->write_record(rec)) {
      Dmsg0(150, "Bad return from write_record\n");
      free_record(rec);
      Leave(100);
      return false;
   }
   Dmsg6(150, "Write sesson_label record JobId=%d FI=%s SessId=%d Strm=%s len=%d "
             "remainder=%d\n", jcr->JobId,
      FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
      stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len,
      rec->remainder);
   free_record(rec);
   Dmsg2(150, "Leave write_session_label Block=%u File=%u\n",
      dev->get_block_num(), dev->get_file());
   Leave(100);
   return true;
}
bool write_session_label ( DCR * dcr , int label ) { JCR * jcr = dcr -> jcr ; DEVICE * dev = dcr -> dev ; DEV_RECORD * rec ; DEV_BLOCK * block = dcr -> block ; char buf1 [ 100 ] , buf2 [ 100 ] ; Enter ( 100 ) ; dev -> Lock ( ) ; Dmsg2 ( 140 , " \n " , label , dev -> getVolCatName ( ) ) ; if ( ! check_for_newvol_or_newfile ( dcr ) ) { Pmsg0 ( 000 , " \n " ) ; dev -> Unlock ( ) ; return false ; } rec = new_record ( ) ; Dmsg1 ( 130 , " \n " , rec ) ; switch ( label ) { case SOS_LABEL : set_start_vol_position ( dcr ) ; break ; case EOS_LABEL : dcr -> EndAddr = dev -> get_full_addr ( ) ; break ; default : Jmsg1 ( jcr , M_ABORT , 0 , _ ( " \n " ) , label ) ; break ; } create_session_label ( dcr , rec , label ) ; rec -> FileIndex = label ; dev -> Unlock ( ) ; if ( ! can_write_record_to_block ( block , rec ) ) { Dmsg0 ( 150 , " \n " ) ; if ( ! dcr -> write_block_to_device ( ) ) { Dmsg0 ( 130 , " \n " ) ; free_record ( rec ) ; Leave ( 100 ) ; return false ; } } if ( ! dcr -> write_record ( rec ) ) { Dmsg0 ( 150 , " \n " ) ; free_record ( rec ) ; Leave ( 100 ) ; return false ; } Dmsg6 ( 150 , " " " \n " , jcr -> JobId , FI_to_ascii ( buf1 , rec -> FileIndex ) , rec -> VolSessionId , stream_to_ascii ( buf2 , rec -> Stream , rec -> FileIndex ) , rec -> data_len , rec -> remainder ) ; free_record ( rec ) ; Dmsg2 ( 150 , " \n " , dev -> get_block_num ( ) , dev -> get_file ( ) ) ; Leave ( 100 ) ; return true ; }
Write session (Job) label
  Returns: false on failure
           true  on success
Write session ( Job ) label Returns : false on failure true on success
/*
    * We guarantee that the session record can totally fit
    *  into a block. If not, write the block, and put it in
    *  the next block. Having the sesssion record totally in
    *  one block makes reading them much easier (no need to
    *  read the next block).
    */ /*
    * We use write_record() because it handles the case that
    *  the maximum user size has been reached.
    */