subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1662929 - in /subversion/branches/fsx-1.10/subversion/libsvn_fs_x: rev_file.c rev_file.h verify.c
Date Sat, 28 Feb 2015 13:02:09 GMT
Author: stefan2
Date: Sat Feb 28 13:02:09 2015
New Revision: 1662929

URL: http://svn.apache.org/r1662929
Log:
On the fsx-1.10 branch:
Add basic file I/O functions to svn_fs_x__revision_file_t's private API.
Begin using them to minimize the dependency on svn_fs_x__revision_file_t's
actual structure defintion.

* subversion/libsvn_fs_x/rev_file.h
  (svn_fs_x__rev_file_name,
   svn_fs_x__rev_file_seek,
   svn_fs_x__rev_file_offset,
   svn_fs_x__rev_file_read): Declare new private API functions.

* subversion/libsvn_fs_x/rev_file.c
  (svn_fs_x__rev_file_name,
   svn_fs_x__rev_file_seek,
   svn_fs_x__rev_file_offset,
   svn_fs_x__rev_file_read): Implement them.

* subversion/libsvn_fs_x/verify.c
  (verify_index_checksum): Expect a revision file instead of plain APR file.
                           Use the new API functions to access it.
  (verify_index_checksums): Update caller.
  (expect_buffer_nul): Expect a revision file instead of plain APR file.
                       Use the new API functions to access it.
  (expected_checksum): Update parameter type.
  (expected_buffered_checksum,
   expected_streamed_checksum): Expect a revision file instead of plain APR
                                file and use the new API functions on it.
  (compare_p2l_to_rev): Update caller. Use the new API functions.

Modified:
    subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c
    subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h
    subversion/branches/fsx-1.10/subversion/libsvn_fs_x/verify.c

Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c?rev=1662929&r1=1662928&r2=1662929&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.c Sat Feb 28 13:02:09 2015
@@ -309,6 +309,15 @@ svn_fs_x__wrap_temp_rev_file(svn_fs_x__r
 }
 
 svn_error_t *
