FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/index.c
/* Read a mapping entry from the phys-to-log index STREAM and append it to
 * RESULT.  *ITEM_INDEX contains the phys offset for the entry and will
 * be moved forward by the size of entry.
 */
Read a mapping entry from the phys-to-log index STREAM and append it to
RESULT.  *ITEM_INDEX contains the phys offset for the entry and will
be moved forward by the size of entry.
Read a mapping entry from the phys - to - log index STREAM and append it to RESULT . * ITEM_INDEX contains the phys offset for the entry and will be moved forward by the size of entry .
static svn_error_t *
read_entry(svn_fs_fs__packed_number_stream_t *stream,
           apr_off_t *item_offset,
           svn_revnum_t *last_revision,
           apr_uint64_t *last_compound,
           apr_array_header_t *result)
{
  apr_uint64_t value;
  svn_fs_fs__p2l_entry_t entry;
  entry.offset = *item_offset;
  SVN_ERR(packed_stream_get(&value, stream));
  entry.size = (apr_off_t)value;
  SVN_ERR(packed_stream_get(&value, stream));
  *last_compound += decode_int(value);
  entry.type = *last_compound & 7;
  entry.item.number = *last_compound / 8;
  if (entry.type > SVN_FS_FS__ITEM_TYPE_CHANGES)
    return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
                            _("Invalid item type in P2L index"));
  if (   entry.type == SVN_FS_FS__ITEM_TYPE_CHANGES
      && entry.item.number != SVN_FS_FS__ITEM_INDEX_CHANGES)
    return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
                            _("Changed path list must have item number 1"));
  SVN_ERR(packed_stream_get(&value, stream));
  *last_revision += (svn_revnum_t)decode_int(value);
  entry.item.revision = *last_revision;
  SVN_ERR(packed_stream_get(&value, stream));
  entry.fnv1_checksum = (apr_uint32_t)value;
  if (value > APR_UINT32_MAX)
    return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
                            _("Invalid FNV1 checksum in P2L index"));
  if (entry.type == SVN_FS_FS__ITEM_TYPE_UNUSED)
    if (   entry.item.number != SVN_FS_FS__ITEM_INDEX_UNUSED
        || entry.fnv1_checksum != 0)
      return svn_error_create(SVN_ERR_FS_INDEX_CORRUPTION, NULL,
                 _("Empty regions must have item number 0 and checksum 0"));
  APR_ARRAY_PUSH(result, svn_fs_fs__p2l_entry_t) = entry;
  *item_offset += entry.size;
  return SVN_NO_ERROR;
}
static svn_error_t * read_entry ( svn_fs_fs__packed_number_stream_t * stream , apr_off_t * item_offset , svn_revnum_t * last_revision , apr_uint64_t * last_compound , apr_array_header_t * result ) { apr_uint64_t value ; svn_fs_fs__p2l_entry_t entry ; entry . offset = * item_offset ; SVN_ERR ( packed_stream_get ( & value , stream ) ) ; entry . size = ( apr_off_t ) value ; SVN_ERR ( packed_stream_get ( & value , stream ) ) ; * last_compound += decode_int ( value ) ; entry . type = * last_compound & 7 ; entry . item . number = * last_compound / 8 ; if ( entry . type > SVN_FS_FS__ITEM_TYPE_CHANGES ) return svn_error_create ( SVN_ERR_FS_INDEX_CORRUPTION , NULL , _ ( " " ) ) ; if ( entry . type == SVN_FS_FS__ITEM_TYPE_CHANGES && entry . item . number != SVN_FS_FS__ITEM_INDEX_CHANGES ) return svn_error_create ( SVN_ERR_FS_INDEX_CORRUPTION , NULL , _ ( " " ) ) ; SVN_ERR ( packed_stream_get ( & value , stream ) ) ; * last_revision += ( svn_revnum_t ) decode_int ( value ) ; entry . item . revision = * last_revision ; SVN_ERR ( packed_stream_get ( & value , stream ) ) ; entry . fnv1_checksum = ( apr_uint32_t ) value ; if ( value > APR_UINT32_MAX ) return svn_error_create ( SVN_ERR_FS_INDEX_CORRUPTION , NULL , _ ( " " ) ) ; if ( entry . type == SVN_FS_FS__ITEM_TYPE_UNUSED ) if ( entry . item . number != SVN_FS_FS__ITEM_INDEX_UNUSED || entry . fnv1_checksum != 0 ) return svn_error_create ( SVN_ERR_FS_INDEX_CORRUPTION , NULL , _ ( " " ) ) ; APR_ARRAY_PUSH ( result , svn_fs_fs__p2l_entry_t ) = entry ; * item_offset += entry . size ; return SVN_NO_ERROR ; }
Read a mapping entry from the phys-to-log index STREAM and append it to
 RESULT.
Read a mapping entry from the phys - to - log index STREAM and append it to RESULT .
/* Verify item type. */ /* Truncating the checksum to 32 bits may have hidden random data in the
   * unused extra bits of the on-disk representation (7/8 bit representation
   * uses 5 bytes on disk for the 32 bit value, leaving 3 bits unused). */ /* Some of the index data for empty rev / pack file sections will not be
   * used during normal operation.  Thus, we have strict rules for the
   * contents of those unused fields. */