rev_file.h revision 299742
1/* rev_file.h --- revision file and index access data structure 2 * 3 * ==================================================================== 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 * ==================================================================== 21 */ 22 23#ifndef SVN_LIBSVN_FS__REV_FILE_H 24#define SVN_LIBSVN_FS__REV_FILE_H 25 26#include "svn_fs.h" 27#include "id.h" 28 29/* In format 7, index files must be read in sync with the respective 30 * revision / pack file. I.e. we must use packed index files for packed 31 * rev files and unpacked ones for non-packed rev files. So, the whole 32 * point is to open them with matching "is packed" setting in case some 33 * background pack process was run. 34 */ 35 36/* Opaque index stream type. 37 */ 38typedef struct svn_fs_fs__packed_number_stream_t 39 svn_fs_fs__packed_number_stream_t; 40 41/* Data file, including indexes data, and associated properties for 42 * START_REVISION. As the FILE is kept open, background pack operations 43 * will not cause access to this file to fail. 44 */ 45typedef struct svn_fs_fs__revision_file_t 46{ 47 /* first (potentially only) revision in the rev / pack file. 48 * SVN_INVALID_REVNUM for txn proto-rev files. */ 49 svn_revnum_t start_revision; 50 51 /* the revision was packed when the first file / stream got opened */ 52 svn_boolean_t is_packed; 53 54 /* rev / pack file */ 55 apr_file_t *file; 56 57 /* stream based on FILE and not NULL exactly when FILE is not NULL */ 58 svn_stream_t *stream; 59 60 /* the opened P2L index stream or NULL. Always NULL for txns. */ 61 svn_fs_fs__packed_number_stream_t *p2l_stream; 62 63 /* the opened L2P index stream or NULL. Always NULL for txns. */ 64 svn_fs_fs__packed_number_stream_t *l2p_stream; 65 66 /* Copied from FS->FFD->BLOCK_SIZE upon creation. It allows us to 67 * use aligned seek() without having the FS handy. */ 68 apr_off_t block_size; 69 70 /* Offset within FILE at which the rev data ends and the L2P index 71 * data starts. Less than P2L_OFFSET. -1 if svn_fs_fs__auto_read_footer 72 * has not been called, yet. */ 73 apr_off_t l2p_offset; 74 75 /* MD5 checksum on the whole on-disk representation of the L2P index. 76 * NULL if svn_fs_fs__auto_read_footer has not been called, yet. */ 77 svn_checksum_t *l2p_checksum; 78 79 /* Offset within FILE at which the L2P index ends and the P2L index 80 * data starts. Greater than L2P_OFFSET. -1 if svn_fs_fs__auto_read_footer 81 * has not been called, yet. */ 82 apr_off_t p2l_offset; 83 84 /* MD5 checksum on the whole on-disk representation of the P2L index. 85 * NULL if svn_fs_fs__auto_read_footer has not been called, yet. */ 86 svn_checksum_t *p2l_checksum; 87 88 /* Offset within FILE at which the P2L index ends and the footer starts. 89 * Greater than P2L_OFFSET. -1 if svn_fs_fs__auto_read_footer has not 90 * been called, yet. */ 91 apr_off_t footer_offset; 92 93 /* pool containing this object */ 94 apr_pool_t *pool; 95} svn_fs_fs__revision_file_t; 96 97/* Open the correct revision file for REV. If the filesystem FS has 98 * been packed, *FILE will be set to the packed file; otherwise, set *FILE 99 * to the revision file for REV. Return SVN_ERR_FS_NO_SUCH_REVISION if the 100 * file doesn't exist. Allocate *FILE in RESULT_POOL and use SCRATCH_POOL 101 * for temporaries. */ 102svn_error_t * 103svn_fs_fs__open_pack_or_rev_file(svn_fs_fs__revision_file_t **file, 104 svn_fs_t *fs, 105 svn_revnum_t rev, 106 apr_pool_t *result_pool, 107 apr_pool_t *scratch_pool); 108 109/* Open the correct revision file for REV with read and write access. 110 * If necessary, temporarily reset the file's read-only state. If the 111 * filesystem FS has been packed, *FILE will be set to the packed file; 112 * otherwise, set *FILE to the revision file for REV. 113 * 114 * Return SVN_ERR_FS_NO_SUCH_REVISION if the file doesn't exist. 115 * Allocate *FILE in RESULT_POOL and use SCRATCH_POOLfor temporaries. */ 116svn_error_t * 117svn_fs_fs__open_pack_or_rev_file_writable(svn_fs_fs__revision_file_t **file, 118 svn_fs_t *fs, 119 svn_revnum_t rev, 120 apr_pool_t *result_pool, 121 apr_pool_t *scratch_pool); 122 123/* If the footer data in FILE has not been read, yet, do so now. 124 * Index locations will only be read upon request as we assume they get 125 * cached and the FILE is usually used for REP data access only. 126 * Hence, the separate step. 127 */ 128svn_error_t * 129svn_fs_fs__auto_read_footer(svn_fs_fs__revision_file_t *file); 130 131/* Open the proto-rev file of transaction TXN_ID in FS and return it in *FILE. 132 * Allocate *FILE in RESULT_POOL use and SCRATCH_POOL for temporaries.. */ 133svn_error_t * 134svn_fs_fs__open_proto_rev_file(svn_fs_fs__revision_file_t **file, 135 svn_fs_t *fs, 136 const svn_fs_fs__id_part_t *txn_id, 137 apr_pool_t* result_pool, 138 apr_pool_t *scratch_pool); 139 140/* Close all files and streams in FILE. 141 */ 142svn_error_t * 143svn_fs_fs__close_revision_file(svn_fs_fs__revision_file_t *file); 144 145#endif 146