1 /* fs_fs.h : interface to the native filesystem layer
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__FS_FS_H
24 #define SVN_LIBSVN_FS__FS_FS_H
28 /* Read the 'format' file of fsfs filesystem FS and store its info in FS.
29 * Use SCRATCH_POOL for temporary allocations. */
31 svn_fs_fs__read_format_file(svn_fs_t *fs, apr_pool_t *scratch_pool);
33 /* Open the fsfs filesystem pointed to by PATH and associate it with
34 filesystem object FS. Use POOL for temporary allocations.
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,
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,
49 svn_cancel_func_t cancel_func,
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,
59 /* Return the shard size of filesystem FS. Return 0 for non-shared ones. */
61 svn_fs_fs__shard_size(svn_fs_t *fs);
63 /* Set *MIN_UNPACKED to the oldest non-packed revision in filesystem FS.
64 Do any temporary allocation in POOL. */
66 svn_fs_fs__min_unpacked_rev(svn_revnum_t *min_unpacked,
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. */
74 svn_fs_fs__ensure_revision_exists(svn_revnum_t rev,
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,
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,
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. */
93 svn_fs_fs__file_text_rep_equal(svn_boolean_t *equal,
97 apr_pool_t *scratch_pool);
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. */
103 svn_fs_fs__prop_rep_equal(svn_boolean_t *equal,
107 apr_pool_t *scratch_pool);
110 /* Return a copy of the representation REP allocated from POOL. */
111 representation_t *svn_fs_fs__rep_copy(representation_t *rep,
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,
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);
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.
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.
135 * Use POOL for temporary allocations.
138 svn_fs_fs__create_file_tree(svn_fs_t *fs,
142 svn_boolean_t use_log_addressing,
145 /* Create a fs_fs fileysystem referenced by FS at path PATH. Get any
146 temporary allocations from POOL.
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,
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,
160 const char *instance_id,
163 /* Return the path to the 'current' file in FS.
164 Perform allocation in POOL. */
166 svn_fs_fs__path_current(svn_fs_t *fs, apr_pool_t *pool);
168 /* Write the format number and maximum number of files per directory
169 for FS, possibly expecting to overwrite a previously existing file.
171 Use POOL for temporary allocation. */
173 svn_fs_fs__write_format(svn_fs_t *fs,
174 svn_boolean_t overwrite,
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. */
181 svn_fs_fs__with_write_lock(svn_fs_t *fs,
182 svn_error_t *(*body)(void *baton,
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. */
191 svn_fs_fs__with_pack_lock(svn_fs_t *fs,
192 svn_error_t *(*body)(void *baton,
197 /* Run BODY (with BATON and POOL) while the txn-current file
200 svn_fs_fs__with_txn_current_lock(svn_fs_t *fs,
201 svn_error_t *(*body)(void *baton,
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.
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. */
213 svn_fs_fs__with_all_locks(svn_fs_t *fs,
214 svn_error_t *(*body)(void *baton,
219 /* Find the value of the property named PROPNAME in transaction TXN.
220 Return the contents in *VALUE_P. The contents will be allocated
222 svn_error_t *svn_fs_fs__revision_prop(svn_string_t **value_p, svn_fs_t *fs,
224 const char *propname,
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,
234 const svn_string_t *const *old_value_p,
235 const svn_string_t *value,
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,
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.
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.
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,
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.
262 If there is no entry for NODE_ID in the cache, return NULL
265 svn_fs_fs__get_node_origin(const svn_fs_id_t **origin_id,
267 const svn_fs_fs__id_part_t *node_id,
271 /* Initialize all session-local caches in FS according to the global
272 cache settings. Use POOL for temporary allocations.
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. */
277 svn_fs_fs__initialize_caches(svn_fs_t *fs, apr_pool_t *pool);
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
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. */
286 svn_fs_fs__initialize_txn_caches(svn_fs_t *fs,
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. */
293 svn_fs_fs__reset_txn_caches(svn_fs_t *fs);