1 /* dag_cache.h : Interface to the DAG walker and node cache. 2 * 3 * ==================================================================== 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 * ==================================================================== 21 */ 22 23 #ifndef SVN_LIBSVN_FS_X_DAG_CACHE_H 24 #define SVN_LIBSVN_FS_X_DAG_CACHE_H 25 26 #include "dag.h" 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif /* __cplusplus */ 31 32 /* In RESULT_POOL, create an instance of a DAG node cache. */ 33 svn_fs_x__dag_cache_t* 34 svn_fs_x__create_dag_cache(apr_pool_t *result_pool); 35 36 /* Invalidate cache entries for PATH within ROOT and any of its children. */ 37 void 38 svn_fs_x__invalidate_dag_cache(svn_fs_root_t *root, 39 const char *path); 40 41 /* Flag type used in svn_fs_x__dag_path_t to determine where the 42 respective node got its copy ID from. */ 43 typedef enum svn_fs_x__copy_id_inherit_t 44 { 45 svn_fs_x__copy_id_inherit_unknown = 0, 46 svn_fs_x__copy_id_inherit_self, 47 svn_fs_x__copy_id_inherit_parent, 48 svn_fs_x__copy_id_inherit_new 49 50 } svn_fs_x__copy_id_inherit_t; 51 52 /* Flags for svn_fs_x__get_dag_path. */ 53 typedef enum svn_fs_x__dag_path_flags_t { 54 55 /* The last component of the PATH need not exist. (All parent 56 directories must exist, as usual.) If the last component doesn't 57 exist, simply leave the `node' member of the bottom parent_path 58 component zero. */ 59 svn_fs_x__dag_path_last_optional = 1, 60 61 /* The caller wants a NULL path object instead of an error if the 62 path cannot be found. */ 63 svn_fs_x__dag_path_allow_null = 2 64 } svn_fs_x__dag_path_flags_t; 65 66 67 /* A linked list representing the path from a node up to a root 68 directory. We use this for cloning, and for operations that need 69 to deal with both a node and its parent directory. For example, a 70 `delete' operation needs to know that the node actually exists, but 71 also needs to change the parent directory. */ 72 typedef struct svn_fs_x__dag_path_t 73 { 74 /* A node along the path. This could be the final node, one of its 75 parents, or the root. Every parent path ends with an element for 76 the root directory. */ 77 dag_node_t *node; 78 79 /* The name NODE has in its parent directory. This is zero for the 80 root directory, which (obviously) has no name in its parent. */ 81 char *entry; 82 83 /* The parent of NODE, or zero if NODE is the root directory. */ 84 struct svn_fs_x__dag_path_t *parent; 85 86 /* The copy ID inheritance style. */ 87 svn_fs_x__copy_id_inherit_t copy_inherit; 88 89 /* If copy ID inheritance style is copy_id_inherit_new, this is the 90 path which should be implicitly copied; otherwise, this is NULL. */ 91 const char *copy_src_path; 92 93 } svn_fs_x__dag_path_t; 94 95 /* Open the node identified by PATH in ROOT, allocating in RESULT_POOL. 96 Set *DAG_PATH_P to a path from the node up to ROOT. The resulting 97 **DAG_PATH_P value is guaranteed to contain at least one element, 98 for the root directory. PATH must be in canonical form. Allocate 99 temporaries from SCRATCH_POOL. 100 101 If resulting *PARENT_PATH_P will eventually be made mutable and 102 modified, or if copy ID inheritance information is otherwise needed, 103 IS_TXN_PATH must be set. If IS_TXN_PATH is FALSE, no copy ID 104 inheritance information will be calculated for the *PARENT_PATH_P chain. 105 106 If FLAGS & svn_fs_x__dag_path_last_optional is zero, return the error 107 SVN_ERR_FS_NOT_FOUND if the node PATH refers to does not exist. If 108 non-zero, require all the parent directories to exist as normal, 109 but if the final path component doesn't exist, simply return a path 110 whose bottom `node' member is zero. This option is useful for 111 callers that create new nodes --- we find the parent directory for 112 them, and tell them whether the entry exists already. 113 114 If FLAGS & svn_fs_x__dag_path_allow_null is non-zero, set the 115 *PARENT_PATH_P to NULL if any node in the path could not be found. 116 117 NOTE: Public interfaces which only *read* from the filesystem 118 should not call this function directly, but should instead use 119 svn_fs_x__get_dag_node(). 120 */ 121 svn_error_t * 122 svn_fs_x__get_dag_path(svn_fs_x__dag_path_t **dag_path_p, 123 svn_fs_root_t *root, 124 const char *path, 125 int flags, 126 svn_boolean_t is_txn_path, 127 apr_pool_t *result_pool, 128 apr_pool_t *scratch_pool); 129 130 /* Make the node referred to by PARENT_PATH mutable, if it isn't already, 131 allocating from RESULT_POOL. ROOT must be the root from which 132 PARENT_PATH descends. Clone any parent directories as needed. 133 Adjust the dag nodes in PARENT_PATH to refer to the clones. Use 134 ERROR_PATH in error messages. Use SCRATCH_POOL for temporaries. */ 135 svn_error_t * 136 svn_fs_x__make_path_mutable(svn_fs_root_t *root, 137 svn_fs_x__dag_path_t *parent_path, 138 const char *error_path, 139 apr_pool_t *result_pool, 140 apr_pool_t *scratch_pool); 141 142 /* Open the node identified by PATH in ROOT. Set *DAG_NODE_P to a temporary 143 reference to the node we find. That reference will become invalid upon 144 the next access to the DAG cache. 145 146 Return the error SVN_ERR_FS_NOT_FOUND if this node doesn't exist. 147 */ 148 svn_error_t * 149 svn_fs_x__get_temp_dag_node(dag_node_t **node_p, 150 svn_fs_root_t *root, 151 const char *path, 152 apr_pool_t *scratch_pool); 153 154 /* Open the node identified by PATH in ROOT. Set *DAG_NODE_P to the 155 node we find, allocated in RESULT_POOL. Return the error 156 SVN_ERR_FS_NOT_FOUND if this node doesn't exist. Use SCRATCH_POOL 157 for temporary allocations. 158 */ 159 svn_error_t * 160 svn_fs_x__get_dag_node(dag_node_t **dag_node_p, 161 svn_fs_root_t *root, 162 const char *path, 163 apr_pool_t *result_pool, 164 apr_pool_t *scratch_pool); 165 166 /* Add / update the NODE in the node cache. */ 167 void 168 svn_fs_x__update_dag_cache(dag_node_t *node); 169 170 #ifdef __cplusplus 171 } 172 #endif /* __cplusplus */ 173 174 #endif /* SVN_LIBSVN_FS_X_DAG_CACHE_H */ 175