src/stored/label.c
void create_volume_header(DEVICE *dev, const char *VolName,
                         const char *PoolName, bool no_prelabel)
{
   DEVRES *device = (DEVRES *)dev->device;

   Enter(130);

   ASSERT2(dev != NULL, "dev ptr is NULL");

   if (dev->is_aligned()) {
      bstrncpy(dev->VolHdr.Id, BaculaMetaDataId, sizeof(dev->VolHdr.Id));
      dev->VolHdr.VerNum = BaculaMetaDataVersion;
      dev->VolHdr.FirstData = dev->file_alignment;
      dev->VolHdr.FileAlignment = dev->file_alignment;
      dev->VolHdr.PaddingSize = dev->padding_size;
      dev->VolHdr.BlockSize = dev->adata_size;
   } else if (dev->is_adata()) {
      bstrncpy(dev->VolHdr.Id, BaculaAlignedDataId, sizeof(dev->VolHdr.Id));
      dev->VolHdr.VerNum = BaculaAlignedDataVersion;
      dev->VolHdr.FirstData = dev->file_alignment;
      dev->VolHdr.FileAlignment = dev->file_alignment;
      dev->VolHdr.PaddingSize = dev->padding_size;
      dev->VolHdr.BlockSize = dev->adata_size;
   } else if (dev->is_cloud()) {
      bstrncpy(dev->VolHdr.Id, BaculaS3CloudId, sizeof(dev->VolHdr.Id));
      dev->VolHdr.VerNum = BaculaS3CloudVersion;
      dev->VolHdr.BlockSize = dev->max_block_size;
      dev->VolHdr.MaxPartSize = dev->max_part_size;
   } else {
      bstrncpy(dev->VolHdr.Id, BaculaId, sizeof(dev->VolHdr.Id));
      dev->VolHdr.VerNum = BaculaTapeVersion;
      dev->VolHdr.BlockSize = dev->max_block_size;
   }

   if ((dev->has_cap(CAP_STREAM) && no_prelabel) || dev->is_worm()) {
      /* We do not want to re-label so write VOL_LABEL now */
      dev->VolHdr.LabelType = VOL_LABEL;
   } else {
      dev->VolHdr.LabelType = PRE_LABEL;  /* Mark Volume as unused */
   }
   bstrncpy(dev->VolHdr.VolumeName, VolName, sizeof(dev->VolHdr.VolumeName));
   bstrncpy(dev->VolHdr.PoolName, PoolName, sizeof(dev->VolHdr.PoolName));
   bstrncpy(dev->VolHdr.MediaType, device->media_type, sizeof(dev->VolHdr.MediaType));

   bstrncpy(dev->VolHdr.PoolType, "Backup", sizeof(dev->VolHdr.PoolType));

   dev->VolHdr.label_btime = get_current_btime();
   dev->VolHdr.label_date = 0;
   dev->VolHdr.label_time = 0;

   if (gethostname(dev->VolHdr.HostName, sizeof(dev->VolHdr.HostName)) != 0) {
      dev->VolHdr.HostName[0] = 0;
   }
   bstrncpy(dev->VolHdr.LabelProg, my_name, sizeof(dev->VolHdr.LabelProg));
   sprintf(dev->VolHdr.ProgVersion, "Ver. %s %s ", VERSION, BDATE);
   sprintf(dev->VolHdr.ProgDate, "Build %s %s ", __DATE__, __TIME__);
   dev->set_labeled();               /* set has Bacula label */
   if (chk_dbglvl(100)) {
      dev->dump_volume_label();
   }
}
/*
 * Create a volume header (label) in memory
 *   The volume record is created after this header (label)
 *   is created.
 */
