FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/recovery.c
/* Part of the recovery procedure.  Given an open non-packed revision file
   REV_FILE for REV, locate the trailer that specifies the offset to the root
   node-id and store this offset in *ROOT_OFFSET.  Do temporary allocations in
   POOL. */
Part of the recovery procedure.  Given an open non-packed revision file
REV_FILE for REV, locate the trailer that specifies the offset to the root
node-id and store this offset in *ROOT_OFFSET.  Do temporary allocations in
POOL.
Part of the recovery procedure . Given an open non - packed revision file REV_FILE for REV locate the trailer that specifies the offset to the root node - id and store this offset in * ROOT_OFFSET . Do temporary allocations in POOL .
static svn_error_t *
recover_get_root_offset(apr_off_t *root_offset,
                        svn_revnum_t rev,
                        svn_fs_fs__revision_file_t *rev_file,
                        apr_pool_t *pool)
{
  char buffer[64];
  svn_stringbuf_t *trailer;
  apr_off_t start;
  apr_off_t end;
  apr_size_t len;
  SVN_ERR_ASSERT(!rev_file->is_packed);
  end = 0;
  SVN_ERR(svn_io_file_seek(rev_file->file, APR_END, &end, pool));
  if (end < sizeof(buffer))
    {
      len = (apr_size_t)end;
      start = 0;
    }
  else
    {
      len = sizeof(buffer);
      start = end - sizeof(buffer);
    }
  SVN_ERR(svn_io_file_seek(rev_file->file, APR_SET, &start, pool));
  SVN_ERR(svn_io_file_read_full2(rev_file->file, buffer, len,
                                 NULL, NULL, pool));
  trailer = svn_stringbuf_ncreate(buffer, len, pool);
  SVN_ERR(svn_fs_fs__parse_revision_trailer(root_offset, NULL, trailer, rev));
  return SVN_NO_ERROR;
}
static svn_error_t * recover_get_root_offset ( apr_off_t * root_offset , svn_revnum_t rev , svn_fs_fs__revision_file_t * rev_file , apr_pool_t * pool ) { char buffer [ 64 ] ; svn_stringbuf_t * trailer ; apr_off_t start ; apr_off_t end ; apr_size_t len ; SVN_ERR_ASSERT ( ! rev_file -> is_packed ) ; end = 0 ; SVN_ERR ( svn_io_file_seek ( rev_file -> file , APR_END , & end , pool ) ) ; if ( end < sizeof ( buffer ) ) { len = ( apr_size_t ) end ; start = 0 ; } else { len = sizeof ( buffer ) ; start = end - sizeof ( buffer ) ; } SVN_ERR ( svn_io_file_seek ( rev_file -> file , APR_SET , & start , pool ) ) ; SVN_ERR ( svn_io_file_read_full2 ( rev_file -> file , buffer , len , NULL , NULL , pool ) ) ; trailer = svn_stringbuf_ncreate ( buffer , len , pool ) ; SVN_ERR ( svn_fs_fs__parse_revision_trailer ( root_offset , NULL , trailer , rev ) ) ; return SVN_NO_ERROR ; }
Part of the recovery procedure.
Part of the recovery procedure .
/* We will assume that the last line containing the two offsets (to the root
     node-id and to the changed path information) will never be longer than 64
     characters. */