cfs/src/FsProc_JournalBasic.cc
// Deserialization is done in two steps. First the header, then the body.
Deserialization is done in two steps. First the header, then the body.
Deserialization is done in two steps . First the header then the body .
void JournalEntry::deserializeBody(uint8_t *buf, size_t buf_size) {
  assert(ile_vec.empty());
  if (buf_size < calcBodySize()) throw std::runtime_error("buffer too small");
  if (state != JournalEntryState::DESERIALIZED_PARTIAL)
    throw std::runtime_error("Requires partially deserialized Jentry");
  uint64_t *uint64_header_fields = (uint64_t *)buf;
  if ((uint64_header_fields[0] != JBODY_MAGIC) ||
      (uint64_header_fields[1] != ustime_serialized))
    throw std::runtime_error(
        "Requires same buffer used for partial deserialization");
  uint64_t je_size = uint64_header_fields[2];
  if (buf_size < je_size) throw std::runtime_error("buffer too small");
  uint64_t num_ile = uint64_header_fields[3];
  uint64_t remaining_buf_size = je_size - calcBodySize();
  char *ptr = (char *)buf;
  ptr += calcBodySize();
  for (uint64_t i = 0; i < num_ile && remaining_buf_size > 0; i++) {
    auto ile = new InodeLogEntry((uint8_t *)ptr, remaining_buf_size);
    ile_vec.push_back(ile);
    size_t ile_size = ile->calcSize();
    remaining_buf_size -= ile_size;
    ptr += ile_size;
  }
  state = JournalEntryState::DESERIALIZED;
}
void JournalEntry :: deserializeBody ( uint8_t * buf , size_t buf_size ) { assert ( ile_vec . empty ( ) ) ; if ( buf_size < calcBodySize ( ) ) throw std :: runtime_error ( " " ) ; if ( state != JournalEntryState :: DESERIALIZED_PARTIAL ) throw std :: runtime_error ( " " ) ; uint64_t * uint64_header_fields = ( uint64_t * ) buf ; if ( ( uint64_header_fields [ 0 ] != JBODY_MAGIC ) || ( uint64_header_fields [ 1 ] != ustime_serialized ) ) throw std :: runtime_error ( " " ) ; uint64_t je_size = uint64_header_fields [ 2 ] ; if ( buf_size < je_size ) throw std :: runtime_error ( " " ) ; uint64_t num_ile = uint64_header_fields [ 3 ] ; uint64_t remaining_buf_size = je_size - calcBodySize ( ) ; char * ptr = ( char * ) buf ; ptr += calcBodySize ( ) ; for ( uint64_t i = 0 ; i < num_ile && remaining_buf_size > 0 ; i ++ ) { auto ile = new InodeLogEntry ( ( uint8_t * ) ptr , remaining_buf_size ) ; ile_vec . push_back ( ile ) ; size_t ile_size = ile -> calcSize ( ) ; remaining_buf_size -= ile_size ; ptr += ile_size ; } state = JournalEntryState :: DESERIALIZED ; }
Deserialization is done in two steps.
Deserialization is done in two steps .