You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2013/07/25 15:36:08 UTC
svn commit: r1506962 -
/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/recovery.c
Author: stefan2
Date: Thu Jul 25 13:36:08 2013
New Revision: 1506962
URL: http://svn.apache.org/r1506962
Log:
On the fsfs-improvements branch: Make recovery handler use a stream
instead of a file and use the proper length data types.
* subversion/libsvn_fs_fs/recovery.c
(recover_read_from_file_baton): replace file with stream
(read_handler_recover): update user;
use casts to handle theoretical overflows
(recover_find_max_ids): update caller
Modified:
subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/recovery.c
Modified: subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/recovery.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/recovery.c?rev=1506962&r1=1506961&r2=1506962&view=diff
==============================================================================
--- subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/recovery.c (original)
+++ subversion/branches/fsfs-improvements/subversion/libsvn_fs_fs/recovery.c Thu Jul 25 13:36:08 2013
@@ -105,7 +105,7 @@ recover_get_largest_revision(svn_fs_t *f
recover_find_max_ids() below. */
struct recover_read_from_file_baton
{
- apr_file_t *file;
+ svn_stream_t *stream;
apr_pool_t *pool;
apr_off_t remaining;
};
@@ -117,7 +117,7 @@ static svn_error_t *
read_handler_recover(void *baton, char *buffer, apr_size_t *len)
{
struct recover_read_from_file_baton *b = baton;
- svn_filesize_t bytes_to_read = *len;
+ apr_size_t bytes_to_read = *len;
if (b->remaining == 0)
{
@@ -126,12 +126,11 @@ read_handler_recover(void *baton, char *
return SVN_NO_ERROR;
}
- if (bytes_to_read > b->remaining)
- bytes_to_read = b->remaining;
+ if ((apr_int64_t)bytes_to_read > (apr_int64_t)b->remaining)
+ bytes_to_read = (apr_size_t)b->remaining;
b->remaining -= bytes_to_read;
- return svn_io_file_read_full2(b->file, buffer, (apr_size_t) bytes_to_read,
- len, NULL, b->pool);
+ return svn_stream_read(b->stream, buffer, &bytes_to_read);
}
/* Part of the recovery procedure. Read the directory noderev at offset
@@ -161,9 +160,9 @@ recover_find_max_ids(svn_fs_t *fs,
apr_pool_t *iterpool;
node_revision_t *noderev;
- stream = svn_stream_from_aprfile2(rev_file, TRUE, pool);
+ baton.stream = svn_stream_from_aprfile2(rev_file, TRUE, pool);
SVN_ERR(svn_io_file_seek(rev_file, APR_SET, &offset, pool));
- SVN_ERR(svn_fs_fs__read_noderev(&noderev, stream, pool));
+ SVN_ERR(svn_fs_fs__read_noderev(&noderev, baton.stream, pool));
/* Check that this is a directory. It should be. */
if (noderev->kind != svn_node_dir)
@@ -185,7 +184,7 @@ recover_find_max_ids(svn_fs_t *fs,
rely on directory entries being stored as PLAIN reps, though. */
offset = noderev->data_rep->offset;
SVN_ERR(svn_io_file_seek(rev_file, APR_SET, &offset, pool));
- SVN_ERR(svn_fs_fs__read_rep_header(&header, stream, pool));
+ SVN_ERR(svn_fs_fs__read_rep_header(&header, baton.stream, pool));
if (header->type != svn_fs_fs__rep_plain)
return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
_("Recovery encountered a deltified directory "
@@ -193,9 +192,8 @@ recover_find_max_ids(svn_fs_t *fs,
/* Now create a stream that's allowed to read only as much data as is
stored in the representation. */
- baton.file = rev_file;
baton.pool = pool;
- baton.remaining = (apr_size_t) noderev->data_rep->expanded_size;
+ baton.remaining = noderev->data_rep->expanded_size;
stream = svn_stream_create(&baton, pool);
svn_stream_set_read(stream, read_handler_recover);