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