1251881Speter/* fs_fs.h : interface to the native filesystem layer
2251881Speter *
3251881Speter * ====================================================================
4251881Speter *    Licensed to the Apache Software Foundation (ASF) under one
5251881Speter *    or more contributor license agreements.  See the NOTICE file
6251881Speter *    distributed with this work for additional information
7251881Speter *    regarding copyright ownership.  The ASF licenses this file
8251881Speter *    to you under the Apache License, Version 2.0 (the
9251881Speter *    "License"); you may not use this file except in compliance
10251881Speter *    with the License.  You may obtain a copy of the License at
11251881Speter *
12251881Speter *      http://www.apache.org/licenses/LICENSE-2.0
13251881Speter *
14251881Speter *    Unless required by applicable law or agreed to in writing,
15251881Speter *    software distributed under the License is distributed on an
16251881Speter *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17251881Speter *    KIND, either express or implied.  See the License for the
18251881Speter *    specific language governing permissions and limitations
19251881Speter *    under the License.
20251881Speter * ====================================================================
21251881Speter */
22251881Speter
23251881Speter#ifndef SVN_LIBSVN_FS__FS_FS_H
24251881Speter#define SVN_LIBSVN_FS__FS_FS_H
25251881Speter
26251881Speter#include "fs.h"
27251881Speter
28251881Speter/* Open the fsfs filesystem pointed to by PATH and associate it with
29251881Speter   filesystem object FS.  Use POOL for temporary allocations.
30251881Speter
31251881Speter   ### Some parts of *FS must have been initialized beforehand; some parts
32251881Speter       (including FS->path) are initialized by this function. */
33251881Spetersvn_error_t *svn_fs_fs__open(svn_fs_t *fs,
34251881Speter                             const char *path,
35251881Speter                             apr_pool_t *pool);
36251881Speter
37251881Speter/* Upgrade the fsfs filesystem FS.  Use POOL for temporary allocations. */
38251881Spetersvn_error_t *svn_fs_fs__upgrade(svn_fs_t *fs,
39251881Speter                                apr_pool_t *pool);
40251881Speter
41251881Speter/* Verify metadata in fsfs filesystem FS.  Limit the checks to revisions
42251881Speter * START to END where possible.  Indicate progress via the optional
43251881Speter * NOTIFY_FUNC callback using NOTIFY_BATON.  The optional CANCEL_FUNC
44251881Speter * will periodically be called with CANCEL_BATON to allow for preemption.
45251881Speter * Use POOL for temporary allocations. */
46251881Spetersvn_error_t *svn_fs_fs__verify(svn_fs_t *fs,
47251881Speter                               svn_revnum_t start,
48251881Speter                               svn_revnum_t end,
49251881Speter                               svn_fs_progress_notify_func_t notify_func,
50251881Speter                               void *notify_baton,
51251881Speter                               svn_cancel_func_t cancel_func,
52251881Speter                               void *cancel_baton,
53251881Speter                               apr_pool_t *pool);
54251881Speter
55251881Speter/* Copy the fsfs filesystem SRC_FS at SRC_PATH into a new copy DST_FS at
56251881Speter * DST_PATH. If INCREMENTAL is TRUE, do not re-copy data which already
57251881Speter * exists in DST_FS. Use POOL for temporary allocations. */
58251881Spetersvn_error_t * svn_fs_fs__hotcopy(svn_fs_t *src_fs,
59251881Speter                                 svn_fs_t *dst_fs,
60251881Speter                                 const char *src_path,
61251881Speter                                 const char *dst_path,
62251881Speter                                 svn_boolean_t incremental,
63251881Speter                                 svn_cancel_func_t cancel_func,
64251881Speter                                 void *cancel_baton,
65251881Speter                                 apr_pool_t *pool);
66251881Speter
67251881Speter/* Recover the fsfs associated with filesystem FS.
68251881Speter   Use optional CANCEL_FUNC/CANCEL_BATON for cancellation support.
69251881Speter   Use POOL for temporary allocations. */
70251881Spetersvn_error_t *svn_fs_fs__recover(svn_fs_t *fs,
71251881Speter                                svn_cancel_func_t cancel_func,
72251881Speter                                void *cancel_baton,
73251881Speter                                apr_pool_t *pool);
74251881Speter
75251881Speter/* Set *NODEREV_P to the node-revision for the node ID in FS.  Do any
76251881Speter   allocations in POOL. */
77251881Spetersvn_error_t *svn_fs_fs__get_node_revision(node_revision_t **noderev_p,
78251881Speter                                          svn_fs_t *fs,
79251881Speter                                          const svn_fs_id_t *id,
80251881Speter                                          apr_pool_t *pool);
81251881Speter
82251881Speter/* Store NODEREV as the node-revision for the node whose id is ID in
83251881Speter   FS, after setting its is_fresh_txn_root to FRESH_TXN_ROOT.  Do any
84251881Speter   necessary temporary allocation in POOL. */
85251881Spetersvn_error_t *svn_fs_fs__put_node_revision(svn_fs_t *fs,
86251881Speter                                          const svn_fs_id_t *id,
87251881Speter                                          node_revision_t *noderev,
88251881Speter                                          svn_boolean_t fresh_txn_root,
89251881Speter                                          apr_pool_t *pool);
90251881Speter
91251881Speter/* Write the node-revision NODEREV into the stream OUTFILE, compatible with
92251881Speter   filesystem format FORMAT.  Only write mergeinfo-related metadata if
93251881Speter   INCLUDE_MERGEINFO is true.  Temporary allocations are from POOL. */
94251881Speter/* ### Currently used only by fs_fs.c */
95251881Spetersvn_error_t *
96251881Spetersvn_fs_fs__write_noderev(svn_stream_t *outfile,
97251881Speter                         node_revision_t *noderev,
98251881Speter                         int format,
99251881Speter                         svn_boolean_t include_mergeinfo,
100251881Speter                         apr_pool_t *pool);
101251881Speter
102251881Speter/* Read a node-revision from STREAM. Set *NODEREV to the new structure,
103251881Speter   allocated in POOL. */
104251881Speter/* ### Currently used only by fs_fs.c */
105251881Spetersvn_error_t *
106251881Spetersvn_fs_fs__read_noderev(node_revision_t **noderev,
107251881Speter                        svn_stream_t *stream,
108251881Speter                        apr_pool_t *pool);
109251881Speter
110251881Speter
111251881Speter/* Set *YOUNGEST to the youngest revision in filesystem FS.  Do any
112251881Speter   temporary allocation in POOL. */
113251881Spetersvn_error_t *svn_fs_fs__youngest_rev(svn_revnum_t *youngest,
114251881Speter                                     svn_fs_t *fs,
115251881Speter                                     apr_pool_t *pool);
116251881Speter
117251881Speter/* Return an error iff REV does not exist in FS. */
118251881Spetersvn_error_t *
119251881Spetersvn_fs_fs__revision_exists(svn_revnum_t rev,
120251881Speter                           svn_fs_t *fs,
121251881Speter                           apr_pool_t *pool);
122251881Speter
123251881Speter/* Set *ROOT_ID to the node-id for the root of revision REV in
124251881Speter   filesystem FS.  Do any allocations in POOL. */
125251881Spetersvn_error_t *svn_fs_fs__rev_get_root(svn_fs_id_t **root_id,
126251881Speter                                     svn_fs_t *fs,
127251881Speter                                     svn_revnum_t rev,
128251881Speter                                     apr_pool_t *pool);
129251881Speter
130251881Speter/* Set *ENTRIES to an apr_hash_t of dirent structs that contain the
131251881Speter   directory entries of node-revision NODEREV in filesystem FS.  The
132251881Speter   returned table (and its keys and values) is allocated in POOL,
133251881Speter   which is also used for temporary allocations. */
134251881Spetersvn_error_t *svn_fs_fs__rep_contents_dir(apr_hash_t **entries,
135251881Speter                                         svn_fs_t *fs,
136251881Speter                                         node_revision_t *noderev,
137251881Speter                                         apr_pool_t *pool);
138251881Speter
139251881Speter/* Set *DIRENT to the entry identified by NAME in the directory given
140251881Speter   by NODEREV in filesystem FS.  If no such entry exits, *DIRENT will
141251881Speter   be NULL. The returned object is allocated in RESULT_POOL; SCRATCH_POOL
142251881Speter   used for temporary allocations. */
143251881Spetersvn_error_t *
144251881Spetersvn_fs_fs__rep_contents_dir_entry(svn_fs_dirent_t **dirent,
145251881Speter                                  svn_fs_t *fs,
146251881Speter                                  node_revision_t *noderev,
147251881Speter                                  const char *name,
148251881Speter                                  apr_pool_t *result_pool,
149251881Speter                                  apr_pool_t *scratch_pool);
150251881Speter
151251881Speter/* Set *CONTENTS to be a readable svn_stream_t that receives the text
152251881Speter   representation of node-revision NODEREV as seen in filesystem FS.
153251881Speter   Use POOL for temporary allocations. */
154251881Spetersvn_error_t *svn_fs_fs__get_contents(svn_stream_t **contents,
155251881Speter                                     svn_fs_t *fs,
156251881Speter                                     node_revision_t *noderev,
157251881Speter                                     apr_pool_t *pool);
158251881Speter
159251881Speter/* Attempt to fetch the text representation of node-revision NODEREV as
160251881Speter   seen in filesystem FS and pass it along with the BATON to the PROCESSOR.
161251881Speter   Set *SUCCESS only of the data could be provided and the processing
162251881Speter   had been called.
163251881Speter   Use POOL for all allocations.
164251881Speter */
165251881Spetersvn_error_t *
166251881Spetersvn_fs_fs__try_process_file_contents(svn_boolean_t *success,
167251881Speter                                     svn_fs_t *fs,
168251881Speter                                     node_revision_t *noderev,
169251881Speter                                     svn_fs_process_contents_func_t processor,
170251881Speter                                     void* baton,
171251881Speter                                     apr_pool_t *pool);
172251881Speter
173251881Speter/* Set *STREAM_P to a delta stream turning the contents of the file SOURCE into
174251881Speter   the contents of the file TARGET, allocated in POOL.
175251881Speter   If SOURCE is null, the empty string will be used. */
176251881Spetersvn_error_t *svn_fs_fs__get_file_delta_stream(svn_txdelta_stream_t **stream_p,
177251881Speter                                              svn_fs_t *fs,
178251881Speter                                              node_revision_t *source,
179251881Speter                                              node_revision_t *target,
180251881Speter                                              apr_pool_t *pool);
181251881Speter
182251881Speter/* Set *PROPLIST to be an apr_hash_t containing the property list of
183251881Speter   node-revision NODEREV as seen in filesystem FS.  Use POOL for
184251881Speter   temporary allocations. */
185251881Spetersvn_error_t *svn_fs_fs__get_proplist(apr_hash_t **proplist,
186251881Speter                                     svn_fs_t *fs,
187251881Speter                                     node_revision_t *noderev,
188251881Speter                                     apr_pool_t *pool);
189251881Speter
190251881Speter/* Set *PROPLIST to be an apr_hash_t containing the property list of
191251881Speter   revision REV as seen in filesystem FS.  Use POOL for temporary
192251881Speter   allocations. */
193251881Spetersvn_error_t *svn_fs_fs__revision_proplist(apr_hash_t **proplist,
194251881Speter                                          svn_fs_t *fs,
195251881Speter                                          svn_revnum_t rev,
196251881Speter                                          apr_pool_t *pool);
197251881Speter
198251881Speter/* Set *LENGTH to the be fulltext length of the node revision
199251881Speter   specified by NODEREV.  Use POOL for temporary allocations. */
200251881Spetersvn_error_t *svn_fs_fs__file_length(svn_filesize_t *length,
201251881Speter                                    node_revision_t *noderev,
202251881Speter                                    apr_pool_t *pool);
203251881Speter
204251881Speter/* Return TRUE if the representation keys in A and B both point to the
205251881Speter   same representation, else return FALSE. */
206251881Spetersvn_boolean_t svn_fs_fs__noderev_same_rep_key(representation_t *a,
207251881Speter                                              representation_t *b);
208251881Speter
209251881Speter
210251881Speter/* Return a copy of the representation REP allocated from POOL. */
211251881Speterrepresentation_t *svn_fs_fs__rep_copy(representation_t *rep,
212251881Speter                                      apr_pool_t *pool);
213251881Speter
214251881Speter
215251881Speter/* Return the recorded checksum of type KIND for the text representation
216251881Speter   of NODREV into CHECKSUM, allocating from POOL.  If no stored checksum is
217251881Speter   available, put all NULL into CHECKSUM. */
218251881Spetersvn_error_t *svn_fs_fs__file_checksum(svn_checksum_t **checksum,
219251881Speter                                      node_revision_t *noderev,
220251881Speter                                      svn_checksum_kind_t kind,
221251881Speter                                      apr_pool_t *pool);
222251881Speter
223251881Speter/* Find the paths which were changed in revision REV of filesystem FS
224251881Speter   and store them in *CHANGED_PATHS_P.  Cached copyfrom information
225251881Speter   will be stored in *COPYFROM_CACHE.  Get any temporary allocations
226251881Speter   from POOL. */
227251881Spetersvn_error_t *svn_fs_fs__paths_changed(apr_hash_t **changed_paths_p,
228251881Speter                                      svn_fs_t *fs,
229251881Speter                                      svn_revnum_t rev,
230251881Speter                                      apr_hash_t *copyfrom_cache,
231251881Speter                                      apr_pool_t *pool);
232251881Speter
233251881Speter/* Create a new transaction in filesystem FS, based on revision REV,
234251881Speter   and store it in *TXN_P.  Allocate all necessary variables from
235251881Speter   POOL. */
236251881Spetersvn_error_t *svn_fs_fs__create_txn(svn_fs_txn_t **txn_p,
237251881Speter                                   svn_fs_t *fs,
238251881Speter                                   svn_revnum_t rev,
239251881Speter                                   apr_pool_t *pool);
240251881Speter
241251881Speter/* Set the transaction property NAME to the value VALUE in transaction
242251881Speter   TXN.  Perform temporary allocations from POOL. */
243251881Spetersvn_error_t *svn_fs_fs__change_txn_prop(svn_fs_txn_t *txn,
244251881Speter                                        const char *name,
245251881Speter                                        const svn_string_t *value,
246251881Speter                                        apr_pool_t *pool);
247251881Speter
248251881Speter/* Change transaction properties in transaction TXN based on PROPS.
249251881Speter   Perform temporary allocations from POOL. */
250251881Spetersvn_error_t *svn_fs_fs__change_txn_props(svn_fs_txn_t *txn,
251251881Speter                                         const apr_array_header_t *props,
252251881Speter                                         apr_pool_t *pool);
253251881Speter
254251881Speter/* Return whether or not the given FS supports mergeinfo metadata. */
255251881Spetersvn_boolean_t svn_fs_fs__fs_supports_mergeinfo(svn_fs_t *fs);
256251881Speter
257251881Speter/* Store a transaction record in *TXN_P for the transaction identified
258251881Speter   by TXN_ID in filesystem FS.  Allocate everything from POOL. */
259251881Spetersvn_error_t *svn_fs_fs__get_txn(transaction_t **txn_p,
260251881Speter                                svn_fs_t *fs,
261251881Speter                                const char *txn_id,
262251881Speter                                apr_pool_t *pool);
263251881Speter
264251881Speter/* Abort the existing transaction TXN, performing any temporary
265251881Speter   allocations in POOL. */
266251881Spetersvn_error_t *svn_fs_fs__abort_txn(svn_fs_txn_t *txn, apr_pool_t *pool);
267251881Speter
268251881Speter/* Create an entirely new mutable node in the filesystem FS, whose
269251881Speter   node-revision is NODEREV.  Set *ID_P to the new node revision's ID.
270251881Speter   Use POOL for any temporary allocation.  COPY_ID is the copy_id to
271251881Speter   use in the node revision ID.  TXN_ID is the Subversion transaction
272251881Speter   under which this occurs. */
273251881Spetersvn_error_t *svn_fs_fs__create_node(const svn_fs_id_t **id_p,
274251881Speter                                    svn_fs_t *fs,
275251881Speter                                    node_revision_t *noderev,
276251881Speter                                    const char *copy_id,
277251881Speter                                    const char *txn_id,
278251881Speter                                    apr_pool_t *pool);
279251881Speter
280251881Speter/* Remove all references to the transaction TXN_ID from filesystem FS.
281251881Speter   Temporary allocations are from POOL. */
282251881Spetersvn_error_t *svn_fs_fs__purge_txn(svn_fs_t *fs,
283251881Speter                                  const char *txn_id,
284251881Speter                                  apr_pool_t *pool);
285251881Speter
286251881Speter/* Add or set in filesystem FS, transaction TXN_ID, in directory
287251881Speter   PARENT_NODEREV a directory entry for NAME pointing to ID of type
288251881Speter   KIND.  Allocations are done in POOL. */
289251881Spetersvn_error_t *svn_fs_fs__set_entry(svn_fs_t *fs,
290251881Speter                                  const char *txn_id,
291251881Speter                                  node_revision_t *parent_noderev,
292251881Speter                                  const char *name,
293251881Speter                                  const svn_fs_id_t *id,
294251881Speter                                  svn_node_kind_t kind,
295251881Speter                                  apr_pool_t *pool);
296251881Speter
297251881Speter/* Add a change to the changes record for filesystem FS in transaction
298251881Speter   TXN_ID.  Mark path PATH, having node-id ID, as changed according to
299251881Speter   the type in CHANGE_KIND.  If the text representation was changed
300251881Speter   set TEXT_MOD to TRUE, and likewise for PROP_MOD.  If this change
301251881Speter   was the result of a copy, set COPYFROM_REV and COPYFROM_PATH to the
302251881Speter   revision and path of the copy source, otherwise they should be set
303251881Speter   to SVN_INVALID_REVNUM and NULL.  Perform any temporary allocations
304251881Speter   from POOL. */
305251881Spetersvn_error_t *svn_fs_fs__add_change(svn_fs_t *fs,
306251881Speter                                   const char *txn_id,
307251881Speter                                   const char *path,
308251881Speter                                   const svn_fs_id_t *id,
309251881Speter                                   svn_fs_path_change_kind_t change_kind,
310251881Speter                                   svn_boolean_t text_mod,
311251881Speter                                   svn_boolean_t prop_mod,
312251881Speter                                   svn_node_kind_t node_kind,
313251881Speter                                   svn_revnum_t copyfrom_rev,
314251881Speter                                   const char *copyfrom_path,
315251881Speter                                   apr_pool_t *pool);
316251881Speter
317251881Speter/* Return a writable stream in *STREAM that allows storing the text
318251881Speter   representation of node-revision NODEREV in filesystem FS.
319251881Speter   Allocations are from POOL. */
320251881Spetersvn_error_t *svn_fs_fs__set_contents(svn_stream_t **stream,
321251881Speter                                     svn_fs_t *fs,
322251881Speter                                     node_revision_t *noderev,
323251881Speter                                     apr_pool_t *pool);
324251881Speter
325251881Speter/* Create a node revision in FS which is an immediate successor of
326251881Speter   OLD_ID, whose contents are NEW_NR.  Set *NEW_ID_P to the new node
327251881Speter   revision's ID.  Use POOL for any temporary allocation.
328251881Speter
329251881Speter   COPY_ID, if non-NULL, is a key into the `copies' table, and
330251881Speter   indicates that this new node is being created as the result of a
331251881Speter   copy operation, and specifically which operation that was.  If
332251881Speter   COPY_ID is NULL, then re-use the copy ID from the predecessor node.
333251881Speter
334251881Speter   TXN_ID is the Subversion transaction under which this occurs.
335251881Speter
336251881Speter   After this call, the deltification code assumes that the new node's
337251881Speter   contents will change frequently, and will avoid representing other
338251881Speter   nodes as deltas against this node's contents.  */
339251881Spetersvn_error_t *svn_fs_fs__create_successor(const svn_fs_id_t **new_id_p,
340251881Speter                                         svn_fs_t *fs,
341251881Speter                                         const svn_fs_id_t *old_idp,
342251881Speter                                         node_revision_t *new_noderev,
343251881Speter                                         const char *copy_id,
344251881Speter                                         const char *txn_id,
345251881Speter                                         apr_pool_t *pool);
346251881Speter
347251881Speter/* Write a new property list PROPLIST for node-revision NODEREV in
348251881Speter   filesystem FS.  Perform any temporary allocations in POOL. */
349251881Spetersvn_error_t *svn_fs_fs__set_proplist(svn_fs_t *fs,
350251881Speter                                     node_revision_t *noderev,
351251881Speter                                     apr_hash_t *proplist,
352251881Speter                                     apr_pool_t *pool);
353251881Speter
354251881Speter/* Commit the transaction TXN in filesystem FS and return its new
355251881Speter   revision number in *REV.  If the transaction is out of date, return
356251881Speter   the error SVN_ERR_FS_TXN_OUT_OF_DATE.  Use POOL for temporary
357251881Speter   allocations. */
358251881Spetersvn_error_t *svn_fs_fs__commit(svn_revnum_t *new_rev_p,
359251881Speter                               svn_fs_t *fs,
360251881Speter                               svn_fs_txn_t *txn,
361251881Speter                               apr_pool_t *pool);
362251881Speter
363251881Speter/* Return the next available copy_id in *COPY_ID for the transaction
364251881Speter   TXN_ID in filesystem FS.  Allocate space in POOL. */
365251881Spetersvn_error_t *svn_fs_fs__reserve_copy_id(const char **copy_id,
366251881Speter                                        svn_fs_t *fs,
367251881Speter                                        const char *txn_id,
368251881Speter                                        apr_pool_t *pool);
369251881Speter
370251881Speter/* Create a fs_fs fileysystem referenced by FS at path PATH.  Get any
371251881Speter   temporary allocations from POOL.
372251881Speter
373251881Speter   ### Some parts of *FS must have been initialized beforehand; some parts
374251881Speter       (including FS->path) are initialized by this function. */
375251881Spetersvn_error_t *svn_fs_fs__create(svn_fs_t *fs,
376251881Speter                               const char *path,
377251881Speter                               apr_pool_t *pool);
378251881Speter
379251881Speter/* Set the uuid of repository FS to UUID, if UUID is not NULL;
380251881Speter   otherwise, set the uuid of FS to a newly generated UUID.  Perform
381251881Speter   temporary allocations in POOL. */
382251881Spetersvn_error_t *svn_fs_fs__set_uuid(svn_fs_t *fs,
383251881Speter                                 const char *uuid,
384251881Speter                                 apr_pool_t *pool);
385251881Speter
386251881Speter/* Set *NAMES_P to an array of names which are all the active
387251881Speter   transactions in filesystem FS.  Allocate the array from POOL. */
388251881Spetersvn_error_t *svn_fs_fs__list_transactions(apr_array_header_t **names_p,
389251881Speter                                          svn_fs_t *fs,
390251881Speter                                          apr_pool_t *pool);
391251881Speter
392251881Speter/* Open the transaction named NAME in filesystem FS.  Set *TXN_P to
393251881Speter * the transaction. If there is no such transaction, return
394251881Speter` * SVN_ERR_FS_NO_SUCH_TRANSACTION.  Allocate the new transaction in
395251881Speter * POOL. */
396251881Spetersvn_error_t *svn_fs_fs__open_txn(svn_fs_txn_t **txn_p,
397251881Speter                                 svn_fs_t *fs,
398251881Speter                                 const char *name,
399251881Speter                                 apr_pool_t *pool);
400251881Speter
401251881Speter/* Return the property list from transaction TXN and store it in
402251881Speter   *PROPLIST.  Allocate the property list from POOL. */
403251881Spetersvn_error_t *svn_fs_fs__txn_proplist(apr_hash_t **proplist,
404251881Speter                                     svn_fs_txn_t *txn,
405251881Speter                                     apr_pool_t *pool);
406251881Speter
407251881Speter/* Delete the mutable node-revision referenced by ID, along with any
408251881Speter   mutable props or directory contents associated with it.  Perform
409251881Speter   temporary allocations in POOL. */
410251881Spetersvn_error_t *svn_fs_fs__delete_node_revision(svn_fs_t *fs,
411251881Speter                                             const svn_fs_id_t *id,
412251881Speter                                             apr_pool_t *pool);
413251881Speter
414251881Speter
415251881Speter/* Find the paths which were changed in transaction TXN_ID of
416251881Speter   filesystem FS and store them in *CHANGED_PATHS_P.
417251881Speter   Get any temporary allocations from POOL. */
418251881Spetersvn_error_t *svn_fs_fs__txn_changes_fetch(apr_hash_t **changes,
419251881Speter                                          svn_fs_t *fs,
420251881Speter                                          const char *txn_id,
421251881Speter                                          apr_pool_t *pool);
422251881Speter
423251881Speter
424251881Speter/* Set *PATH to the path of REV in FS, whether in a pack file or not.
425251881Speter   Allocate *PATH in POOL.
426251881Speter
427251881Speter   Note: If the caller does not have the write lock on FS, then the path is
428251881Speter   not guaranteed to be correct or to remain correct after the function
429251881Speter   returns, because the revision might become packed before or after this
430251881Speter   call.  If a file exists at that path, then it is correct; if not, then
431251881Speter   the caller should call update_min_unpacked_rev() and re-try once. */
432251881Spetersvn_error_t *
433251881Spetersvn_fs_fs__path_rev_absolute(const char **path,
434251881Speter                             svn_fs_t *fs,
435251881Speter                             svn_revnum_t rev,
436251881Speter                             apr_pool_t *pool);
437251881Speter
438251881Speter/* Return the path to the 'current' file in FS.
439251881Speter   Perform allocation in POOL. */
440251881Speterconst char *
441251881Spetersvn_fs_fs__path_current(svn_fs_t *fs, apr_pool_t *pool);
442251881Speter
443251881Speter/* Obtain a write lock on the filesystem FS in a subpool of POOL, call
444251881Speter   BODY with BATON and that subpool, destroy the subpool (releasing the write
445251881Speter   lock) and return what BODY returned. */
446251881Spetersvn_error_t *
447251881Spetersvn_fs_fs__with_write_lock(svn_fs_t *fs,
448251881Speter                           svn_error_t *(*body)(void *baton,
449251881Speter                                                apr_pool_t *pool),
450251881Speter                           void *baton,
451251881Speter                           apr_pool_t *pool);
452251881Speter
453251881Speter/* Find the value of the property named PROPNAME in transaction TXN.
454251881Speter   Return the contents in *VALUE_P.  The contents will be allocated
455251881Speter   from POOL. */
456251881Spetersvn_error_t *svn_fs_fs__revision_prop(svn_string_t **value_p, svn_fs_t *fs,
457251881Speter                                      svn_revnum_t rev,
458251881Speter                                      const char *propname,
459251881Speter                                      apr_pool_t *pool);
460251881Speter
461251881Speter/* Change, add, or delete a property on a revision REV in filesystem
462251881Speter   FS.  NAME gives the name of the property, and value, if non-NULL,
463251881Speter   gives the new contents of the property.  If value is NULL, then the
464251881Speter   property will be deleted.  If OLD_VALUE_P is not NULL, do nothing unless the
465251881Speter   preexisting value is *OLD_VALUE_P.  Do any temporary allocation in POOL.  */
466251881Spetersvn_error_t *svn_fs_fs__change_rev_prop(svn_fs_t *fs, svn_revnum_t rev,
467251881Speter                                        const char *name,
468251881Speter                                        const svn_string_t *const *old_value_p,
469251881Speter                                        const svn_string_t *value,
470251881Speter                                        apr_pool_t *pool);
471251881Speter
472251881Speter/* Retrieve information about the Subversion transaction SVN_TXN from
473251881Speter   the `transactions' table of FS, allocating from POOL.  Set
474251881Speter   *ROOT_ID_P to the ID of the transaction's root directory.  Set
475251881Speter   *BASE_ROOT_ID_P to the ID of the root directory of the
476251881Speter   transaction's base revision.
477251881Speter
478251881Speter   If there is no such transaction, SVN_ERR_FS_NO_SUCH_TRANSACTION is
479251881Speter   the error returned.
480251881Speter
481251881Speter   Returns SVN_ERR_FS_TRANSACTION_NOT_MUTABLE if TXN_NAME refers to a
482251881Speter   transaction that has already been committed.
483251881Speter
484251881Speter   Allocate *ROOT_ID_P and *BASE_ROOT_ID_P in POOL.  */
485251881Spetersvn_error_t *svn_fs_fs__get_txn_ids(const svn_fs_id_t **root_id_p,
486251881Speter                                    const svn_fs_id_t **base_root_id_p,
487251881Speter                                    svn_fs_t *fs,
488251881Speter                                    const char *txn_name,
489251881Speter                                    apr_pool_t *pool);
490251881Speter
491251881Speter/* Begin a new transaction in filesystem FS, based on existing
492251881Speter   revision REV.  The new transaction is returned in *TXN_P.  Allocate
493251881Speter   the new transaction structure from POOL. */
494251881Spetersvn_error_t *svn_fs_fs__begin_txn(svn_fs_txn_t **txn_p, svn_fs_t *fs,
495251881Speter                                  svn_revnum_t rev, apr_uint32_t flags,
496251881Speter                                  apr_pool_t *pool);
497251881Speter
498251881Speter/* Find the value of the property named PROPNAME in transaction TXN.
499251881Speter   Return the contents in *VALUE_P.  The contents will be allocated
500251881Speter   from POOL. */
501251881Spetersvn_error_t *svn_fs_fs__txn_prop(svn_string_t **value_p, svn_fs_txn_t *txn,
502251881Speter                                 const char *propname, apr_pool_t *pool);
503251881Speter
504251881Speter/* If directory PATH does not exist, create it and give it the same
505251881Speter   permissions as FS_PATH.*/
506251881Spetersvn_error_t *svn_fs_fs__ensure_dir_exists(const char *path,
507251881Speter                                          const char *fs_path,
508251881Speter                                          apr_pool_t *pool);
509251881Speter
510251881Speter/* Update the node origin index for FS, recording the mapping from
511251881Speter   NODE_ID to NODE_REV_ID.  Use POOL for any temporary allocations.
512251881Speter
513251881Speter   Because this is just an "optional" cache, this function does not
514251881Speter   return an error if the underlying storage is readonly; it still
515251881Speter   returns an error for other error conditions.
516251881Speter */
517251881Spetersvn_error_t *
518251881Spetersvn_fs_fs__set_node_origin(svn_fs_t *fs,
519251881Speter                           const char *node_id,
520251881Speter                           const svn_fs_id_t *node_rev_id,
521251881Speter                           apr_pool_t *pool);
522251881Speter
523251881Speter/* Set *ORIGIN_ID to the node revision ID from which the history of
524251881Speter   all nodes in FS whose "Node ID" is NODE_ID springs, as determined
525251881Speter   by a look in the index.  ORIGIN_ID needs to be parsed in an
526251881Speter   FS-backend-specific way.  Use POOL for allocations.
527251881Speter
528251881Speter   If there is no entry for NODE_ID in the cache, return NULL
529251881Speter   in *ORIGIN_ID. */
530251881Spetersvn_error_t *
531251881Spetersvn_fs_fs__get_node_origin(const svn_fs_id_t **origin_id,
532251881Speter                           svn_fs_t *fs,
533251881Speter                           const char *node_id,
534251881Speter                           apr_pool_t *pool);
535251881Speter
536251881Speter
537251881Speter/* Initialize all session-local caches in FS according to the global
538251881Speter   cache settings. Use POOL for allocations.
539251881Speter
540251881Speter   Please note that it is permissible for this function to set some
541251881Speter   or all of these caches to NULL, regardless of any setting. */
542251881Spetersvn_error_t *
543251881Spetersvn_fs_fs__initialize_caches(svn_fs_t *fs, apr_pool_t *pool);
544251881Speter
545251881Speter/* Initialize all transaction-local caches in FS according to the global
546251881Speter   cache settings and make TXN_ID part of their key space. Use POOL for
547251881Speter   allocations.
548251881Speter
549251881Speter   Please note that it is permissible for this function to set some or all
550251881Speter   of these caches to NULL, regardless of any setting. */
551251881Spetersvn_error_t *
552251881Spetersvn_fs_fs__initialize_txn_caches(svn_fs_t *fs,
553251881Speter                                 const char *txn_id,
554251881Speter                                 apr_pool_t *pool);
555251881Speter
556251881Speter/* Resets the svn_cache__t structures local to the current transaction in FS.
557251881Speter   Calling it more than once per txn or from outside any txn is allowed. */
558251881Spetervoid
559251881Spetersvn_fs_fs__reset_txn_caches(svn_fs_t *fs);
560251881Speter
561251881Speter/* Possibly pack the repository at PATH.  This just take full shards, and
562251881Speter   combines all the revision files into a single one, with a manifest header.
563251881Speter   Use optional CANCEL_FUNC/CANCEL_BATON for cancellation support.
564251881Speter
565251881Speter   Existing filesystem references need not change.  */
566251881Spetersvn_error_t *
567251881Spetersvn_fs_fs__pack(svn_fs_t *fs,
568251881Speter                svn_fs_pack_notify_t notify_func,
569251881Speter                void *notify_baton,
570251881Speter                svn_cancel_func_t cancel_func,
571251881Speter                void *cancel_baton,
572251881Speter                apr_pool_t *pool);
573251881Speter
574251881Speter
575251881Speter#endif
576