Logo Search packages:      
Sourcecode: aimage version File versions  Download package

int imager::start_imaging (  )

Flag happens between here

Definition at line 730 of file imager.cpp.

{
    output_ident = new class ident(outfile);

    /* If the user is imaging to an AFF file,
     * open it and try to ident the drive.
     * Drive ident is not done if writing to a raw file, because
     * there is no place to store the ident information. This will be changed
     * when we can write an XML log.
     */
    af->tag = (void *)this;               // remember me!

    /* If the segment size hasn't been set, then set it */

    /** Flag happens between here */

    if(opt_append){
      /* Make sure that the AFF file is for this drive, and set it up */
    }
    else {

      ident();                // ident the drive if possible
      af_update_seg(af,AF_ACQUISITION_COMMAND_LINE,0,(const u_char *)command_line,strlen(command_line));
      af_update_seg(af,AF_ACQUISITION_DEVICE,0,(const u_char *)infile,strlen(infile));

      af_set_sectorsize(af,sector_size);
      af_set_pagesize(af,opt_pagesize);   // sets current page size
      if(opt_maxsize){
          if(af_set_maxsize(af,opt_maxsize)){
            exit(-1);
          }
      }

      if(total_sectors>0){
          af_update_segq(af,AF_DEVICE_SECTORS,(int64)total_sectors);
      }
      if(opt_no_ifconfig==0){
          char *macs = ident::mac_addresses();
          if(macs){
            af_update_seg(af,AF_ACQUISITION_MACADDR,0,(const u_char *)macs,strlen(macs));
            free(macs);
          }
      }

      if(opt_no_dmesg==0){
          char *dmesg = ident::dmesg();
          if(dmesg && strlen(dmesg)){
            af_update_seg(af,AF_ACQUISITION_DMESG,0,(const u_char *)dmesg,strlen(dmesg));
            free(dmesg);
          }
      }
      af_make_gid(af);
    }
    af_set_callback(af,segwrite_callback);
    af_set_acquisition_date(af,time(0));

    /* Here is where the imaging takes place.
     * Do it unless ifd==FD_IDENT, which is the fictitious FD.
     */

    if(logfile){
      fprintf(logfile,"aimage infile=%s ",infile);
      fprintf(logfile,"outfile_aff=%s ",outfile);
      fprintf(logfile,"\n");
    }
    if(in!=FD_IDENT){
      imaging_timer.start();
      if(opt_recover_scan){
          start_recover_scan();
      }
      else{
          start_imaging2();
      }
      imaging_timer.stop();
    }


    /* AFF Cleanup... */
    if(af){
      if(hash_invalid==false){
          if(af_update_seg(af,AF_MD5,0,md5.final(),md5.SIZE)){
            if(errno!=ENOTSUP) perror("Could not update AF_MD5");
          }
          if(af_update_seg(af,AF_SHA1,0,sha1.final(),sha1.SIZE)){
            if(errno!=ENOTSUP) perror("Could not update AF_SHA1");
          }
          if(af_update_seg(af,AF_SHA256,0,sha256.final(),sha256.SIZE)){
            if(errno!=ENOTSUP) perror("Could not update AF_SHA1");
          }
      }
      else {
          af_del_seg(af,AF_MD5);    // because it is not valid
          af_del_seg(af,AF_SHA1);
      }
      if(af_update_segq(af,AF_BADSECTORS, (int64)bad_sectors_read)){
          if(errno!=ENOTSUP) perror("Could not update AF_BADSECTORS");
      }
      if(af_update_segq(af,AF_BLANKSECTORS, (int64)total_blank_sectors)){
          if(errno!=ENOTSUP) perror("Could not update AF_BLANKSECTORS");
      }
      unsigned long elapsed_seconds = (unsigned long)imaging_timer.elapsed_seconds();
      if(af_update_seg(af,AF_ACQUISITION_SECONDS,elapsed_seconds,0,0)){
          if(errno!=ENOTSUP) perror("Could not update AF_ACQUISITION_SECONDS");
      }
    }
    return 0;
}

Generated by  Doxygen 1.6.0   Back to index