1
/* fs_fs.h : interface to the native filesystem layer
3
* ====================================================================
4
* Copyright (c) 2000-2004 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
21
#include "revs-txns.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
/* Set *NODEREV_P to the node-revision for the node ID in FS. Do any
36
allocations in POOL. */
37
svn_error_t *svn_fs_fs__get_node_revision (node_revision_t **noderev_p,
39
const svn_fs_id_t *id,
42
/* Store NODEREV as the node-revision for the node whose id is ID in
43
FS. Do any necessary temporary allocation in POOL. */
44
svn_error_t *svn_fs_fs__put_node_revision (svn_fs_t *fs,
45
const svn_fs_id_t *id,
46
node_revision_t *noderev,
49
/* Set *YOUNGEST to the youngest revision in filesystem FS. Do any
50
temporary allocation in POOL. */
51
svn_error_t *svn_fs_fs__youngest_rev (svn_revnum_t *youngest,
55
/* Set *ROOT_ID to the node-id for the root of revision REV in
56
filesystem FS. Do any allocations in POOL. */
57
svn_error_t *svn_fs_fs__rev_get_root (svn_fs_id_t **root_id,
62
/* Set *ENTRIES to an apr_hash_t of dirent structs that contain the
63
directory entries of node-revision NODEREV in filesystem FS. Use
64
POOL for temporary allocations. The returned hash does *not* live
65
in POOL, and becomes invalid on the next call to this function. If
66
you need it to live longer, copy it with
67
svn_fs_fs__copy_dir_entries. */
68
svn_error_t *svn_fs_fs__rep_contents_dir (apr_hash_t **entries,
70
node_revision_t *noderev,
73
/* Return a copy of the directory hash ENTRIES in POOL. Use this to
74
copy the result of svn_fs_fs__rep_contents_dir into a predictable
75
place so that doesn't become invalid before it's no longer
77
apr_hash_t *svn_fs_fs__copy_dir_entries (apr_hash_t *entries,
80
/* Set *CONTENTS to be a readable svn_stream_t that receives the text
81
representation of node-revision NODEREV as seen in filesystem FS.
82
Use POOL for temporary allocations. */
83
svn_error_t *svn_fs_fs__get_contents (svn_stream_t **contents,
85
node_revision_t *noderev,
88
/* Set *PROPLIST to be an apr_hash_t containing the property list of
89
node-revision NODEREV as seen in filesystem FS. Use POOL for
90
temporary allocations. */
91
svn_error_t *svn_fs_fs__get_proplist (apr_hash_t **proplist,
93
node_revision_t *noderev,
96
/* Set the revision property list of revision REV in filesystem FS to
97
PROPLIST. Use POOL for temporary allocations. */
98
svn_error_t *svn_fs_fs__set_revision_proplist (svn_fs_t *fs,
100
apr_hash_t *proplist,
103
/* Set *PROPLIST to be an apr_hash_t containing the property list of
104
revision REV as seen in filesystem FS. Use POOL for temporary
106
svn_error_t *svn_fs_fs__revision_proplist (apr_hash_t **proplist,
111
/* Set *LENGTH to the be fulltext length of the node revision
112
specified by NODEREV. Use POOL for temporary allocations. */
113
svn_error_t *svn_fs_fs__file_length (svn_filesize_t *length,
114
node_revision_t *noderev,
117
/* Return TRUE if the representation keys in A and B both point to the
118
same representation, else return FALSE. */
119
svn_boolean_t svn_fs_fs__noderev_same_rep_key (representation_t *a,
120
representation_t *b);
123
/* Return a copy of the representation REP allocated from POOL. */
124
representation_t *svn_fs_fs__rep_copy (representation_t *rep,
128
/* Return the record MD5 checksum of the text representation of NODREV
129
into DIGEST, allocating from POOL. If no stored checksum is
130
available, put all 0's into DIGEST. */
131
svn_error_t *svn_fs_fs__file_checksum (unsigned char digest[],
132
node_revision_t *noderev,
135
/* Find the paths which were changed in revision REV of filesystem FS
136
and store them in *CHANGED_PATHS_P. Cached copyfrom information
137
will be stored in *COPYFROM_CACHE. Get any temporary allocations
139
svn_error_t *svn_fs_fs__paths_changed (apr_hash_t **changed_paths_p,
142
apr_hash_t *copyfrom_cache,
145
/* Create a new transaction in filesystem FS, based on revision REV,
146
and store it in *TXN_P. Allocate all necessary variables from
148
svn_error_t *svn_fs_fs__create_txn (svn_fs_txn_t **txn_p,
153
/* Set the transaction property NAME to the value VALUE in transaction
154
TXN. Perform temporary allocations from POOL. */
155
svn_error_t *svn_fs_fs__change_txn_prop (svn_fs_txn_t *txn,
157
const svn_string_t *value,
160
/* Store a transaction record in *TXN_P for the transaction identified
161
by TXN_ID in filesystem FS. Allocate everything from POOL. */
162
svn_error_t *svn_fs_fs__get_txn (transaction_t **txn_p,
167
/* Create an entirely new mutable node in the filesystem FS, whose
168
node-revision is NODEREV. Set *ID_P to the new node revision's ID.
169
Use POOL for any temporary allocation. COPY_ID is the copy_id to
170
use in the node revision ID. TXN_ID is the Subversion transaction
171
under which this occurs. */
172
svn_error_t *svn_fs_fs__create_node (const svn_fs_id_t **id_p,
174
node_revision_t *noderev,
179
/* Remove all references to the transaction TXN_ID from filesystem FS.
180
Temporary allocations are from POOL. */
181
svn_error_t *svn_fs_fs__purge_txn (svn_fs_t *fs,
185
/* Add or set in filesystem FS, transaction TXN_ID, in directory
186
PARENT_NODEREV a directory entry for NAME pointing to ID of type
187
KIND. Allocations are done in POOL. */
188
svn_error_t *svn_fs_fs__set_entry (svn_fs_t *fs,
190
node_revision_t *parent_noderev,
192
const svn_fs_id_t *id,
193
svn_node_kind_t kind,
196
/* Add a change to the changes record for filesystem FS in transaction
197
TXN_ID. Mark path PATH, having node-id ID, as changed according to
198
the type in CHANGE_KIND. If the text representation was changed
199
set TEXT_MOD to TRUE, and likewise for PROP_MOD. If this change
200
was the result of a copy, set COPYFROM_REV and COPYFROM_PATH to the
201
revision and path of the copy source, otherwise they should be set
202
to SVN_INVALID_REVNUM and NULL. Perform any temporary allocations
204
svn_error_t *svn_fs_fs__add_change (svn_fs_t *fs,
207
const svn_fs_id_t *id,
208
svn_fs_path_change_kind_t change_kind,
209
svn_boolean_t text_mod,
210
svn_boolean_t prop_mod,
211
svn_revnum_t copyfrom_rev,
212
const char *copyfrom_path,
215
/* Return a writable stream in *STREAM that allows storing the text
216
representation of node-revision NODEREV in filesystem FS.
217
Allocations are from POOL. */
218
svn_error_t *svn_fs_fs__set_contents (svn_stream_t **stream,
220
node_revision_t *noderev,
223
/* Create a node revision in FS which is an immediate successor of
224
OLD_ID, whose contents are NEW_NR. Set *NEW_ID_P to the new node
225
revision's ID. Use POOL for any temporary allocation.
227
COPY_ID, if non-NULL, is a key into the `copies' table, and
228
indicates that this new node is being created as the result of a
229
copy operation, and specifically which operation that was. If
230
COPY_ID is NULL, then re-use the copy ID from the predecessor node.
232
TXN_ID is the Subversion transaction under which this occurs.
234
After this call, the deltification code assumes that the new node's
235
contents will change frequently, and will avoid representing other
236
nodes as deltas against this node's contents. */
237
svn_error_t *svn_fs_fs__create_successor (const svn_fs_id_t **new_id_p,
239
const svn_fs_id_t *old_idp,
240
node_revision_t *new_noderev,
245
/* Write a new property list PROPLIST for node-revision NODEREV in
246
filesystem FS. Perform any temporary allocations in POOL. */
247
svn_error_t *svn_fs_fs__set_proplist (svn_fs_t *fs,
248
node_revision_t *noderev,
249
apr_hash_t *proplist,
252
/* Commit the transaction TXN in filesystem FS and return it's new
253
revision number in *REV. If the transaction is out of date, return
254
the error SVN_ERR_FS_TXN_OUT_OF_DATE. Use POOL for temporary
256
svn_error_t *svn_fs_fs__commit (svn_revnum_t *new_rev_p,
261
/* Return the next available copy_id in *COPY_ID for the transaction
262
TXN_ID in filesystem FS. Allocate space in POOL. */
263
svn_error_t *svn_fs_fs__reserve_copy_id (const char **copy_id,
268
/* Create a fs_fs fileysystem referenced by FS at path PATH. Get any
269
temporary allocations from POOL. */
270
svn_error_t *svn_fs_fs__create (svn_fs_t *fs,
274
/* Store the uuid of the repository FS in *UUID. Allocate space in
276
svn_error_t *svn_fs_fs__get_uuid (svn_fs_t *fs,
280
/* Set the uuid of repository FS to UUID. Perform temporary
281
allocations in POOL. */
282
svn_error_t *svn_fs_fs__set_uuid (svn_fs_t *fs,
286
/* Write out the zeroth revision for filesystem FS. */
287
svn_error_t *svn_fs_fs__write_revision_zero (svn_fs_t *fs);
289
/* Set *NAMES_P to an array of names which are all the active
290
transactions in filesystem FS. Allocate the array from POOL. */
291
svn_error_t *svn_fs_fs__list_transactions (apr_array_header_t **names_p,
295
/* Open the transaction named NAME in filesystem FS. Set *TXN_P to
296
* the transaction. If there is no such transaction, return
297
` * SVN_ERR_FS_NO_SUCH_TRANSACTION. Allocate the new transaction in
299
svn_error_t *svn_fs_fs__open_txn (svn_fs_txn_t **txn_p,
304
/* Return the property list from transaction TXN and store it in
305
*PROPLIST. Allocate the property list from POOL. */
306
svn_error_t *svn_fs_fs__txn_proplist (apr_hash_t **proplist,
310
/* Delete the mutable node-revision referenced by ID, along with any
311
mutable props or directory contents associated with it. Perform
312
temporary allocations in POOL. */
313
svn_error_t *svn_fs_fs__delete_node_revision (svn_fs_t *fs,
314
const svn_fs_id_t *id,
318
/* Find the paths which were changed in transaction TXN_ID of
319
filesystem FS and store them in *CHANGED_PATHS_P. Cached copyfrom
320
information will be stored in COPYFROM_CACHE if it is non-NULL.
321
Get any temporary allocations from POOL. */
322
svn_error_t *svn_fs_fs__txn_changes_fetch (apr_hash_t **changes,
325
apr_hash_t *copyfrom_cache,
329
/* Move a file into place from OLD_FILENAME in the transactions
330
directory to its final location NEW_FILENAME in the repository. On
331
Unix, match the permissions of the new file to the permissions of
332
PERMS_REFERENCE. Temporary allocations are from POOL. */
333
svn_error_t *svn_fs_fs__move_into_place (const char *old_filename,
334
const char *new_filename,
335
const char *perms_reference,
338
/* Match the perms on FILENAME to the PERMS_REFERENCE file if we're
339
not on a win32 system. On win32, this is a no-op. */
340
svn_error_t *svn_fs_fs__dup_perms (const char *filename,
341
const char *perms_reference,
344
/* Return the path to the file containing revision REV in FS.
345
Allocate the new char * from POOL. */
346
const char *svn_fs_fs__path_rev (svn_fs_t *fs,
350
/* Obtain a write lock on the filesystem FS in a subpool of POOL, call
351
BODY with BATON and that subpool, destroy the subpool (releasing the write
352
lock) and return what BODY returned. */
354
svn_fs_fs__with_write_lock (svn_fs_t *fs,
355
svn_error_t *(*body)(void *baton,