]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/subversion/subversion/libsvn_fs_fs/fs_fs.h
Upgrade to OpenSSH 7.6p1. This will be followed shortly by 7.7p1.
[FreeBSD/FreeBSD.git] / contrib / subversion / subversion / libsvn_fs_fs / fs_fs.h
1 /* fs_fs.h : interface to the native filesystem layer
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__FS_FS_H
24 #define SVN_LIBSVN_FS__FS_FS_H
25
26 #include "fs.h"
27
28 /* Read the 'format' file of fsfs filesystem FS and store its info in FS.
29  * Use SCRATCH_POOL for temporary allocations. */
30 svn_error_t *
31 svn_fs_fs__read_format_file(svn_fs_t *fs, apr_pool_t *scratch_pool);
32
33 /* Open the fsfs filesystem pointed to by PATH and associate it with
34    filesystem object FS.  Use POOL for temporary allocations.
35
36    ### Some parts of *FS must have been initialized beforehand; some parts
37        (including FS->path) are initialized by this function. */
38 svn_error_t *svn_fs_fs__open(svn_fs_t *fs,
39                              const char *path,
40                              apr_pool_t *pool);
41
42 /* Initialize parts of the FS data that are being shared across multiple
43    filesystem objects.  Use COMMON_POOL for process-wide and POOL for
44    temporary allocations.  Use COMMON_POOL_LOCK to ensure that the
45    initialization is serialized. */
46 svn_error_t *svn_fs_fs__initialize_shared_data(svn_fs_t *fs,
47                                                svn_mutex__t *common_pool_lock,
48                                                apr_pool_t *pool,
49                                                apr_pool_t *common_pool);
50
51 /* Upgrade the fsfs filesystem FS.  Indicate progress via the optional
52  * NOTIFY_FUNC callback using NOTIFY_BATON.  The optional CANCEL_FUNC
53  * will periodically be called with CANCEL_BATON to allow for preemption.
54  * Use POOL for temporary allocations. */
55 svn_error_t *svn_fs_fs__upgrade(svn_fs_t *fs,
56                                 svn_fs_upgrade_notify_t notify_func,
57                                 void *notify_baton,
58                                 svn_cancel_func_t cancel_func,
59                                 void *cancel_baton,
60                                 apr_pool_t *pool);
61
62 /* Set *YOUNGEST to the youngest revision in filesystem FS.  Do any
63    temporary allocation in POOL. */
64 svn_error_t *svn_fs_fs__youngest_rev(svn_revnum_t *youngest,
65                                      svn_fs_t *fs,
66                                      apr_pool_t *pool);
67
68 /* Return the shard size of filesystem FS.  Return 0 for non-shared ones. */
69 int
70 svn_fs_fs__shard_size(svn_fs_t *fs);
71
72 /* Set *MIN_UNPACKED to the oldest non-packed revision in filesystem FS.
73    Do any temporary allocation in POOL. */
74 svn_error_t *
75 svn_fs_fs__min_unpacked_rev(svn_revnum_t *min_unpacked,
76                             svn_fs_t *fs,
77                             apr_pool_t *pool);
78
79 /* Return SVN_ERR_FS_NO_SUCH_REVISION if the given revision REV is newer
80    than the current youngest revision in FS or is simply not a valid
81    revision number, else return success. */
82 svn_error_t *
83 svn_fs_fs__ensure_revision_exists(svn_revnum_t rev,
84                                   svn_fs_t *fs,
85                                   apr_pool_t *pool);
86
87 /* Set *LENGTH to the be fulltext length of the node revision
88    specified by NODEREV.  Use POOL for temporary allocations. */
89 svn_error_t *svn_fs_fs__file_length(svn_filesize_t *length,
90                                     node_revision_t *noderev,
91                                     apr_pool_t *pool);
92
93 /* Return TRUE if the representation keys in A and B both point to the
94    same representation, else return FALSE. */
95 svn_boolean_t svn_fs_fs__noderev_same_rep_key(representation_t *a,
96                                               representation_t *b);
97
98 /* Set *EQUAL to TRUE if the text representations in A and B within FS
99    have equal contents, else set it to FALSE.
100    Use SCRATCH_POOL for temporary allocations. */
101 svn_error_t *
102 svn_fs_fs__file_text_rep_equal(svn_boolean_t *equal,
103                                svn_fs_t *fs,
104                                node_revision_t *a,
105                                node_revision_t *b,
106                                apr_pool_t *scratch_pool);
107
108 /* Set *EQUAL to TRUE if the property representations in A and B within FS
109    have equal contents, else set it to FALSE.
110    Use SCRATCH_POOL for temporary allocations. */
111 svn_error_t *
112 svn_fs_fs__prop_rep_equal(svn_boolean_t *equal,
113                           svn_fs_t *fs,
114                           node_revision_t *a,
115                           node_revision_t *b,
116                           apr_pool_t *scratch_pool);
117
118
119 /* Return a copy of the representation REP allocated from POOL. */
120 representation_t *svn_fs_fs__rep_copy(representation_t *rep,
121                                       apr_pool_t *pool);
122
123
124 /* Return the recorded checksum of type KIND for the text representation
125    of NODREV into CHECKSUM, allocating from POOL.  If no stored checksum is
126    available, put all NULL into CHECKSUM. */
127 svn_error_t *svn_fs_fs__file_checksum(svn_checksum_t **checksum,
128                                       node_revision_t *noderev,
129                                       svn_checksum_kind_t kind,
130                                       apr_pool_t *pool);
131
132 /* Return whether or not the given FS supports mergeinfo metadata. */
133 svn_boolean_t svn_fs_fs__fs_supports_mergeinfo(svn_fs_t *fs);
134
135 /* Under the repository db PATH, create a FSFS repository with FORMAT,
136  * the given SHARD_SIZE. If USE_LOG_ADDRESSING is non-zero, repository
137  * will use logical addressing. If not supported by the respective format,
138  * the latter two parameters will be ignored. FS will be updated.
139  *
140  * The only file not being written is the 'format' file.  This allows
141  * callers such as hotcopy to modify the contents before turning the
142  * tree into an accessible repository.
143  *
144  * Use POOL for temporary allocations.
145  */
146 svn_error_t *
147 svn_fs_fs__create_file_tree(svn_fs_t *fs,
148                             const char *path,
149                             int format,
150                             int shard_size,
151                             svn_boolean_t use_log_addressing,
152                             apr_pool_t *pool);
153
154 /* Create a fs_fs fileysystem referenced by FS at path PATH.  Get any
155    temporary allocations from POOL.
156
157    ### Some parts of *FS must have been initialized beforehand; some parts
158        (including FS->path) are initialized by this function. */
159 svn_error_t *svn_fs_fs__create(svn_fs_t *fs,
160                                const char *path,
161                                apr_pool_t *pool);
162
163 /* Set the uuid of repository FS to UUID and the instance ID to INSTANCE_ID.
164    If any of them is NULL, use a newly generated UUID / ID instead.  Ignore
165    INSTANCE_ID whenever instance IDs are not supported by the FS format.
166    Perform temporary allocations in POOL. */
167 svn_error_t *svn_fs_fs__set_uuid(svn_fs_t *fs,
168                                  const char *uuid,
169                                  const char *instance_id,
170                                  apr_pool_t *pool);
171
172 /* Return the path to the 'current' file in FS.
173    Perform allocation in POOL. */
174 const char *
175 svn_fs_fs__path_current(svn_fs_t *fs, apr_pool_t *pool);
176
177 /* Write the format number and maximum number of files per directory
178    for FS, possibly expecting to overwrite a previously existing file.
179
180    Use POOL for temporary allocation. */
181 svn_error_t *
182 svn_fs_fs__write_format(svn_fs_t *fs,
183                         svn_boolean_t overwrite,
184                         apr_pool_t *pool);
185
186 /* Obtain a write lock on the filesystem FS in a subpool of POOL, call
187    BODY with BATON and that subpool, destroy the subpool (releasing the write
188    lock) and return what BODY returned. */
189 svn_error_t *
190 svn_fs_fs__with_write_lock(svn_fs_t *fs,
191                            svn_error_t *(*body)(void *baton,
192                                                 apr_pool_t *pool),
193                            void *baton,
194                            apr_pool_t *pool);
195
196 /* Obtain a pack operation lock on the filesystem FS in a subpool of POOL,
197    call BODY with BATON and that subpool, destroy the subpool (releasing the
198    write lock) and return what BODY returned. */
199 svn_error_t *
200 svn_fs_fs__with_pack_lock(svn_fs_t *fs,
201                           svn_error_t *(*body)(void *baton,
202                                                apr_pool_t *pool),
203                           void *baton,
204                           apr_pool_t *pool);
205
206 /* Run BODY (with BATON and POOL) while the txn-current file
207    of FS is locked. */
208 svn_error_t *
209 svn_fs_fs__with_txn_current_lock(svn_fs_t *fs,
210                                  svn_error_t *(*body)(void *baton,
211                                                       apr_pool_t *pool),
212                                  void *baton,
213                                  apr_pool_t *pool);
214
215 /* Obtain all locks on the filesystem FS in a subpool of POOL, call BODY
216    with BATON and that subpool, destroy the subpool (releasing the locks)
217    and return what BODY returned.
218
219    This combines svn_fs_fs__with_write_lock, svn_fs_fs__with_pack_lock,
220    and svn_fs_fs__with_txn_current_lock, ensuring correct lock ordering. */
221 svn_error_t *
222 svn_fs_fs__with_all_locks(svn_fs_t *fs,
223                           svn_error_t *(*body)(void *baton,
224                                                apr_pool_t *pool),
225                           void *baton,
226                           apr_pool_t *pool);
227
228 /* Find the value of the property named PROPNAME in revision REV.
229    Return the contents in *VALUE_P.  The contents will be allocated
230    from RESULT_POOL and SCRATCH_POOL is used for temporaries.
231    Invalidate any revprop cache is REFRESH is set. */
232 svn_error_t *svn_fs_fs__revision_prop(svn_string_t **value_p, svn_fs_t *fs,
233                                       svn_revnum_t rev,
234                                       const char *propname,
235                                       svn_boolean_t refresh,
236                                       apr_pool_t *result_pool,
237                                       apr_pool_t *scratch_pool);
238
239 /* Change, add, or delete a property on a revision REV in filesystem
240    FS.  NAME gives the name of the property, and value, if non-NULL,
241    gives the new contents of the property.  If value is NULL, then the
242    property will be deleted.  If OLD_VALUE_P is not NULL, do nothing unless the
243    preexisting value is *OLD_VALUE_P.  Do any temporary allocation in POOL.  */
244 svn_error_t *svn_fs_fs__change_rev_prop(svn_fs_t *fs, svn_revnum_t rev,
245                                         const char *name,
246                                         const svn_string_t *const *old_value_p,
247                                         const svn_string_t *value,
248                                         apr_pool_t *pool);
249
250 /* If directory PATH does not exist, create it and give it the same
251    permissions as FS_PATH.*/
252 svn_error_t *svn_fs_fs__ensure_dir_exists(const char *path,
253                                           const char *fs_path,
254                                           apr_pool_t *pool);
255
256 /* Update the node origin index for FS, recording the mapping from
257    NODE_ID to NODE_REV_ID.  Use POOL for any temporary allocations.
258
259    Because this is just an "optional" cache, this function does not
260    return an error if the underlying storage is readonly; it still
261    returns an error for other error conditions.
262  */
263 svn_error_t *
264 svn_fs_fs__set_node_origin(svn_fs_t *fs,
265                            const svn_fs_fs__id_part_t *node_id,
266                            const svn_fs_id_t *node_rev_id,
267                            apr_pool_t *pool);
268
269 /* Set *ORIGIN_ID to the node revision ID from which the history of
270    all nodes in FS whose "Node ID" is NODE_ID springs, as determined
271    by a look in the index.  ORIGIN_ID needs to be parsed in an
272    FS-backend-specific way.  Use POOL for allocations.
273
274    If there is no entry for NODE_ID in the cache, return NULL
275    in *ORIGIN_ID. */
276 svn_error_t *
277 svn_fs_fs__get_node_origin(const svn_fs_id_t **origin_id,
278                            svn_fs_t *fs,
279                            const svn_fs_fs__id_part_t *node_id,
280                            apr_pool_t *pool);
281
282
283 /* Initialize all session-local caches in FS according to the global
284    cache settings. Use POOL for temporary allocations.
285
286    Please note that it is permissible for this function to set some
287    or all of these caches to NULL, regardless of any setting. */
288 svn_error_t *
289 svn_fs_fs__initialize_caches(svn_fs_t *fs, apr_pool_t *pool);
290
291 /* Initialize all transaction-local caches in FS according to the global
292    cache settings and make TXN_ID part of their key space. Use POOL for
293    allocations.
294
295    Please note that it is permissible for this function to set some or all
296    of these caches to NULL, regardless of any setting. */
297 svn_error_t *
298 svn_fs_fs__initialize_txn_caches(svn_fs_t *fs,
299                                  const char *txn_id,
300                                  apr_pool_t *pool);
301
302 /* Resets the svn_cache__t structures local to the current transaction in FS.
303    Calling it more than once per txn or from outside any txn is allowed. */
304 void
305 svn_fs_fs__reset_txn_caches(svn_fs_t *fs);
306
307 #endif