Create a volume header (label) in memory
The volume record is created after this header (label)
is created.
Create a volume header ( label ) in memory The volume record is created after this header ( label ) is created .
void create_volume_header(DEVICE *dev, const char *VolName,
                         const char *PoolName, bool no_prelabel)
{
   DEVRES *device = (DEVRES *)dev->device;
   Enter(130);
   ASSERT2(dev != NULL, "dev ptr is NULL");
   if (dev->is_aligned()) {
      bstrncpy(dev->VolHdr.Id, BaculaMetaDataId, sizeof(dev->VolHdr.Id));
      dev->VolHdr.VerNum = BaculaMetaDataVersion;
      dev->VolHdr.FirstData = dev->file_alignment;
      dev->VolHdr.FileAlignment = dev->file_alignment;
      dev->VolHdr.PaddingSize = dev->padding_size;
      dev->VolHdr.BlockSize = dev->adata_size;
   } else if (dev->is_adata()) {
      bstrncpy(dev->VolHdr.Id, BaculaAlignedDataId, sizeof(dev->VolHdr.Id));
      dev->VolHdr.VerNum = BaculaAlignedDataVersion;
      dev->VolHdr.FirstData = dev->file_alignment;
      dev->VolHdr.FileAlignment = dev->file_alignment;
      dev->VolHdr.PaddingSize = dev->padding_size;
      dev->VolHdr.BlockSize = dev->adata_size;
   } else if (dev->is_cloud()) {
      bstrncpy(dev->VolHdr.Id, BaculaS3CloudId, sizeof(dev->VolHdr.Id));
      dev->VolHdr.VerNum = BaculaS3CloudVersion;
      dev->VolHdr.BlockSize = dev->max_block_size;
      dev->VolHdr.MaxPartSize = dev->max_part_size;
   } else {
      bstrncpy(dev->VolHdr.Id, BaculaId, sizeof(dev->VolHdr.Id));
      dev->VolHdr.VerNum = BaculaTapeVersion;
      dev->VolHdr.BlockSize = dev->max_block_size;
   }
   if ((dev->has_cap(CAP_STREAM) && no_prelabel) || dev->is_worm()) {
      dev->VolHdr.LabelType = VOL_LABEL;
   } else {
      dev->VolHdr.LabelType = PRE_LABEL;  
   }
   bstrncpy(dev->VolHdr.VolumeName, VolName, sizeof(dev->VolHdr.VolumeName));
   bstrncpy(dev->VolHdr.PoolName, PoolName, sizeof(dev->VolHdr.PoolName));
   bstrncpy(dev->VolHdr.MediaType, device->media_type, sizeof(dev->VolHdr.MediaType));
   bstrncpy(dev->VolHdr.PoolType, "Backup", sizeof(dev->VolHdr.PoolType));
   dev->VolHdr.label_btime = get_current_btime();
   dev->VolHdr.label_date = 0;
   dev->VolHdr.label_time = 0;
   if (gethostname(dev->VolHdr.HostName, sizeof(dev->VolHdr.HostName)) != 0) {
      dev->VolHdr.HostName[0] = 0;
   }
   bstrncpy(dev->VolHdr.LabelProg, my_name, sizeof(dev->VolHdr.LabelProg));
   sprintf(dev->VolHdr.ProgVersion, "Ver. %s %s ", VERSION, BDATE);
   sprintf(dev->VolHdr.ProgDate, "Build %s %s ", __DATE__, __TIME__);
   dev->set_labeled();               
   if (chk_dbglvl(100)) {
      dev->dump_volume_label();
   }
}
void create_volume_header ( DEVICE * dev , const char * VolName , const char * PoolName , bool no_prelabel ) { DEVRES * device = ( DEVRES * ) dev -> device ; Enter ( 130 ) ; ASSERT2 ( dev != NULL , " " ) ; if ( dev -> is_aligned ( ) ) { bstrncpy ( dev -> VolHdr . Id , BaculaMetaDataId , sizeof ( dev -> VolHdr . Id ) ) ; dev -> VolHdr . VerNum = BaculaMetaDataVersion ; dev -> VolHdr . FirstData = dev -> file_alignment ; dev -> VolHdr . FileAlignment = dev -> file_alignment ; dev -> VolHdr . PaddingSize = dev -> padding_size ; dev -> VolHdr . BlockSize = dev -> adata_size ; } else if ( dev -> is_adata ( ) ) { bstrncpy ( dev -> VolHdr . Id , BaculaAlignedDataId , sizeof ( dev -> VolHdr . Id ) ) ; dev -> VolHdr . VerNum = BaculaAlignedDataVersion ; dev -> VolHdr . FirstData = dev -> file_alignment ; dev -> VolHdr . FileAlignment = dev -> file_alignment ; dev -> VolHdr . PaddingSize = dev -> padding_size ; dev -> VolHdr . BlockSize = dev -> adata_size ; } else if ( dev -> is_cloud ( ) ) { bstrncpy ( dev -> VolHdr . Id , BaculaS3CloudId , sizeof ( dev -> VolHdr . Id ) ) ; dev -> VolHdr . VerNum = BaculaS3CloudVersion ; dev -> VolHdr . BlockSize = dev -> max_block_size ; dev -> VolHdr . MaxPartSize = dev -> max_part_size ; } else { bstrncpy ( dev -> VolHdr . Id , BaculaId , sizeof ( dev -> VolHdr . Id ) ) ; dev -> VolHdr . VerNum = BaculaTapeVersion ; dev -> VolHdr . BlockSize = dev -> max_block_size ; } if ( ( dev -> has_cap ( CAP_STREAM ) && no_prelabel ) || dev -> is_worm ( ) ) { dev -> VolHdr . LabelType = VOL_LABEL ; } else { dev -> VolHdr . LabelType = PRE_LABEL ; } bstrncpy ( dev -> VolHdr . VolumeName , VolName , sizeof ( dev -> VolHdr . VolumeName ) ) ; bstrncpy ( dev -> VolHdr . PoolName , PoolName , sizeof ( dev -> VolHdr . PoolName ) ) ; bstrncpy ( dev -> VolHdr . MediaType , device -> media_type , sizeof ( dev -> VolHdr . MediaType ) ) ; bstrncpy ( dev -> VolHdr . PoolType , " " , sizeof ( dev -> VolHdr . PoolType ) ) ; dev -> VolHdr . label_btime = get_current_btime ( ) ; dev -> VolHdr . label_date = 0 ; dev -> VolHdr . label_time = 0 ; if ( gethostname ( dev -> VolHdr . HostName , sizeof ( dev -> VolHdr . HostName ) ) != 0 ) { dev -> VolHdr . HostName [ 0 ] = 0 ; } bstrncpy ( dev -> VolHdr . LabelProg , my_name , sizeof ( dev -> VolHdr . LabelProg ) ) ; sprintf ( dev -> VolHdr . ProgVersion , " " , VERSION , BDATE ) ; sprintf ( dev -> VolHdr . ProgDate , " " , __DATE__ , __TIME__ ) ; dev -> set_labeled ( ) ; if ( chk_dbglvl ( 100 ) ) { dev -> dump_volume_label ( ) ; } }
Create a volume header (label) in memory
   The volume record is created after this header (label)
   is created.
Create a volume header ( label ) in memory The volume record is created after this header ( label ) is created .
/* We do not want to re-label so write VOL_LABEL now */ /* Mark Volume as unused */ /* set has Bacula label */