1 /* fs_fs.h : interface to the native filesystem layer
3 * ====================================================================
4 * Copyright (c) 2000-2007 CollabNet. All rights reserved.
6 * This software is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at http://subversion.tigris.org/license-1.html.
9 * If newer versions of this license are posted there, you may use a
10 * newer version instead, at your option.
12 * This software consists of voluntary contributions made by many
13 * individuals. For exact contribution history, see the revision
14 * history and logs, available at http://subversion.tigris.org/.
15 * ====================================================================
18 #ifndef SVN_LIBSVN_FS__FS_FS_H
19 #define SVN_LIBSVN_FS__FS_FS_H
23 /* Open the fsfs filesystem pointed to by PATH and associate it with
24 filesystem object FS. Use POOL for temporary allocations. */
25 svn_error_t
*svn_fs_fs__open(svn_fs_t
*fs
,
29 /* Upgrade the fsfs filesystem FS. Use POOL for temporary allocations. */
30 svn_error_t
*svn_fs_fs__upgrade(svn_fs_t
*fs
,
33 /* Copy the fsfs filesystem at SRC_PATH into a new copy at DST_PATH.
34 Use POOL for temporary allocations. */
35 svn_error_t
*svn_fs_fs__hotcopy(const char *src_path
,
39 /* Recover the fsfs associated with filesystem FS.
40 Use optional CANCEL_FUNC/CANCEL_BATON for cancellation support.
41 Use POOL for temporary allocations. */
42 svn_error_t
*svn_fs_fs__recover(svn_fs_t
*fs
,
43 svn_cancel_func_t cancel_func
,
47 /* Set *NODEREV_P to the node-revision for the node ID in FS. Do any
48 allocations in POOL. */
49 svn_error_t
*svn_fs_fs__get_node_revision(node_revision_t
**noderev_p
,
51 const svn_fs_id_t
*id
,
54 /* Store NODEREV as the node-revision for the node whose id is ID in
55 FS, after setting its is_fresh_txn_root to FRESH_TXN_ROOT. Do any
56 necessary temporary allocation in POOL. */
57 svn_error_t
*svn_fs_fs__put_node_revision(svn_fs_t
*fs
,
58 const svn_fs_id_t
*id
,
59 node_revision_t
*noderev
,
60 svn_boolean_t fresh_txn_root
,
63 /* Set *YOUNGEST to the youngest revision in filesystem FS. Do any
64 temporary allocation in POOL. */
65 svn_error_t
*svn_fs_fs__youngest_rev(svn_revnum_t
*youngest
,
69 /* Set *ROOT_ID to the node-id for the root of revision REV in
70 filesystem FS. Do any allocations in POOL. */
71 svn_error_t
*svn_fs_fs__rev_get_root(svn_fs_id_t
**root_id
,
76 /* Set *ENTRIES to an apr_hash_t of dirent structs that contain the
77 directory entries of node-revision NODEREV in filesystem FS. The
78 returned table (and its keys and values) is allocated in POOL,
79 which is also used for temporary allocations. */
80 svn_error_t
*svn_fs_fs__rep_contents_dir(apr_hash_t
**entries
,
82 node_revision_t
*noderev
,
85 /* Set *CONTENTS to be a readable svn_stream_t that receives the text
86 representation of node-revision NODEREV as seen in filesystem FS.
87 Use POOL for temporary allocations. */
88 svn_error_t
*svn_fs_fs__get_contents(svn_stream_t
**contents
,
90 node_revision_t
*noderev
,
93 /* Set *STREAM_P to a delta stream turning the contents of the file SOURCE into
94 the contents of the file TARGET, allocated in POOL.
95 If SOURCE is null, the empty string will be used. */
96 svn_error_t
*svn_fs_fs__get_file_delta_stream(svn_txdelta_stream_t
**stream_p
,
98 node_revision_t
*source
,
99 node_revision_t
*target
,
102 /* Set *PROPLIST to be an apr_hash_t containing the property list of
103 node-revision NODEREV as seen in filesystem FS. Use POOL for
104 temporary allocations. */
105 svn_error_t
*svn_fs_fs__get_proplist(apr_hash_t
**proplist
,
107 node_revision_t
*noderev
,
110 /* Set the revision property list of revision REV in filesystem FS to
111 PROPLIST. Use POOL for temporary allocations. */
112 svn_error_t
*svn_fs_fs__set_revision_proplist(svn_fs_t
*fs
,
114 apr_hash_t
*proplist
,
117 /* Set *PROPLIST to be an apr_hash_t containing the property list of
118 revision REV as seen in filesystem FS. Use POOL for temporary
120 svn_error_t
*svn_fs_fs__revision_proplist(apr_hash_t
**proplist
,
125 /* Set *LENGTH to the be fulltext length of the node revision
126 specified by NODEREV. Use POOL for temporary allocations. */
127 svn_error_t
*svn_fs_fs__file_length(svn_filesize_t
*length
,
128 node_revision_t
*noderev
,
131 /* Return TRUE if the representation keys in A and B both point to the
132 same representation, else return FALSE. */
133 svn_boolean_t
svn_fs_fs__noderev_same_rep_key(representation_t
*a
,
134 representation_t
*b
);
137 /* Return a copy of the representation REP allocated from POOL. */
138 representation_t
*svn_fs_fs__rep_copy(representation_t
*rep
,
142 /* Return the record MD5 checksum of the text representation of NODREV
143 into DIGEST, allocating from POOL. If no stored checksum is
144 available, put all 0's into DIGEST. */
145 svn_error_t
*svn_fs_fs__file_checksum(unsigned char digest
[],
146 node_revision_t
*noderev
,
149 /* Find the paths which were changed in revision REV of filesystem FS
150 and store them in *CHANGED_PATHS_P. Cached copyfrom information
151 will be stored in *COPYFROM_CACHE. Get any temporary allocations
153 svn_error_t
*svn_fs_fs__paths_changed(apr_hash_t
**changed_paths_p
,
156 apr_hash_t
*copyfrom_cache
,
159 /* Create a new transaction in filesystem FS, based on revision REV,
160 and store it in *TXN_P. Allocate all necessary variables from
162 svn_error_t
*svn_fs_fs__create_txn(svn_fs_txn_t
**txn_p
,
167 /* Set the transaction property NAME to the value VALUE in transaction
168 TXN. Perform temporary allocations from POOL. */
169 svn_error_t
*svn_fs_fs__change_txn_prop(svn_fs_txn_t
*txn
,
171 const svn_string_t
*value
,
174 /* Change transaction properties in transaction TXN based on PROPS.
175 Perform temporary allocations from POOL. */
176 svn_error_t
*svn_fs_fs__change_txn_props(svn_fs_txn_t
*txn
,
177 apr_array_header_t
*props
,
180 /* Set the transaction mergeinfo for NAME to VALUE in transaction TXN.
181 Perform temporary allocations from POOL. */
182 svn_error_t
*svn_fs_fs__change_txn_mergeinfo(svn_fs_txn_t
*txn
,
184 const svn_string_t
*value
,
187 /* Return whether or not the given FS supports mergeinfo metadata. */
188 svn_boolean_t
svn_fs_fs__fs_supports_mergeinfo(svn_fs_t
*fs
);
190 /* Store a transaction record in *TXN_P for the transaction identified
191 by TXN_ID in filesystem FS. Allocate everything from POOL. */
192 svn_error_t
*svn_fs_fs__get_txn(transaction_t
**txn_p
,
197 /* Abort the existing transaction TXN, performing any temporary
198 allocations in POOL. */
199 svn_error_t
*svn_fs_fs__abort_txn(svn_fs_txn_t
*txn
, apr_pool_t
*pool
);
201 /* Create an entirely new mutable node in the filesystem FS, whose
202 node-revision is NODEREV. Set *ID_P to the new node revision's ID.
203 Use POOL for any temporary allocation. COPY_ID is the copy_id to
204 use in the node revision ID. TXN_ID is the Subversion transaction
205 under which this occurs. */
206 svn_error_t
*svn_fs_fs__create_node(const svn_fs_id_t
**id_p
,
208 node_revision_t
*noderev
,
213 /* Remove all references to the transaction TXN_ID from filesystem FS.
214 Temporary allocations are from POOL. */
215 svn_error_t
*svn_fs_fs__purge_txn(svn_fs_t
*fs
,
219 /* Add or set in filesystem FS, transaction TXN_ID, in directory
220 PARENT_NODEREV a directory entry for NAME pointing to ID of type
221 KIND. Allocations are done in POOL. */
222 svn_error_t
*svn_fs_fs__set_entry(svn_fs_t
*fs
,
224 node_revision_t
*parent_noderev
,
226 const svn_fs_id_t
*id
,
227 svn_node_kind_t kind
,
230 /* Add a change to the changes record for filesystem FS in transaction
231 TXN_ID. Mark path PATH, having node-id ID, as changed according to
232 the type in CHANGE_KIND. If the text representation was changed
233 set TEXT_MOD to TRUE, and likewise for PROP_MOD. If this change
234 was the result of a copy, set COPYFROM_REV and COPYFROM_PATH to the
235 revision and path of the copy source, otherwise they should be set
236 to SVN_INVALID_REVNUM and NULL. Perform any temporary allocations
238 svn_error_t
*svn_fs_fs__add_change(svn_fs_t
*fs
,
241 const svn_fs_id_t
*id
,
242 svn_fs_path_change_kind_t change_kind
,
243 svn_boolean_t text_mod
,
244 svn_boolean_t prop_mod
,
245 svn_revnum_t copyfrom_rev
,
246 const char *copyfrom_path
,
249 /* Return a writable stream in *STREAM that allows storing the text
250 representation of node-revision NODEREV in filesystem FS.
251 Allocations are from POOL. */
252 svn_error_t
*svn_fs_fs__set_contents(svn_stream_t
**stream
,
254 node_revision_t
*noderev
,
257 /* Create a node revision in FS which is an immediate successor of
258 OLD_ID, whose contents are NEW_NR. Set *NEW_ID_P to the new node
259 revision's ID. Use POOL for any temporary allocation.
261 COPY_ID, if non-NULL, is a key into the `copies' table, and
262 indicates that this new node is being created as the result of a
263 copy operation, and specifically which operation that was. If
264 COPY_ID is NULL, then re-use the copy ID from the predecessor node.
266 TXN_ID is the Subversion transaction under which this occurs.
268 After this call, the deltification code assumes that the new node's
269 contents will change frequently, and will avoid representing other
270 nodes as deltas against this node's contents. */
271 svn_error_t
*svn_fs_fs__create_successor(const svn_fs_id_t
**new_id_p
,
273 const svn_fs_id_t
*old_idp
,
274 node_revision_t
*new_noderev
,
279 /* Write a new property list PROPLIST for node-revision NODEREV in
280 filesystem FS. Perform any temporary allocations in POOL. */
281 svn_error_t
*svn_fs_fs__set_proplist(svn_fs_t
*fs
,
282 node_revision_t
*noderev
,
283 apr_hash_t
*proplist
,
286 /* Commit the transaction TXN in filesystem FS and return its new
287 revision number in *REV. If the transaction is out of date, return
288 the error SVN_ERR_FS_TXN_OUT_OF_DATE. Use POOL for temporary
290 svn_error_t
*svn_fs_fs__commit(svn_revnum_t
*new_rev_p
,
295 /* Return the next available copy_id in *COPY_ID for the transaction
296 TXN_ID in filesystem FS. Allocate space in POOL. */
297 svn_error_t
*svn_fs_fs__reserve_copy_id(const char **copy_id
,
302 /* Create a fs_fs fileysystem referenced by FS at path PATH. Get any
303 temporary allocations from POOL. */
304 svn_error_t
*svn_fs_fs__create(svn_fs_t
*fs
,
308 /* Store the uuid of the repository FS in *UUID. Allocate space in
310 svn_error_t
*svn_fs_fs__get_uuid(svn_fs_t
*fs
,
314 /* Set the uuid of repository FS to UUID, if UUID is not NULL;
315 otherwise, set the uuid of FS to a newly generated UUID. Perform
316 temporary allocations in POOL. */
317 svn_error_t
*svn_fs_fs__set_uuid(svn_fs_t
*fs
,
321 /* Set *NAMES_P to an array of names which are all the active
322 transactions in filesystem FS. Allocate the array from POOL. */
323 svn_error_t
*svn_fs_fs__list_transactions(apr_array_header_t
**names_p
,
327 /* Open the transaction named NAME in filesystem FS. Set *TXN_P to
328 * the transaction. If there is no such transaction, return
329 ` * SVN_ERR_FS_NO_SUCH_TRANSACTION. Allocate the new transaction in
331 svn_error_t
*svn_fs_fs__open_txn(svn_fs_txn_t
**txn_p
,
336 /* Return the property list from transaction TXN and store it in
337 *PROPLIST. Allocate the property list from POOL. */
338 svn_error_t
*svn_fs_fs__txn_proplist(apr_hash_t
**proplist
,
342 /* Delete the mutable node-revision referenced by ID, along with any
343 mutable props or directory contents associated with it. Perform
344 temporary allocations in POOL. */
345 svn_error_t
*svn_fs_fs__delete_node_revision(svn_fs_t
*fs
,
346 const svn_fs_id_t
*id
,
350 /* Find the paths which were changed in transaction TXN_ID of
351 filesystem FS and store them in *CHANGED_PATHS_P. Cached copyfrom
352 information will be stored in COPYFROM_CACHE if it is non-NULL.
353 Get any temporary allocations from POOL. */
354 svn_error_t
*svn_fs_fs__txn_changes_fetch(apr_hash_t
**changes
,
357 apr_hash_t
*copyfrom_cache
,
361 /* Move a file into place from OLD_FILENAME in the transactions
362 directory to its final location NEW_FILENAME in the repository. On
363 Unix, match the permissions of the new file to the permissions of
364 PERMS_REFERENCE. Temporary allocations are from POOL. */
365 svn_error_t
*svn_fs_fs__move_into_place(const char *old_filename
,
366 const char *new_filename
,
367 const char *perms_reference
,
370 /* Match the perms on FILENAME to the PERMS_REFERENCE file if we're
371 not on a win32 system. On win32, this is a no-op. */
372 svn_error_t
*svn_fs_fs__dup_perms(const char *filename
,
373 const char *perms_reference
,
376 /* Return the path to the file containing revision REV in FS.
377 Allocate the new char * from POOL. */
378 const char *svn_fs_fs__path_rev(svn_fs_t
*fs
,
382 /* Return the path to the 'current' file in FS.
383 Perform allocation in POOL. */
385 svn_fs_fs__path_current(svn_fs_t
*fs
, apr_pool_t
*pool
);
387 /* Obtain a write lock on the filesystem FS in a subpool of POOL, call
388 BODY with BATON and that subpool, destroy the subpool (releasing the write
389 lock) and return what BODY returned. */
391 svn_fs_fs__with_write_lock(svn_fs_t
*fs
,
392 svn_error_t
*(*body
)(void *baton
,
397 /* Find the value of the property named PROPNAME in transaction TXN.
398 Return the contents in *VALUE_P. The contents will be allocated
400 svn_error_t
*svn_fs_fs__revision_prop(svn_string_t
**value_p
, svn_fs_t
*fs
,
402 const char *propname
,
405 /* Change, add, or delete a property on a revision REV in filesystem
406 FS. NAME gives the name of the property, and value, if non-NULL,
407 gives the new contents of the property. If value is NULL, then the
408 property will be deleted. Do any temporary allocation in POOL. */
409 svn_error_t
*svn_fs_fs__change_rev_prop(svn_fs_t
*fs
, svn_revnum_t rev
,
411 const svn_string_t
*value
,
414 /* Retrieve information about the Subversion transaction SVN_TXN from
415 the `transactions' table of FS, allocating from POOL. Set
416 *ROOT_ID_P to the ID of the transaction's root directory. Set
417 *BASE_ROOT_ID_P to the ID of the root directory of the
418 transaction's base revision.
420 If there is no such transaction, SVN_ERR_FS_NO_SUCH_TRANSACTION is
423 Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
424 transaction that has already been committed.
426 Allocate *ROOT_ID_P and *BASE_ROOT_ID_P in POOL. */
427 svn_error_t
*svn_fs_fs__get_txn_ids(const svn_fs_id_t
**root_id_p
,
428 const svn_fs_id_t
**base_root_id_p
,
430 const char *txn_name
,
433 /* Begin a new transaction in filesystem FS, based on existing
434 revision REV. The new transaction is returned in *TXN_P. Allocate
435 the new transaction structure from POOL. */
436 svn_error_t
*svn_fs_fs__begin_txn(svn_fs_txn_t
**txn_p
, svn_fs_t
*fs
,
437 svn_revnum_t rev
, apr_uint32_t flags
,
440 /* Find the value of the property named PROPNAME in transaction TXN.
441 Return the contents in *VALUE_P. The contents will be allocated
443 svn_error_t
*svn_fs_fs__txn_prop(svn_string_t
**value_p
, svn_fs_txn_t
*txn
,
444 const char *propname
, apr_pool_t
*pool
);
446 /* If directory PATH does not exist, create it and give it the same
447 permissions as FS->path.*/
448 svn_error_t
*svn_fs_fs__ensure_dir_exists(const char *path
,
452 /* Update the node origin index for FS, recording the mapping from
453 NODE_ID to NODE_REV_ID. Use POOL for any temporary allocations.
455 Because this is just an "optional" cache, this function does not
456 return an error if the underlying storage is readonly; it still
457 returns an error for other error conditions.
460 svn_fs_fs__set_node_origin(svn_fs_t
*fs
,
462 const svn_fs_id_t
*node_rev_id
,
465 /* Set *ORIGIN_ID to the node revision ID from which the history of
466 all nodes in FS whose "Node ID" is NODE_ID springs, as determined
467 by a look in the index. ORIGIN_ID needs to be parsed in an
468 FS-backend-specific way. Use POOL for allocations.
470 If there is no entry for NODE_ID in the cache, return NULL
473 svn_fs_fs__get_node_origin(const svn_fs_id_t
**origin_id
,