src/worker.cc
// Copy data from file into memory blocks.
Copy data from file into memory blocks.
Copy data from file into memory blocks .
bool FileThread::ReadPages(int fd) {
  int page_length = sat_->page_length();
  int strict = sat_->strict();
  bool result = true;
  lseek64(fd, 0, SEEK_SET);
  for (int i = 0; i < sat_->disk_pages(); i++) {
    struct page_entry dst;
    if (!GetEmptyPage(&dst))
      return false;
    dst.pattern = page_recs_[i].pattern;
    page_recs_[i].dst = dst.addr;
    if (!ReadPageFromFile(fd, &dst)) {
        PutEmptyPage(&dst);
        return false;
    }
    SectorValidatePage(page_recs_[i], &dst, i);
    if (strict) {
      crc_page_ = i;
      int errors = CrcCheckPage(&dst);
      if (errors) {
        logprintf(5, "Log: file miscompare at block %d, "
                  "offset %x-%x. File: %s\n",
                  i, i * page_length, ((i + 1) * page_length) - 1,
                  filename_.c_str());
        result = false;
      }
      crc_page_ = -1;
      errorcount_ += errors;
    }
    if (!PutValidPage(&dst))
      return false;
  }
  return result;
}
bool FileThread :: ReadPages ( int fd ) { int page_length = sat_ -> page_length ( ) ; int strict = sat_ -> strict ( ) ; bool result = true ; lseek64 ( fd , 0 , SEEK_SET ) ; for ( int i = 0 ; i < sat_ -> disk_pages ( ) ; i ++ ) { struct page_entry dst ; if ( ! GetEmptyPage ( & dst ) ) return false ; dst . pattern = page_recs_ [ i ] . pattern ; page_recs_ [ i ] . dst = dst . addr ; if ( ! ReadPageFromFile ( fd , & dst ) ) { PutEmptyPage ( & dst ) ; return false ; } SectorValidatePage ( page_recs_ [ i ] , & dst , i ) ; if ( strict ) { crc_page_ = i ; int errors = CrcCheckPage ( & dst ) ; if ( errors ) { logprintf ( 5 , " " " \n " , i , i * page_length , ( ( i + 1 ) * page_length ) - 1 , filename_ . c_str ( ) ) ; result = false ; } crc_page_ = -1 ; errorcount_ += errors ; } if ( ! PutValidPage ( & dst ) ) return false ; } return result ; }
Copy data from file into memory blocks.
Copy data from file into memory blocks .
// Read our data back out of the file, into it's new location. // Retrieve expected pattern. // Update page recordpage record. // Read from the file into destination page. // Ensure that the transfer ended up with correct data. // Record page index currently CRC checked.