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 /* Copy the fsfs filesystem at SRC_PATH into a new copy at DST_PATH.
30 Use POOL for temporary allocations. */
31 svn_error_t
*svn_fs_fs__hotcopy(const char *src_path
,
35 /* Recover the fsfs associated with filesystem FS.
36 Use optional CANCEL_FUNC/CANCEL_BATON for cancellation support.
37 Use POOL for temporary allocations. */
38 svn_error_t
*svn_fs_fs__recover(svn_fs_t
*fs
,
39 svn_cancel_func_t cancel_func
,
43 /* Set *NODEREV_P to the node-revision for the node ID in FS. Do any
44 allocations in POOL. */
45 svn_error_t
*svn_fs_fs__get_node_revision(node_revision_t
**noderev_p
,
47 const svn_fs_id_t
*id
,
50 /* Store NODEREV as the node-revision for the node whose id is ID in
51 FS, after setting its is_fresh_txn_root to FRESH_TXN_ROOT. Do any
52 necessary temporary allocation in POOL. */
53 svn_error_t
*svn_fs_fs__put_node_revision(svn_fs_t
*fs
,
54 const svn_fs_id_t
*id
,
55 node_revision_t
*noderev
,
56 svn_boolean_t fresh_txn_root
,
59 /* Set *YOUNGEST to the youngest revision in filesystem FS. Do any
60 temporary allocation in POOL. */
61 svn_error_t
*svn_fs_fs__youngest_rev(svn_revnum_t
*youngest
,
65 /* Set *ROOT_ID to the node-id for the root of revision REV in
66 filesystem FS. Do any allocations in POOL. */
67 svn_error_t
*svn_fs_fs__rev_get_root(svn_fs_id_t
**root_id
,
72 /* Set *ENTRIES to an apr_hash_t of dirent structs that contain the
73 directory entries of node-revision NODEREV in filesystem FS. Use
74 POOL for temporary allocations. The returned hash does *not* live
75 in POOL, and becomes invalid on the next call to this function. If
76 you need it to live longer, copy it with
77 svn_fs_fs__copy_dir_entries. */
78 svn_error_t
*svn_fs_fs__rep_contents_dir(apr_hash_t
**entries
,
80 node_revision_t
*noderev
,
83 /* Return a copy of the directory hash ENTRIES in POOL. Use this to
84 copy the result of svn_fs_fs__rep_contents_dir into a predictable
85 place so that doesn't become invalid before it's no longer
87 apr_hash_t
*svn_fs_fs__copy_dir_entries(apr_hash_t
*entries
,
90 /* Set *CONTENTS to be a readable svn_stream_t that receives the text
91 representation of node-revision NODEREV as seen in filesystem FS.
92 Use POOL for temporary allocations. */
93 svn_error_t
*svn_fs_fs__get_contents(svn_stream_t
**contents
,
95 node_revision_t
*noderev
,
98 /* Set *STREAM_P to a delta stream turning the contents of the file SOURCE into
99 the contents of the file TARGET, allocated in POOL.
100 If SOURCE is null, the empty string will be used. */
101 svn_error_t
*svn_fs_fs__get_file_delta_stream(svn_txdelta_stream_t
**stream_p
,
103 node_revision_t
*source
,
104 node_revision_t
*target
,
107 /* Set *PROPLIST to be an apr_hash_t containing the property list of
108 node-revision NODEREV as seen in filesystem FS. Use POOL for
109 temporary allocations. */
110 svn_error_t
*svn_fs_fs__get_proplist(apr_hash_t
**proplist
,
112 node_revision_t
*noderev
,
115 /* Set the revision property list of revision REV in filesystem FS to
116 PROPLIST. Use POOL for temporary allocations. */
117 svn_error_t
*svn_fs_fs__set_revision_proplist(svn_fs_t
*fs
,
119 apr_hash_t
*proplist
,
122 /* Set *PROPLIST to be an apr_hash_t containing the property list of
123 revision REV as seen in filesystem FS. Use POOL for temporary
125 svn_error_t
*svn_fs_fs__revision_proplist(apr_hash_t
**proplist
,
130 /* Set *LENGTH to the be fulltext length of the node revision
131 specified by NODEREV. Use POOL for temporary allocations. */
132 svn_error_t
*svn_fs_fs__file_length(svn_filesize_t
*length
,
133 node_revision_t
*noderev
,
136 /* Return TRUE if the representation keys in A and B both point to the
137 same representation, else return FALSE. */
138 svn_boolean_t
svn_fs_fs__noderev_same_rep_key(representation_t
*a
,
139 representation_t
*b
);
142 /* Return a copy of the representation REP allocated from POOL. */
143 representation_t
*svn_fs_fs__rep_copy(representation_t
*rep
,
147 /* Return the record MD5 checksum of the text representation of NODREV
148 into DIGEST, allocating from POOL. If no stored checksum is
149 available, put all 0's into DIGEST. */
150 svn_error_t
*svn_fs_fs__file_checksum(unsigned char digest
[],
151 node_revision_t
*noderev
,
154 /* Find the paths which were changed in revision REV of filesystem FS
155 and store them in *CHANGED_PATHS_P. Cached copyfrom information
156 will be stored in *COPYFROM_CACHE. Get any temporary allocations
158 svn_error_t
*svn_fs_fs__paths_changed(apr_hash_t
**changed_paths_p
,
161 apr_hash_t
*copyfrom_cache
,
164 /* Create a new transaction in filesystem FS, based on revision REV,
165 and store it in *TXN_P. Allocate all necessary variables from
167 svn_error_t
*svn_fs_fs__create_txn(svn_fs_txn_t
**txn_p
,
172 /* Set the transaction property NAME to the value VALUE in transaction
173 TXN. Perform temporary allocations from POOL. */
174 svn_error_t
*svn_fs_fs__change_txn_prop(svn_fs_txn_t
*txn
,
176 const svn_string_t
*value
,
179 /* Change transaction properties in transaction TXN based on PROPS.
180 Perform temporary allocations from POOL. */
181 svn_error_t
*svn_fs_fs__change_txn_props(svn_fs_txn_t
*txn
,
182 apr_array_header_t
*props
,
185 /* Set the transaction mergeinfo for NAME to VALUE in transaction TXN.
186 Perform temporary allocations from POOL. */
187 svn_error_t
*svn_fs_fs__change_txn_mergeinfo(svn_fs_txn_t
*txn
,
189 const svn_string_t
*value
,
192 /* Store a transaction record in *TXN_P for the transaction identified
193 by TXN_ID in filesystem FS. Allocate everything from POOL. */
194 svn_error_t
*svn_fs_fs__get_txn(transaction_t
**txn_p
,
199 /* Abort the existing transaction TXN, performing any temporary
200 allocations in POOL. */
201 svn_error_t
*svn_fs_fs__abort_txn(svn_fs_txn_t
*txn
, apr_pool_t
*pool
);
203 /* Create an entirely new mutable node in the filesystem FS, whose
204 node-revision is NODEREV. Set *ID_P to the new node revision's ID.
205 Use POOL for any temporary allocation. COPY_ID is the copy_id to
206 use in the node revision ID. TXN_ID is the Subversion transaction
207 under which this occurs. */
208 svn_error_t
*svn_fs_fs__create_node(const svn_fs_id_t
**id_p
,
210 node_revision_t
*noderev
,
215 /* Remove all references to the transaction TXN_ID from filesystem FS.
216 Temporary allocations are from POOL. */
217 svn_error_t
*svn_fs_fs__purge_txn(svn_fs_t
*fs
,
221 /* Add or set in filesystem FS, transaction TXN_ID, in directory
222 PARENT_NODEREV a directory entry for NAME pointing to ID of type
223 KIND. Allocations are done in POOL. */
224 svn_error_t
*svn_fs_fs__set_entry(svn_fs_t
*fs
,
226 node_revision_t
*parent_noderev
,
228 const svn_fs_id_t
*id
,
229 svn_node_kind_t kind
,
232 /* Add a change to the changes record for filesystem FS in transaction
233 TXN_ID. Mark path PATH, having node-id ID, as changed according to
234 the type in CHANGE_KIND. If the text representation was changed
235 set TEXT_MOD to TRUE, and likewise for PROP_MOD. If this change
236 was the result of a copy, set COPYFROM_REV and COPYFROM_PATH to the
237 revision and path of the copy source, otherwise they should be set
238 to SVN_INVALID_REVNUM and NULL. Perform any temporary allocations
240 svn_error_t
*svn_fs_fs__add_change(svn_fs_t
*fs
,
243 const svn_fs_id_t
*id
,
244 svn_fs_path_change_kind_t change_kind
,
245 svn_boolean_t text_mod
,
246 svn_boolean_t prop_mod
,
247 svn_revnum_t copyfrom_rev
,
248 const char *copyfrom_path
,
251 /* Return a writable stream in *STREAM that allows storing the text
252 representation of node-revision NODEREV in filesystem FS.
253 Allocations are from POOL. */
254 svn_error_t
*svn_fs_fs__set_contents(svn_stream_t
**stream
,
256 node_revision_t
*noderev
,
259 /* Create a node revision in FS which is an immediate successor of
260 OLD_ID, whose contents are NEW_NR. Set *NEW_ID_P to the new node
261 revision's ID. Use POOL for any temporary allocation.
263 COPY_ID, if non-NULL, is a key into the `copies' table, and
264 indicates that this new node is being created as the result of a
265 copy operation, and specifically which operation that was. If
266 COPY_ID is NULL, then re-use the copy ID from the predecessor node.
268 TXN_ID is the Subversion transaction under which this occurs.
270 After this call, the deltification code assumes that the new node's
271 contents will change frequently, and will avoid representing other
272 nodes as deltas against this node's contents. */
273 svn_error_t
*svn_fs_fs__create_successor(const svn_fs_id_t
**new_id_p
,
275 const svn_fs_id_t
*old_idp
,
276 node_revision_t
*new_noderev
,
281 /* Write a new property list PROPLIST for node-revision NODEREV in
282 filesystem FS. Perform any temporary allocations in POOL. */
283 svn_error_t
*svn_fs_fs__set_proplist(svn_fs_t
*fs
,
284 node_revision_t
*noderev
,
285 apr_hash_t
*proplist
,
288 /* Commit the transaction TXN in filesystem FS and return its new
289 revision number in *REV. If the transaction is out of date, return
290 the error SVN_ERR_FS_TXN_OUT_OF_DATE. Use POOL for temporary
292 svn_error_t
*svn_fs_fs__commit(svn_revnum_t
*new_rev_p
,
297 /* Return the next available copy_id in *COPY_ID for the transaction
298 TXN_ID in filesystem FS. Allocate space in POOL. */
299 svn_error_t
*svn_fs_fs__reserve_copy_id(const char **copy_id
,
304 /* Create a fs_fs fileysystem referenced by FS at path PATH. Get any
305 temporary allocations from POOL. */
306 svn_error_t
*svn_fs_fs__create(svn_fs_t
*fs
,
310 /* Store the uuid of the repository FS in *UUID. Allocate space in
312 svn_error_t
*svn_fs_fs__get_uuid(svn_fs_t
*fs
,
316 /* Set the uuid of repository FS to UUID, if UUID is not NULL;
317 otherwise, set the uuid of FS to a newly generated UUID. Perform
318 temporary allocations in POOL. */
319 svn_error_t
*svn_fs_fs__set_uuid(svn_fs_t
*fs
,
323 /* Set *NAMES_P to an array of names which are all the active
324 transactions in filesystem FS. Allocate the array from POOL. */
325 svn_error_t
*svn_fs_fs__list_transactions(apr_array_header_t
**names_p
,
329 /* Open the transaction named NAME in filesystem FS. Set *TXN_P to
330 * the transaction. If there is no such transaction, return
331 ` * SVN_ERR_FS_NO_SUCH_TRANSACTION. Allocate the new transaction in
333 svn_error_t
*svn_fs_fs__open_txn(svn_fs_txn_t
**txn_p
,
338 /* Return the property list from transaction TXN and store it in
339 *PROPLIST. Allocate the property list from POOL. */
340 svn_error_t
*svn_fs_fs__txn_proplist(apr_hash_t
**proplist
,
344 /* Delete the mutable node-revision referenced by ID, along with any
345 mutable props or directory contents associated with it. Perform
346 temporary allocations in POOL. */
347 svn_error_t
*svn_fs_fs__delete_node_revision(svn_fs_t
*fs
,
348 const svn_fs_id_t
*id
,
352 /* Find the paths which were changed in transaction TXN_ID of
353 filesystem FS and store them in *CHANGED_PATHS_P. Cached copyfrom
354 information will be stored in COPYFROM_CACHE if it is non-NULL.
355 Get any temporary allocations from POOL. */
356 svn_error_t
*svn_fs_fs__txn_changes_fetch(apr_hash_t
**changes
,
359 apr_hash_t
*copyfrom_cache
,
363 /* Move a file into place from OLD_FILENAME in the transactions
364 directory to its final location NEW_FILENAME in the repository. On
365 Unix, match the permissions of the new file to the permissions of
366 PERMS_REFERENCE. Temporary allocations are from POOL. */
367 svn_error_t
*svn_fs_fs__move_into_place(const char *old_filename
,
368 const char *new_filename
,
369 const char *perms_reference
,
372 /* Match the perms on FILENAME to the PERMS_REFERENCE file if we're
373 not on a win32 system. On win32, this is a no-op. */
374 svn_error_t
*svn_fs_fs__dup_perms(const char *filename
,
375 const char *perms_reference
,
378 /* Return the path to the file containing revision REV in FS.
379 Allocate the new char * from POOL. */
380 const char *svn_fs_fs__path_rev(svn_fs_t
*fs
,
384 /* Return the path to the 'current' file in FS.
385 Perform allocation in POOL. */
387 svn_fs_fs__path_current(svn_fs_t
*fs
, apr_pool_t
*pool
);
389 /* Obtain a write lock on the filesystem FS in a subpool of POOL, call
390 BODY with BATON and that subpool, destroy the subpool (releasing the write
391 lock) and return what BODY returned. */
393 svn_fs_fs__with_write_lock(svn_fs_t
*fs
,
394 svn_error_t
*(*body
)(void *baton
,
399 /* Find the value of the property named PROPNAME in transaction TXN.
400 Return the contents in *VALUE_P. The contents will be allocated
402 svn_error_t
*svn_fs_fs__revision_prop(svn_string_t
**value_p
, svn_fs_t
*fs
,
404 const char *propname
,
407 /* Change, add, or delete a property on a revision REV in filesystem
408 FS. NAME gives the name of the property, and value, if non-NULL,
409 gives the new contents of the property. If value is NULL, then the
410 property will be deleted. Do any temporary allocation in POOL. */
411 svn_error_t
*svn_fs_fs__change_rev_prop(svn_fs_t
*fs
, svn_revnum_t rev
,
413 const svn_string_t
*value
,
416 /* Retrieve information about the Subversion transaction SVN_TXN from
417 the `transactions' table of FS, allocating from POOL. Set
418 *ROOT_ID_P to the ID of the transaction's root directory. Set
419 *BASE_ROOT_ID_P to the ID of the root directory of the
420 transaction's base revision.
422 If there is no such transaction, SVN_ERR_FS_NO_SUCH_TRANSACTION is
425 Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
426 transaction that has already been committed.
428 Allocate *ROOT_ID_P and *BASE_ROOT_ID_P in POOL. */
429 svn_error_t
*svn_fs_fs__get_txn_ids(const svn_fs_id_t
**root_id_p
,
430 const svn_fs_id_t
**base_root_id_p
,
432 const char *txn_name
,
435 /* Begin a new transaction in filesystem FS, based on existing
436 revision REV. The new transaction is returned in *TXN_P. Allocate
437 the new transaction structure from POOL. */
438 svn_error_t
*svn_fs_fs__begin_txn(svn_fs_txn_t
**txn_p
, svn_fs_t
*fs
,
439 svn_revnum_t rev
, apr_uint32_t flags
,
442 /* Find the value of the property named PROPNAME in transaction TXN.
443 Return the contents in *VALUE_P. The contents will be allocated
445 svn_error_t
*svn_fs_fs__txn_prop(svn_string_t
**value_p
, svn_fs_txn_t
*txn
,
446 const char *propname
, apr_pool_t
*pool
);