1 /* rev_file.h --- revision file and index access data structure
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
20 * ====================================================================
23 #ifndef SVN_LIBSVN_FS_X__REV_FILE_H
24 #define SVN_LIBSVN_FS_X__REV_FILE_H
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.
36 /* Opaque index stream type.
38 typedef struct svn_fs_x__packed_number_stream_t
39 svn_fs_x__packed_number_stream_t;
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.
45 typedef struct svn_fs_x__revision_file_t
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;
51 /* the revision was packed when the first file / stream got opened */
52 svn_boolean_t is_packed;
57 /* stream based on FILE and not NULL exactly when FILE is not NULL */
60 /* the opened P2L index stream or NULL. Always NULL for txns. */
61 svn_fs_x__packed_number_stream_t *p2l_stream;
63 /* the opened L2P index stream or NULL. Always NULL for txns. */
64 svn_fs_x__packed_number_stream_t *l2p_stream;
66 /* Copied from FS->FFD->BLOCK_SIZE upon creation. It allows us to
67 * use aligned seek() without having the FS handy. */
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. */
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;
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. */
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;
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;
93 /* pool containing this object */
95 } svn_fs_x__revision_file_t;
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. */
103 svn_fs_x__open_pack_or_rev_file(svn_fs_x__revision_file_t **file,
106 apr_pool_t *result_pool,
107 apr_pool_t *scratch_pool);
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.
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. */
117 svn_fs_x__open_pack_or_rev_file_writable(svn_fs_x__revision_file_t **file,
120 apr_pool_t *result_pool,
121 apr_pool_t *scratch_pool);
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.
129 svn_fs_x__auto_read_footer(svn_fs_x__revision_file_t *file);
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.. */
134 svn_fs_x__open_proto_rev_file(svn_fs_x__revision_file_t **file,
136 svn_fs_x__txn_id_t txn_id,
137 apr_pool_t* result_pool,
138 apr_pool_t *scratch_pool);
140 /* Wrap the TEMP_FILE, used in the context of FS, into a revision file
141 * struct, allocated in RESULT_POOL, and return it in *FILE.
144 svn_fs_x__wrap_temp_rev_file(svn_fs_x__revision_file_t **file,
146 apr_file_t *temp_file,
147 apr_pool_t *result_pool);
149 /* Close all files and streams in FILE.
152 svn_fs_x__close_revision_file(svn_fs_x__revision_file_t *file);