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 /* Return whether or not the given FS supports mergeinfo metadata. */
181 svn_boolean_t
svn_fs_fs__fs_supports_mergeinfo(svn_fs_t
*fs
);
183 /* Store a transaction record in *TXN_P for the transaction identified
184 by TXN_ID in filesystem FS. Allocate everything from POOL. */
185 svn_error_t
*svn_fs_fs__get_txn(transaction_t
**txn_p
,
190 /* Abort the existing transaction TXN, performing any temporary
191 allocations in POOL. */
192 svn_error_t
*svn_fs_fs__abort_txn(svn_fs_txn_t
*txn
, apr_pool_t
*pool
);
194 /* Create an entirely new mutable node in the filesystem FS, whose
195 node-revision is NODEREV. Set *ID_P to the new node revision's ID.
196 Use POOL for any temporary allocation. COPY_ID is the copy_id to
197 use in the node revision ID. TXN_ID is the Subversion transaction
198 under which this occurs. */
199 svn_error_t
*svn_fs_fs__create_node(const svn_fs_id_t
**id_p
,
201 node_revision_t
*noderev
,
206 /* Remove all references to the transaction TXN_ID from filesystem FS.
207 Temporary allocations are from POOL. */
208 svn_error_t
*svn_fs_fs__purge_txn(svn_fs_t
*fs
,
212 /* Add or set in filesystem FS, transaction TXN_ID, in directory
213 PARENT_NODEREV a directory entry for NAME pointing to ID of type
214 KIND. Allocations are done in POOL. */
215 svn_error_t
*svn_fs_fs__set_entry(svn_fs_t
*fs
,
217 node_revision_t
*parent_noderev
,
219 const svn_fs_id_t
*id
,
220 svn_node_kind_t kind
,
223 /* Add a change to the changes record for filesystem FS in transaction
224 TXN_ID. Mark path PATH, having node-id ID, as changed according to
225 the type in CHANGE_KIND. If the text representation was changed
226 set TEXT_MOD to TRUE, and likewise for PROP_MOD. If this change
227 was the result of a copy, set COPYFROM_REV and COPYFROM_PATH to the
228 revision and path of the copy source, otherwise they should be set
229 to SVN_INVALID_REVNUM and NULL. Perform any temporary allocations
231 svn_error_t
*svn_fs_fs__add_change(svn_fs_t
*fs
,
234 const svn_fs_id_t
*id
,
235 svn_fs_path_change_kind_t change_kind
,
236 svn_boolean_t text_mod
,
237 svn_boolean_t prop_mod
,
238 svn_revnum_t copyfrom_rev
,
239 const char *copyfrom_path
,
242 /* Return a writable stream in *STREAM that allows storing the text
243 representation of node-revision NODEREV in filesystem FS.
244 Allocations are from POOL. */
245 svn_error_t
*svn_fs_fs__set_contents(svn_stream_t
**stream
,
247 node_revision_t
*noderev
,
250 /* Create a node revision in FS which is an immediate successor of
251 OLD_ID, whose contents are NEW_NR. Set *NEW_ID_P to the new node
252 revision's ID. Use POOL for any temporary allocation.
254 COPY_ID, if non-NULL, is a key into the `copies' table, and
255 indicates that this new node is being created as the result of a
256 copy operation, and specifically which operation that was. If
257 COPY_ID is NULL, then re-use the copy ID from the predecessor node.
259 TXN_ID is the Subversion transaction under which this occurs.
261 After this call, the deltification code assumes that the new node's
262 contents will change frequently, and will avoid representing other
263 nodes as deltas against this node's contents. */
264 svn_error_t
*svn_fs_fs__create_successor(const svn_fs_id_t
**new_id_p
,
266 const svn_fs_id_t
*old_idp
,
267 node_revision_t
*new_noderev
,
272 /* Write a new property list PROPLIST for node-revision NODEREV in
273 filesystem FS. Perform any temporary allocations in POOL. */
274 svn_error_t
*svn_fs_fs__set_proplist(svn_fs_t
*fs
,
275 node_revision_t
*noderev
,
276 apr_hash_t
*proplist
,
279 /* Commit the transaction TXN in filesystem FS and return its new
280 revision number in *REV. If the transaction is out of date, return
281 the error SVN_ERR_FS_TXN_OUT_OF_DATE. Use POOL for temporary
283 svn_error_t
*svn_fs_fs__commit(svn_revnum_t
*new_rev_p
,
288 /* Return the next available copy_id in *COPY_ID for the transaction
289 TXN_ID in filesystem FS. Allocate space in POOL. */
290 svn_error_t
*svn_fs_fs__reserve_copy_id(const char **copy_id
,
295 /* Create a fs_fs fileysystem referenced by FS at path PATH. Get any
296 temporary allocations from POOL. */
297 svn_error_t
*svn_fs_fs__create(svn_fs_t
*fs
,
301 /* Store the uuid of the repository FS in *UUID. Allocate space in
303 svn_error_t
*svn_fs_fs__get_uuid(svn_fs_t
*fs
,
307 /* Set the uuid of repository FS to UUID, if UUID is not NULL;
308 otherwise, set the uuid of FS to a newly generated UUID. Perform
309 temporary allocations in POOL. */
310 svn_error_t
*svn_fs_fs__set_uuid(svn_fs_t
*fs
,
314 /* Set *NAMES_P to an array of names which are all the active
315 transactions in filesystem FS. Allocate the array from POOL. */
316 svn_error_t
*svn_fs_fs__list_transactions(apr_array_header_t
**names_p
,
320 /* Open the transaction named NAME in filesystem FS. Set *TXN_P to
321 * the transaction. If there is no such transaction, return
322 ` * SVN_ERR_FS_NO_SUCH_TRANSACTION. Allocate the new transaction in
324 svn_error_t
*svn_fs_fs__open_txn(svn_fs_txn_t
**txn_p
,
329 /* Return the property list from transaction TXN and store it in
330 *PROPLIST. Allocate the property list from POOL. */
331 svn_error_t
*svn_fs_fs__txn_proplist(apr_hash_t
**proplist
,
335 /* Delete the mutable node-revision referenced by ID, along with any
336 mutable props or directory contents associated with it. Perform
337 temporary allocations in POOL. */
338 svn_error_t
*svn_fs_fs__delete_node_revision(svn_fs_t
*fs
,
339 const svn_fs_id_t
*id
,
343 /* Find the paths which were changed in transaction TXN_ID of
344 filesystem FS and store them in *CHANGED_PATHS_P. Cached copyfrom
345 information will be stored in COPYFROM_CACHE if it is non-NULL.
346 Get any temporary allocations from POOL. */
347 svn_error_t
*svn_fs_fs__txn_changes_fetch(apr_hash_t
**changes
,
350 apr_hash_t
*copyfrom_cache
,
354 /* Move a file into place from OLD_FILENAME in the transactions
355 directory to its final location NEW_FILENAME in the repository. On
356 Unix, match the permissions of the new file to the permissions of
357 PERMS_REFERENCE. Temporary allocations are from POOL. */
358 svn_error_t
*svn_fs_fs__move_into_place(const char *old_filename
,
359 const char *new_filename
,
360 const char *perms_reference
,
363 /* Match the perms on FILENAME to the PERMS_REFERENCE file if we're
364 not on a win32 system. On win32, this is a no-op. */
365 svn_error_t
*svn_fs_fs__dup_perms(const char *filename
,
366 const char *perms_reference
,
369 /* Return the path to the file containing revision REV in FS.
370 Allocate the new char * from POOL. */
371 const char *svn_fs_fs__path_rev(svn_fs_t
*fs
,
375 /* Return the path to the 'current' file in FS.
376 Perform allocation in POOL. */
378 svn_fs_fs__path_current(svn_fs_t
*fs
, apr_pool_t
*pool
);
380 /* Obtain a write lock on the filesystem FS in a subpool of POOL, call
381 BODY with BATON and that subpool, destroy the subpool (releasing the write
382 lock) and return what BODY returned. */
384 svn_fs_fs__with_write_lock(svn_fs_t
*fs
,
385 svn_error_t
*(*body
)(void *baton
,
390 /* Find the value of the property named PROPNAME in transaction TXN.
391 Return the contents in *VALUE_P. The contents will be allocated
393 svn_error_t
*svn_fs_fs__revision_prop(svn_string_t
**value_p
, svn_fs_t
*fs
,
395 const char *propname
,
398 /* Change, add, or delete a property on a revision REV in filesystem
399 FS. NAME gives the name of the property, and value, if non-NULL,
400 gives the new contents of the property. If value is NULL, then the
401 property will be deleted. Do any temporary allocation in POOL. */
402 svn_error_t
*svn_fs_fs__change_rev_prop(svn_fs_t
*fs
, svn_revnum_t rev
,
404 const svn_string_t
*value
,
407 /* Retrieve information about the Subversion transaction SVN_TXN from
408 the `transactions' table of FS, allocating from POOL. Set
409 *ROOT_ID_P to the ID of the transaction's root directory. Set
410 *BASE_ROOT_ID_P to the ID of the root directory of the
411 transaction's base revision.
413 If there is no such transaction, SVN_ERR_FS_NO_SUCH_TRANSACTION is
416 Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
417 transaction that has already been committed.
419 Allocate *ROOT_ID_P and *BASE_ROOT_ID_P in POOL. */
420 svn_error_t
*svn_fs_fs__get_txn_ids(const svn_fs_id_t
**root_id_p
,
421 const svn_fs_id_t
**base_root_id_p
,
423 const char *txn_name
,
426 /* Begin a new transaction in filesystem FS, based on existing
427 revision REV. The new transaction is returned in *TXN_P. Allocate
428 the new transaction structure from POOL. */
429 svn_error_t
*svn_fs_fs__begin_txn(svn_fs_txn_t
**txn_p
, svn_fs_t
*fs
,
430 svn_revnum_t rev
, apr_uint32_t flags
,
433 /* Find the value of the property named PROPNAME in transaction TXN.
434 Return the contents in *VALUE_P. The contents will be allocated
436 svn_error_t
*svn_fs_fs__txn_prop(svn_string_t
**value_p
, svn_fs_txn_t
*txn
,
437 const char *propname
, apr_pool_t
*pool
);
439 /* If directory PATH does not exist, create it and give it the same
440 permissions as FS->path.*/
441 svn_error_t
*svn_fs_fs__ensure_dir_exists(const char *path
,
445 /* Update the node origin index for FS, recording the mapping from
446 NODE_ID to NODE_REV_ID. Use POOL for any temporary allocations.
448 Because this is just an "optional" cache, this function does not
449 return an error if the underlying storage is readonly; it still
450 returns an error for other error conditions.
453 svn_fs_fs__set_node_origin(svn_fs_t
*fs
,
455 const svn_fs_id_t
*node_rev_id
,
458 /* Set *ORIGIN_ID to the node revision ID from which the history of
459 all nodes in FS whose "Node ID" is NODE_ID springs, as determined
460 by a look in the index. ORIGIN_ID needs to be parsed in an
461 FS-backend-specific way. Use POOL for allocations.
463 If there is no entry for NODE_ID in the cache, return NULL
466 svn_fs_fs__get_node_origin(const svn_fs_id_t
**origin_id
,