+svn_fs_x__rev_file_name(const char **filename,
+                        svn_fs_x__revision_file_t *file,
+                        apr_pool_t *result_pool)
+{
+  return svn_error_trace(svn_io_file_name_get(filename, file->file,
+                                              result_pool));
+}
+
+svn_error_t *
 svn_fs_x__rev_file_l2p_index(svn_fs_x__packed_number_stream_t **stream,
                              svn_fs_x__revision_file_t *file)
 {
@@ -371,6 +380,34 @@ svn_fs_x__rev_file_p2l_info(svn_fs_x__in
 }
 
 svn_error_t *
+svn_fs_x__rev_file_seek(svn_fs_x__revision_file_t *file,
+                        apr_off_t *buffer_start,
+                        apr_off_t offset)
+{
+  return svn_error_trace(svn_io_file_aligned_seek(file->file,
+                                                  file->block_size,
+                                                  buffer_start, offset,
+                                                  file->pool));
+}
+
+svn_error_t *
+svn_fs_x__rev_file_offset(apr_off_t *offset,
+                          svn_fs_x__revision_file_t *file)
+{
+  return svn_error_trace(svn_fs_x__get_file_offset(offset, file->file,
+                                                   file->pool));
+}
+
+svn_error_t *
+svn_fs_x__rev_file_read(svn_fs_x__revision_file_t *file,
+                        void *buf,
+                        apr_size_t nbytes)
+{
+  return svn_error_trace(svn_io_file_read_full2(file->file, buf, nbytes,
+                                                NULL, NULL, file->pool));
+}
+
+svn_error_t *
 svn_fs_x__close_revision_file(svn_fs_x__revision_file_t *file)
 {
   if (file->stream)

Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h?rev=1662929&r1=1662928&r2=1662929&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/rev_file.h Sat Feb 28 13:02:09 2015
@@ -139,6 +139,12 @@ svn_fs_x__wrap_temp_rev_file(svn_fs_x__r
 
 /* Access functions */
 
+/* Convenience wrapper around svn_io_file_name_get. */
+svn_error_t *
+svn_fs_x__rev_file_name(const char **filename,
+                        svn_fs_x__revision_file_t *file,
+                        apr_pool_t *result_pool);
+
 /* Set *STREAM to the shared L2P data stream of FILE.  Initializes the
  * stream on demand.
  */
@@ -165,6 +171,25 @@ svn_error_t *
 svn_fs_x__rev_file_p2l_info(svn_fs_x__index_info_t *info,
                             svn_fs_x__revision_file_t *file);
 
+/* File manipulation. */
+
+/* Convenience wrapper around svn_io_file_aligned_seek. */
+svn_error_t *
+svn_fs_x__rev_file_seek(svn_fs_x__revision_file_t *file,
+                        apr_off_t *buffer_start,
+                        apr_off_t offset);
+
+/* Convenience wrapper around svn_fs_x__get_file_offset. */
+svn_error_t *
+svn_fs_x__rev_file_offset(apr_off_t *offset,
+                          svn_fs_x__revision_file_t *file);
+
+/* Convenience wrapper around svn_io_file_read_full2. */
+svn_error_t *
+svn_fs_x__rev_file_read(svn_fs_x__revision_file_t *file,
+                        void *buf,
+                        apr_size_t nbytes);
+
 /* Close all files and streams in FILE.
  */
 svn_error_t *

Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/verify.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/verify.c?rev=1662929&r1=1662928&r2=1662929&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/verify.c (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/verify.c Sat Feb 28 13:02:09 2015
@@ -141,7 +141,7 @@ verify_rep_cache(svn_fs_t *fs,
  * indedx NAME in the error message.  Supports cancellation with CANCEL_FUNC
  * and CANCEL_BATON.  SCRATCH_POOL is for temporary allocations. */
 static svn_error_t *
-verify_index_checksum(apr_file_t *file,
+verify_index_checksum(svn_fs_x__revision_file_t *file,
                       const char *name,
                       svn_fs_x__index_info_t *index_info,
                       svn_cancel_func_t cancel_func,
@@ -155,14 +155,13 @@ verify_index_checksum(apr_file_t *file,
     = svn_checksum_ctx_create(svn_checksum_md5, scratch_pool);
 
   /* Calculate the index checksum. */
-  SVN_ERR(svn_io_file_seek(file, APR_SET, &index_info->start, scratch_pool));
+  SVN_ERR(svn_fs_x__rev_file_seek(file, NULL, index_info->start));
   while (size > 0)
     {
       apr_size_t to_read = size > sizeof(buffer)
                          ? sizeof(buffer)
                          : (apr_size_t)size;
-      SVN_ERR(svn_io_file_read_full2(file, buffer, to_read, NULL, NULL,
-                                     scratch_pool));
+      SVN_ERR(svn_fs_x__rev_file_read(file, buffer, to_read));
       SVN_ERR(svn_checksum_update(context, buffer, to_read));
       size -= to_read;
 
@@ -177,7 +176,7 @@ verify_index_checksum(apr_file_t *file,
     {
       const char *file_name;
 
-      SVN_ERR(svn_io_file_name_get(&file_name, file, scratch_pool));
+      SVN_ERR(svn_fs_x__rev_file_name(&file_name, file, scratch_pool));
       SVN_ERR(svn_checksum_mismatch_err(index_info->checksum, actual,
                                         scratch_pool, 
                                         _("%s checksum mismatch in file %s"),
@@ -210,9 +209,9 @@ verify_index_checksums(svn_fs_t *fs,
   SVN_ERR(svn_fs_x__rev_file_p2l_info(&p2l_index_info, rev_file));
 
   /* Verify the index contents against the checksum from the footer. */
-  SVN_ERR(verify_index_checksum(rev_file->file, "L2P index", &l2p_index_info,
+  SVN_ERR(verify_index_checksum(rev_file, "L2P index", &l2p_index_info,
                                 cancel_func, cancel_baton, scratch_pool));
-  SVN_ERR(verify_index_checksum(rev_file->file, "P2L index", &p2l_index_info,
+  SVN_ERR(verify_index_checksum(rev_file, "P2L index", &p2l_index_info,
                                 cancel_func, cancel_baton, scratch_pool));
 
   /* Done. */
@@ -422,7 +421,7 @@ compare_p2l_to_l2p_index(svn_fs_t *fs,
  * exceed STREAM_THRESHOLD.  Use SCRATCH_POOL for temporary allocations.
  */
 static svn_error_t *
-expect_buffer_nul(apr_file_t *file,
+expect_buffer_nul(svn_fs_x__revision_file_t *file,
                   apr_off_t size,
                   apr_pool_t *scratch_pool)
 {
@@ -437,8 +436,7 @@ expect_buffer_nul(apr_file_t *file,
 
   /* read the whole data block; error out on failure */
   data.chunks[(size - 1)/ sizeof(apr_uint64_t)] = 0;
-  SVN_ERR(svn_io_file_read_full2(file, data.buffer, size, NULL, NULL,
-                                 scratch_pool));
+  SVN_ERR(svn_fs_x__rev_file_read(file, data.buffer, size));
 
   /* chunky check */
   for (i = 0; i < size / sizeof(apr_uint64_t); ++i)
@@ -452,8 +450,8 @@ expect_buffer_nul(apr_file_t *file,
         const char *file_name;
         apr_off_t offset;
 
-        SVN_ERR(svn_io_file_name_get(&file_name, file, scratch_pool));
-        SVN_ERR(svn_fs_x__get_file_offset(&offset, file, scratch_pool));
+        SVN_ERR(svn_fs_x__rev_file_name(&file_name, file, scratch_pool));
+        SVN_ERR(svn_fs_x__rev_file_offset(&offset, file));
         offset -= size - i;
 
         return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
@@ -470,7 +468,7 @@ expect_buffer_nul(apr_file_t *file,
  * Use SCRATCH_POOL for temporary allocations.
  */
 static svn_error_t *
-read_all_nul(apr_file_t *file,
+read_all_nul(svn_fs_x__revision_file_t *file,
              apr_off_t size,
              apr_pool_t *scratch_pool)
 {
@@ -488,7 +486,7 @@ read_all_nul(apr_file_t *file,
  * in error message.  Allocate temporary data in SCRATCH_POOL.
  */
 static svn_error_t *
-expected_checksum(apr_file_t *file,
+expected_checksum(svn_fs_x__revision_file_t *file,
                   svn_fs_x__p2l_entry_t *entry,
                   apr_uint32_t actual,
                   apr_pool_t *scratch_pool)
@@ -497,8 +495,7 @@ expected_checksum(apr_file_t *file,
     {
       const char *file_name;
 
-      SVN_ERR(svn_io_file_name_get(&file_name, file, scratch_pool));
-      SVN_ERR(svn_io_file_name_get(&file_name, file, scratch_pool));
+      SVN_ERR(svn_fs_x__rev_file_name(&file_name, file, scratch_pool));
       return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
                                _("Checksum mismatch in item at offset %s of "
                                  "length %s bytes in file %s"),
@@ -515,15 +512,14 @@ expected_checksum(apr_file_t *file,
  * exceed STREAM_THRESHOLD.  Use SCRATCH_POOL for temporary allocations.
  */
 static svn_error_t *
-expected_buffered_checksum(apr_file_t *file,
+expected_buffered_checksum(svn_fs_x__revision_file_t *file,
                            svn_fs_x__p2l_entry_t *entry,
                            apr_pool_t *scratch_pool)
 {
   unsigned char buffer[STREAM_THRESHOLD];
   SVN_ERR_ASSERT(entry->size <= STREAM_THRESHOLD);
 
-  SVN_ERR(svn_io_file_read_full2(file, buffer, (apr_size_t)entry->size,
-                                 NULL, NULL, scratch_pool));
+  SVN_ERR(svn_fs_x__rev_file_read(file, buffer, (apr_size_t)entry->size));
   SVN_ERR(expected_checksum(file, entry,
                             svn__fnv1a_32x4(buffer, (apr_size_t)entry->size),
                             scratch_pool));
@@ -536,7 +532,7 @@ expected_buffered_checksum(apr_file_t *f
  * Use SCRATCH_POOL for temporary allocations.
  */
 static svn_error_t *
-expected_streamed_checksum(apr_file_t *file,
+expected_streamed_checksum(svn_fs_x__revision_file_t *file,
                            svn_fs_x__p2l_entry_t *entry,
                            apr_pool_t *scratch_pool)
 {
@@ -551,8 +547,7 @@ expected_streamed_checksum(apr_file_t *f
       apr_size_t to_read = size > sizeof(buffer)
                          ? sizeof(buffer)
                          : (apr_size_t)size;
-      SVN_ERR(svn_io_file_read_full2(file, buffer, to_read, NULL, NULL,
-                                     scratch_pool));
+      SVN_ERR(svn_fs_x__rev_file_read(file, buffer, to_read));
       SVN_ERR(svn_checksum_update(context, buffer, to_read));
       size -= to_read;
     }
@@ -607,8 +602,7 @@ compare_p2l_to_rev(svn_fs_t *fs,
                              apr_off_t_toa(scratch_pool,
                                            max_offset));
 
-  SVN_ERR(svn_io_file_aligned_seek(rev_file->file, ffd->block_size, NULL, 0,
-                                   scratch_pool));
+  SVN_ERR(svn_fs_x__rev_file_seek(rev_file, NULL, 0));
 
   /* for all offsets in the file, get the P2L index entries and check
      them against the L2P index */
@@ -626,8 +620,7 @@ compare_p2l_to_rev(svn_fs_t *fs,
 
       /* The above might have moved the file pointer.
        * Ensure we actually start reading at OFFSET.  */
-      SVN_ERR(svn_io_file_aligned_seek(rev_file->file, ffd->block_size,
-                                       NULL, offset, iterpool));
+      SVN_ERR(svn_fs_x__rev_file_seek(rev_file, NULL, offset));
 
       /* process all entries (and later continue with the next block) */
       for (i = 0; i < entries->nelts; ++i)
@@ -660,15 +653,15 @@ compare_p2l_to_rev(svn_fs_t *fs,
             {
               /* skip filler entry at the end of the p2l index */
               if (entry->offset != max_offset)
-                SVN_ERR(read_all_nul(rev_file->file, entry->size, iterpool));
+                SVN_ERR(read_all_nul(rev_file, entry->size, iterpool));
             }
           else
             {
               if (entry->size < STREAM_THRESHOLD)
-                SVN_ERR(expected_buffered_checksum(rev_file->file, entry,
+                SVN_ERR(expected_buffered_checksum(rev_file, entry,
                                                    iterpool));
               else
-                SVN_ERR(expected_streamed_checksum(rev_file->file, entry,
+                SVN_ERR(expected_streamed_checksum(rev_file, entry,
                                                    iterpool));
             }
 



Mime
View raw message