FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/transaction.c
/* Make sure the length ACTUAL_LENGTH of the proto-revision file PROTO_REV
   of transaction TXN_ID in filesystem FS matches the proto-index file.
   Trim any crash / failure related extra data from the proto-rev file.

   If the prototype revision file is too short, we can't do much but bail out.

   Perform all allocations in POOL. */
Make sure the length ACTUAL_LENGTH of the proto-revision file PROTO_REV
of transaction TXN_ID in filesystem FS matches the proto-index file.
Trim any crash / failure related extra data from the proto-rev file.

If the prototype revision file is too short, we can't do much but bail out.

Perform all allocations in POOL.
Make sure the length ACTUAL_LENGTH of the proto - revision file PROTO_REV of transaction TXN_ID in filesystem FS matches the proto - index file . Trim any crash / failure related extra data from the proto - rev file . If the prototype revision file is too short we can ' t do much but bail out . Perform all allocations in POOL .
static svn_error_t *
auto_truncate_proto_rev(svn_fs_t *fs,
                        apr_file_t *proto_rev,
                        apr_off_t actual_length,
                        const svn_fs_fs__id_part_t *txn_id,
                        apr_pool_t *pool)
{
  if (svn_fs_fs__use_log_addressing(fs))
    {
      const char *path = svn_fs_fs__path_p2l_proto_index(fs, txn_id, pool);
      apr_file_t *file;
      apr_off_t indexed_length;
      SVN_ERR(svn_fs_fs__p2l_proto_index_open(&file, path, pool));
      SVN_ERR(svn_fs_fs__p2l_proto_index_next_offset(&indexed_length, file,
                                                     pool));
      SVN_ERR(svn_io_file_close(file, pool));
      if (indexed_length < actual_length)
        SVN_ERR(svn_io_file_trunc(proto_rev, indexed_length, pool));
      else if (indexed_length > actual_length)
        return svn_error_createf(SVN_ERR_FS_INDEX_INCONSISTENT,
                                 NULL,
                                 _("p2l proto index offset %s beyond proto"
                                   "rev file size %s for TXN %s"),
                                   apr_off_t_toa(pool, indexed_length),
                                   apr_off_t_toa(pool, actual_length),
                                   svn_fs_fs__id_txn_unparse(txn_id, pool));
    }
  return SVN_NO_ERROR;
}
static svn_error_t * auto_truncate_proto_rev ( svn_fs_t * fs , apr_file_t * proto_rev , apr_off_t actual_length , const svn_fs_fs__id_part_t * txn_id , apr_pool_t * pool ) { if ( svn_fs_fs__use_log_addressing ( fs ) ) { const char * path = svn_fs_fs__path_p2l_proto_index ( fs , txn_id , pool ) ; apr_file_t * file ; apr_off_t indexed_length ; SVN_ERR ( svn_fs_fs__p2l_proto_index_open ( & file , path , pool ) ) ; SVN_ERR ( svn_fs_fs__p2l_proto_index_next_offset ( & indexed_length , file , pool ) ) ; SVN_ERR ( svn_io_file_close ( file , pool ) ) ; if ( indexed_length < actual_length ) SVN_ERR ( svn_io_file_trunc ( proto_rev , indexed_length , pool ) ) ; else if ( indexed_length > actual_length ) return svn_error_createf ( SVN_ERR_FS_INDEX_INCONSISTENT , NULL , _ ( " " " " ) , apr_off_t_toa ( pool , indexed_length ) , apr_off_t_toa ( pool , actual_length ) , svn_fs_fs__id_txn_unparse ( txn_id , pool ) ) ; } return SVN_NO_ERROR ; }
Make sure the length ACTUAL_LENGTH of the proto-revision file PROTO_REV
of transaction TXN_ID in filesystem FS matches the proto-index file.
Make sure the length ACTUAL_LENGTH of the proto - revision file PROTO_REV of transaction TXN_ID in filesystem FS matches the proto - index file .
/* Only relevant for newer FSFS formats. */ /* Determine file range covered by the proto-index so far.  Note that
         we always append to both file, i.e. the last index entry also
         corresponds to the last addition in the rev file. */ /* Handle mismatches. */