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 /* Open the fsfs filesystem pointed to by PATH and associate it with
29 filesystem object FS. Use POOL for temporary allocations.
31 ### Some parts of *FS must have been initialized beforehand; some parts
32 (including FS->path) are initialized by this function. */
33 svn_error_t *svn_fs_fs__open(svn_fs_t *fs,
37 /* Upgrade the fsfs filesystem FS. Use POOL for temporary allocations. */
38 svn_error_t *svn_fs_fs__upgrade(svn_fs_t *fs,
41 /* Verify metadata in fsfs filesystem FS. Limit the checks to revisions
42 * START to END where possible. 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__verify(svn_fs_t *fs,
49 svn_fs_progress_notify_func_t notify_func,
51 svn_cancel_func_t cancel_func,
55 /* Copy the fsfs filesystem SRC_FS at SRC_PATH into a new copy DST_FS at
56 * DST_PATH. If INCREMENTAL is TRUE, do not re-copy data which already
57 * exists in DST_FS. Use POOL for temporary allocations. */
58 svn_error_t * svn_fs_fs__hotcopy(svn_fs_t *src_fs,
62 svn_boolean_t incremental,
63 svn_cancel_func_t cancel_func,
67 /* Recover the fsfs associated with filesystem FS.
68 Use optional CANCEL_FUNC/CANCEL_BATON for cancellation support.
69 Use POOL for temporary allocations. */
70 svn_error_t *svn_fs_fs__recover(svn_fs_t *fs,
71 svn_cancel_func_t cancel_func,
75 /* Set *NODEREV_P to the node-revision for the node ID in FS. Do any
76 allocations in POOL. */
77 svn_error_t *svn_fs_fs__get_node_revision(node_revision_t **noderev_p,
79 const svn_fs_id_t *id,
82 /* Store NODEREV as the node-revision for the node whose id is ID in
83 FS, after setting its is_fresh_txn_root to FRESH_TXN_ROOT. Do any
84 necessary temporary allocation in POOL. */
85 svn_error_t *svn_fs_fs__put_node_revision(svn_fs_t *fs,
86 const svn_fs_id_t *id,
87 node_revision_t *noderev,
88 svn_boolean_t fresh_txn_root,
91 /* Write the node-revision NODEREV into the stream OUTFILE, compatible with
92 filesystem format FORMAT. Only write mergeinfo-related metadata if
93 INCLUDE_MERGEINFO is true. Temporary allocations are from POOL. */
94 /* ### Currently used only by fs_fs.c */
96 svn_fs_fs__write_noderev(svn_stream_t *outfile,
97 node_revision_t *noderev,
99 svn_boolean_t include_mergeinfo,
102 /* Read a node-revision from STREAM. Set *NODEREV to the new structure,
103 allocated in POOL. */
104 /* ### Currently used only by fs_fs.c */
106 svn_fs_fs__read_noderev(node_revision_t **noderev,
107 svn_stream_t *stream,
111 /* Set *YOUNGEST to the youngest revision in filesystem FS. Do any
112 temporary allocation in POOL. */
113 svn_error_t *svn_fs_fs__youngest_rev(svn_revnum_t *youngest,
117 /* Return an error iff REV does not exist in FS. */
119 svn_fs_fs__revision_exists(svn_revnum_t rev,
123 /* Set *ROOT_ID to the node-id for the root of revision REV in
124 filesystem FS. Do any allocations in POOL. */
125 svn_error_t *svn_fs_fs__rev_get_root(svn_fs_id_t **root_id,
130 /* Set *ENTRIES to an apr_hash_t of dirent structs that contain the
131 directory entries of node-revision NODEREV in filesystem FS. The
132 returned table (and its keys and values) is allocated in POOL,
133 which is also used for temporary allocations. */
134 svn_error_t *svn_fs_fs__rep_contents_dir(apr_hash_t **entries,
136 node_revision_t *noderev,
139 /* Set *DIRENT to the entry identified by NAME in the directory given
140 by NODEREV in filesystem FS. If no such entry exits, *DIRENT will
141 be NULL. The returned object is allocated in RESULT_POOL; SCRATCH_POOL
142 used for temporary allocations. */
144 svn_fs_fs__rep_contents_dir_entry(svn_fs_dirent_t **dirent,
146 node_revision_t *noderev,
148 apr_pool_t *result_pool,
149 apr_pool_t *scratch_pool);
151 /* Set *CONTENTS to be a readable svn_stream_t that receives the text
152 representation of node-revision NODEREV as seen in filesystem FS.
153 Use POOL for temporary allocations. */
154 svn_error_t *svn_fs_fs__get_contents(svn_stream_t **contents,
156 node_revision_t *noderev,
159 /* Attempt to fetch the text representation of node-revision NODEREV as
160 seen in filesystem FS and pass it along with the BATON to the PROCESSOR.
161 Set *SUCCESS only of the data could be provided and the processing
163 Use POOL for all allocations.
166 svn_fs_fs__try_process_file_contents(svn_boolean_t *success,
168 node_revision_t *noderev,
169 svn_fs_process_contents_func_t processor,
173 /* Set *STREAM_P to a delta stream turning the contents of the file SOURCE into
174 the contents of the file TARGET, allocated in POOL.
175 If SOURCE is null, the empty string will be used. */
176 svn_error_t *svn_fs_fs__get_file_delta_stream(svn_txdelta_stream_t **stream_p,
178 node_revision_t *source,
179 node_revision_t *target,
182 /* Set *PROPLIST to be an apr_hash_t containing the property list of
183 node-revision NODEREV as seen in filesystem FS. Use POOL for
184 temporary allocations. */
185 svn_error_t *svn_fs_fs__get_proplist(apr_hash_t **proplist,
187 node_revision_t *noderev,
190 /* Set *PROPLIST to be an apr_hash_t containing the property list of
191 revision REV as seen in filesystem FS. Use POOL for temporary
193 svn_error_t *svn_fs_fs__revision_proplist(apr_hash_t **proplist,
198 /* Set *LENGTH to the be fulltext length of the node revision
199 specified by NODEREV. Use POOL for temporary allocations. */
200 svn_error_t *svn_fs_fs__file_length(svn_filesize_t *length,
201 node_revision_t *noderev,
204 /* Return TRUE if the representation keys in A and B both point to the
205 same representation, else return FALSE. */
206 svn_boolean_t svn_fs_fs__noderev_same_rep_key(representation_t *a,
207 representation_t *b);
210 /* Return a copy of the representation REP allocated from POOL. */
211 representation_t *svn_fs_fs__rep_copy(representation_t *rep,
215 /* Return the recorded checksum of type KIND for the text representation
216 of NODREV into CHECKSUM, allocating from POOL. If no stored checksum is
217 available, put all NULL into CHECKSUM. */
218 svn_error_t *svn_fs_fs__file_checksum(svn_checksum_t **checksum,
219 node_revision_t *noderev,
220 svn_checksum_kind_t kind,
223 /* Find the paths which were changed in revision REV of filesystem FS
224 and store them in *CHANGED_PATHS_P. Cached copyfrom information
225 will be stored in *COPYFROM_CACHE. Get any temporary allocations
227 svn_error_t *svn_fs_fs__paths_changed(apr_hash_t **changed_paths_p,
230 apr_hash_t *copyfrom_cache,
233 /* Create a new transaction in filesystem FS, based on revision REV,
234 and store it in *TXN_P. Allocate all necessary variables from
236 svn_error_t *svn_fs_fs__create_txn(svn_fs_txn_t **txn_p,
241 /* Set the transaction property NAME to the value VALUE in transaction
242 TXN. Perform temporary allocations from POOL. */
243 svn_error_t *svn_fs_fs__change_txn_prop(svn_fs_txn_t *txn,
245 const svn_string_t *value,
248 /* Change transaction properties in transaction TXN based on PROPS.
249 Perform temporary allocations from POOL. */
250 svn_error_t *svn_fs_fs__change_txn_props(svn_fs_txn_t *txn,
251 const apr_array_header_t *props,
254 /* Return whether or not the given FS supports mergeinfo metadata. */
255 svn_boolean_t svn_fs_fs__fs_supports_mergeinfo(svn_fs_t *fs);
257 /* Store a transaction record in *TXN_P for the transaction identified
258 by TXN_ID in filesystem FS. Allocate everything from POOL. */
259 svn_error_t *svn_fs_fs__get_txn(transaction_t **txn_p,
264 /* Abort the existing transaction TXN, performing any temporary
265 allocations in POOL. */
266 svn_error_t *svn_fs_fs__abort_txn(svn_fs_txn_t *txn, apr_pool_t *pool);
268 /* Create an entirely new mutable node in the filesystem FS, whose
269 node-revision is NODEREV. Set *ID_P to the new node revision's ID.
270 Use POOL for any temporary allocation. COPY_ID is the copy_id to
271 use in the node revision ID. TXN_ID is the Subversion transaction
272 under which this occurs. */
273 svn_error_t *svn_fs_fs__create_node(const svn_fs_id_t **id_p,
275 node_revision_t *noderev,
280 /* Remove all references to the transaction TXN_ID from filesystem FS.
281 Temporary allocations are from POOL. */
282 svn_error_t *svn_fs_fs__purge_txn(svn_fs_t *fs,
286 /* Add or set in filesystem FS, transaction TXN_ID, in directory
287 PARENT_NODEREV a directory entry for NAME pointing to ID of type
288 KIND. Allocations are done in POOL. */
289 svn_error_t *svn_fs_fs__set_entry(svn_fs_t *fs,
291 node_revision_t *parent_noderev,
293 const svn_fs_id_t *id,
294 svn_node_kind_t kind,
297 /* Add a change to the changes record for filesystem FS in transaction
298 TXN_ID. Mark path PATH, having node-id ID, as changed according to
299 the type in CHANGE_KIND. If the text representation was changed
300 set TEXT_MOD to TRUE, and likewise for PROP_MOD. If this change
301 was the result of a copy, set COPYFROM_REV and COPYFROM_PATH to the
302 revision and path of the copy source, otherwise they should be set
303 to SVN_INVALID_REVNUM and NULL. Perform any temporary allocations
305 svn_error_t *svn_fs_fs__add_change(svn_fs_t *fs,
308 const svn_fs_id_t *id,
309 svn_fs_path_change_kind_t change_kind,
310 svn_boolean_t text_mod,
311 svn_boolean_t prop_mod,
312 svn_node_kind_t node_kind,
313 svn_revnum_t copyfrom_rev,
314 const char *copyfrom_path,
317 /* Return a writable stream in *STREAM that allows storing the text
318 representation of node-revision NODEREV in filesystem FS.
319 Allocations are from POOL. */
320 svn_error_t *svn_fs_fs__set_contents(svn_stream_t **stream,
322 node_revision_t *noderev,
325 /* Create a node revision in FS which is an immediate successor of
326 OLD_ID, whose contents are NEW_NR. Set *NEW_ID_P to the new node
327 revision's ID. Use POOL for any temporary allocation.
329 COPY_ID, if non-NULL, is a key into the `copies' table, and
330 indicates that this new node is being created as the result of a
331 copy operation, and specifically which operation that was. If
332 COPY_ID is NULL, then re-use the copy ID from the predecessor node.
334 TXN_ID is the Subversion transaction under which this occurs.
336 After this call, the deltification code assumes that the new node's
337 contents will change frequently, and will avoid representing other
338 nodes as deltas against this node's contents. */
339 svn_error_t *svn_fs_fs__create_successor(const svn_fs_id_t **new_id_p,
341 const svn_fs_id_t *old_idp,
342 node_revision_t *new_noderev,
347 /* Write a new property list PROPLIST for node-revision NODEREV in
348 filesystem FS. Perform any temporary allocations in POOL. */
349 svn_error_t *svn_fs_fs__set_proplist(svn_fs_t *fs,
350 node_revision_t *noderev,
351 apr_hash_t *proplist,
354 /* Commit the transaction TXN in filesystem FS and return its new
355 revision number in *REV. If the transaction is out of date, return
356 the error SVN_ERR_FS_TXN_OUT_OF_DATE. Use POOL for temporary
358 svn_error_t *svn_fs_fs__commit(svn_revnum_t *new_rev_p,
363 /* Return the next available copy_id in *COPY_ID for the transaction
364 TXN_ID in filesystem FS. Allocate space in POOL. */
365 svn_error_t *svn_fs_fs__reserve_copy_id(const char **copy_id,
370 /* Create a fs_fs fileysystem referenced by FS at path PATH. Get any
371 temporary allocations from POOL.
373 ### Some parts of *FS must have been initialized beforehand; some parts
374 (including FS->path) are initialized by this function. */
375 svn_error_t *svn_fs_fs__create(svn_fs_t *fs,
379 /* Set the uuid of repository FS to UUID, if UUID is not NULL;
380 otherwise, set the uuid of FS to a newly generated UUID. Perform
381 temporary allocations in POOL. */
382 svn_error_t *svn_fs_fs__set_uuid(svn_fs_t *fs,
386 /* Set *NAMES_P to an array of names which are all the active
387 transactions in filesystem FS. Allocate the array from POOL. */
388 svn_error_t *svn_fs_fs__list_transactions(apr_array_header_t **names_p,
392 /* Open the transaction named NAME in filesystem FS. Set *TXN_P to
393 * the transaction. If there is no such transaction, return
394 ` * SVN_ERR_FS_NO_SUCH_TRANSACTION. Allocate the new transaction in
396 svn_error_t *svn_fs_fs__open_txn(svn_fs_txn_t **txn_p,
401 /* Return the property list from transaction TXN and store it in
402 *PROPLIST. Allocate the property list from POOL. */
403 svn_error_t *svn_fs_fs__txn_proplist(apr_hash_t **proplist,
407 /* Delete the mutable node-revision referenced by ID, along with any
408 mutable props or directory contents associated with it. Perform
409 temporary allocations in POOL. */
410 svn_error_t *svn_fs_fs__delete_node_revision(svn_fs_t *fs,
411 const svn_fs_id_t *id,
415 /* Find the paths which were changed in transaction TXN_ID of
416 filesystem FS and store them in *CHANGED_PATHS_P.
417 Get any temporary allocations from POOL. */
418 svn_error_t *svn_fs_fs__txn_changes_fetch(apr_hash_t **changes,
424 /* Set *PATH to the path of REV in FS, whether in a pack file or not.
425 Allocate *PATH in POOL.
427 Note: If the caller does not have the write lock on FS, then the path is
428 not guaranteed to be correct or to remain correct after the function
429 returns, because the revision might become packed before or after this
430 call. If a file exists at that path, then it is correct; if not, then
431 the caller should call update_min_unpacked_rev() and re-try once. */
433 svn_fs_fs__path_rev_absolute(const char **path,
438 /* Return the path to the 'current' file in FS.
439 Perform allocation in POOL. */
441 svn_fs_fs__path_current(svn_fs_t *fs, apr_pool_t *pool);
443 /* Obtain a write lock on the filesystem FS in a subpool of POOL, call
444 BODY with BATON and that subpool, destroy the subpool (releasing the write
445 lock) and return what BODY returned. */
447 svn_fs_fs__with_write_lock(svn_fs_t *fs,
448 svn_error_t *(*body)(void *baton,
453 /* Find the value of the property named PROPNAME in transaction TXN.
454 Return the contents in *VALUE_P. The contents will be allocated
456 svn_error_t *svn_fs_fs__revision_prop(svn_string_t **value_p, svn_fs_t *fs,
458 const char *propname,
461 /* Change, add, or delete a property on a revision REV in filesystem
462 FS. NAME gives the name of the property, and value, if non-NULL,
463 gives the new contents of the property. If value is NULL, then the
464 property will be deleted. If OLD_VALUE_P is not NULL, do nothing unless the
465 preexisting value is *OLD_VALUE_P. Do any temporary allocation in POOL. */
466 svn_error_t *svn_fs_fs__change_rev_prop(svn_fs_t *fs, svn_revnum_t rev,
468 const svn_string_t *const *old_value_p,
469 const svn_string_t *value,
472 /* Retrieve information about the Subversion transaction SVN_TXN from
473 the `transactions' table of FS, allocating from POOL. Set
474 *ROOT_ID_P to the ID of the transaction's root directory. Set
475 *BASE_ROOT_ID_P to the ID of the root directory of the
476 transaction's base revision.
478 If there is no such transaction, SVN_ERR_FS_NO_SUCH_TRANSACTION is
481 Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
482 transaction that has already been committed.
484 Allocate *ROOT_ID_P and *BASE_ROOT_ID_P in POOL. */
485 svn_error_t *svn_fs_fs__get_txn_ids(const svn_fs_id_t **root_id_p,
486 const svn_fs_id_t **base_root_id_p,
488 const char *txn_name,
491 /* Begin a new transaction in filesystem FS, based on existing
492 revision REV. The new transaction is returned in *TXN_P. Allocate
493 the new transaction structure from POOL. */
494 svn_error_t *svn_fs_fs__begin_txn(svn_fs_txn_t **txn_p, svn_fs_t *fs,
495 svn_revnum_t rev, apr_uint32_t flags,
498 /* Find the value of the property named PROPNAME in transaction TXN.
499 Return the contents in *VALUE_P. The contents will be allocated
501 svn_error_t *svn_fs_fs__txn_prop(svn_string_t **value_p, svn_fs_txn_t *txn,
502 const char *propname, apr_pool_t *pool);
504 /* If directory PATH does not exist, create it and give it the same
505 permissions as FS_PATH.*/
506 svn_error_t *svn_fs_fs__ensure_dir_exists(const char *path,
510 /* Update the node origin index for FS, recording the mapping from
511 NODE_ID to NODE_REV_ID. Use POOL for any temporary allocations.
513 Because this is just an "optional" cache, this function does not
514 return an error if the underlying storage is readonly; it still
515 returns an error for other error conditions.
518 svn_fs_fs__set_node_origin(svn_fs_t *fs,
520 const svn_fs_id_t *node_rev_id,
523 /* Set *ORIGIN_ID to the node revision ID from which the history of
524 all nodes in FS whose "Node ID" is NODE_ID springs, as determined
525 by a look in the index. ORIGIN_ID needs to be parsed in an
526 FS-backend-specific way. Use POOL for allocations.
528 If there is no entry for NODE_ID in the cache, return NULL
531 svn_fs_fs__get_node_origin(const svn_fs_id_t **origin_id,
537 /* Initialize all session-local caches in FS according to the global
538 cache settings. Use POOL for allocations.
540 Please note that it is permissible for this function to set some
541 or all of these caches to NULL, regardless of any setting. */
543 svn_fs_fs__initialize_caches(svn_fs_t *fs, apr_pool_t *pool);
545 /* Initialize all transaction-local caches in FS according to the global
546 cache settings and make TXN_ID part of their key space. Use POOL for
549 Please note that it is permissible for this function to set some or all
550 of these caches to NULL, regardless of any setting. */
552 svn_fs_fs__initialize_txn_caches(svn_fs_t *fs,
556 /* Resets the svn_cache__t structures local to the current transaction in FS.
557 Calling it more than once per txn or from outside any txn is allowed. */
559 svn_fs_fs__reset_txn_caches(svn_fs_t *fs);
561 /* Possibly pack the repository at PATH. This just take full shards, and
562 combines all the revision files into a single one, with a manifest header.
563 Use optional CANCEL_FUNC/CANCEL_BATON for cancellation support.
565 Existing filesystem references need not change. */
567 svn_fs_fs__pack(svn_fs_t *fs,
568 svn_fs_pack_notify_t notify_func,
570 svn_cancel_func_t cancel_func,