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 FSX, index data must be read in sync with the respective revision /
30 * pack file. I.e. we must use packed index files for packed rev files and
31 * unpacked ones for non-packed rev files. So, the whole point is to open
32 * them with matching "is packed" setting in case some background pack
35 * Another thing that this allows us is to lazily open the file, i.e. open
36 * it upon first access.
39 /* Opaque index stream type.
41 typedef struct svn_fs_x__packed_number_stream_t
42 svn_fs_x__packed_number_stream_t;
44 /* Location and content meta data for an index. */
45 typedef struct svn_fs_x__index_info_t
47 /* Offset within the pack / rev file at which the index data starts. */
50 /* First offset behind the index data. */
53 /* MD5 checksum on the whole on-disk representation of the index. */
54 svn_checksum_t *checksum;
56 } svn_fs_x__index_info_t;
58 /* Location and content meta data for a revision / pack file. */
59 typedef struct svn_fs_x__rev_file_info_t
61 /* first (potentially only) revision in the rev / pack file.
62 * SVN_INVALID_REVNUM for txn proto-rev files. */
63 svn_revnum_t start_revision;
65 /* the revision was packed when the first file / stream got opened */
66 svn_boolean_t is_packed;
68 } svn_fs_x__rev_file_info_t;
70 /* Data file, including indexes data, and associated properties for
71 * START_REVISION. As the FILE is kept open, background pack operations
72 * will not cause access to this file to fail.
74 typedef struct svn_fs_x__revision_file_t svn_fs_x__revision_file_t;
76 /* Initialize the revision / pack file access structure in *FILE for reading
77 * revision REV from filesystem FS. The file will not be opened until the
78 * first call to any of the access functions.
80 * Allocate *FILE in RESULT_POOL. */
82 svn_fs_x__rev_file_init(svn_fs_x__revision_file_t **file,
85 apr_pool_t *result_pool);
87 /* Open the correct revision file for REV with read and write access.
88 * If necessary, temporarily reset the file's read-only state. If the
89 * filesystem FS has been packed, *FILE will be set to the packed file;
90 * otherwise, set *FILE to the revision file for REV.
92 * Return SVN_ERR_FS_NO_SUCH_REVISION if the file doesn't exist.
93 * Allocate *FILE in RESULT_POOL and use SCRATCH_POOLfor temporaries. */
95 svn_fs_x__rev_file_open_writable(svn_fs_x__revision_file_t **file,
98 apr_pool_t *result_pool,
99 apr_pool_t *scratch_pool);
101 /* Open the proto-rev file of transaction TXN_ID in FS and return it in *FILE.
102 * Allocate *FILE in RESULT_POOL use and SCRATCH_POOL for temporaries.. */
104 svn_fs_x__rev_file_open_proto_rev(svn_fs_x__revision_file_t **file,
106 svn_fs_x__txn_id_t txn_id,
107 apr_pool_t* result_pool,
108 apr_pool_t *scratch_pool);
110 /* Wrap the TEMP_FILE, used in the context of FS, into a revision file
111 * struct, allocated in RESULT_POOL, and return it in *FILE.
114 svn_fs_x__rev_file_wrap_temp(svn_fs_x__revision_file_t **file,
116 apr_file_t *temp_file,
117 apr_pool_t *result_pool);
119 /* Access functions */
121 /* Copy the L2P index info for FILE into *INFO.
124 svn_fs_x__rev_file_info(svn_fs_x__rev_file_info_t *info,
125 svn_fs_x__revision_file_t *file);
127 /* Convenience wrapper around svn_io_file_name_get. */
129 svn_fs_x__rev_file_name(const char **filename,
130 svn_fs_x__revision_file_t *file,
131 apr_pool_t *result_pool);
133 /* Set *STREAM to the shared stream object of FILE.
136 svn_fs_x__rev_file_stream(svn_stream_t **stream,
137 svn_fs_x__revision_file_t *file);
139 /* Set *APR_FILE to the shared file object of FILE.
142 svn_fs_x__rev_file_get(apr_file_t **apr_file,
143 svn_fs_x__revision_file_t *file);
145 /* Set *STREAM to the shared L2P data stream of FILE.
148 svn_fs_x__rev_file_l2p_index(svn_fs_x__packed_number_stream_t **stream,
149 svn_fs_x__revision_file_t *file);
151 /* Set *STREAM to the shared P2L data stream of FILE.
154 svn_fs_x__rev_file_p2l_index(svn_fs_x__packed_number_stream_t **stream,
155 svn_fs_x__revision_file_t *file);
157 /* Copy the L2P index info for FILE into *INFO.
160 svn_fs_x__rev_file_l2p_info(svn_fs_x__index_info_t *info,
161 svn_fs_x__revision_file_t *file);
163 /* Copy the P2L index info for FILE into *INFO.
166 svn_fs_x__rev_file_p2l_info(svn_fs_x__index_info_t *info,
167 svn_fs_x__revision_file_t *file);
169 /* Set *SIZE to the length of the revision data in FILE.
172 svn_fs_x__rev_file_data_size(svn_filesize_t *size,
173 svn_fs_x__revision_file_t *file);
175 /* File manipulation. */
177 /* Convenience wrapper around svn_io_file_aligned_seek. */
179 svn_fs_x__rev_file_seek(svn_fs_x__revision_file_t *file,
180 apr_off_t *buffer_start,
183 /* Convenience wrapper around svn_fs_x__get_file_offset. */
185 svn_fs_x__rev_file_offset(apr_off_t *offset,
186 svn_fs_x__revision_file_t *file);
188 /* Convenience wrapper around svn_io_file_read_full2. */
190 svn_fs_x__rev_file_read(svn_fs_x__revision_file_t *file,
194 /* Close all files and streams in FILE. They will be reopened automatically
195 * by any of the above access functions.
198 svn_fs_x__close_revision_file(svn_fs_x__revision_file_t *file);