Author: ivan
Date: Sat Jan 9 16:23:58 2016
New Revision: 1723862
URL: http://svn.apache.org/viewvc?rev=1723862&view=rev
Log:
On 'fs-node-api' branch: Provide native, but naive, implementation of FS node
API for FSFS.
* subversion/libsvn_fs_fs/node.c
(fs_node_data_t, fs_node_kind, fs_node_has_props, fs_node_file_length,
fs_node_dir_entries, fs_node_vtable, svn_fs_fs__node_create): New.
* subversion/libsvn_fs_fs/node.h
(svn_fs_fs__node_create): New.
* subversion/libsvn_fs_fs/tree.c
(): Include "node.h"
(fs_open_node): New.
(root_vtable): Add fs_open_node to vtable.
Added:
subversion/branches/fs-node-api/subversion/libsvn_fs_fs/node.c (with
props)
subversion/branches/fs-node-api/subversion/libsvn_fs_fs/node.h (with
props)
Modified:
subversion/branches/fs-node-api/subversion/libsvn_fs_fs/tree.c
Added: subversion/branches/fs-node-api/subversion/libsvn_fs_fs/node.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fs-node-api/subversion/libsvn_fs_fs/node.c?rev=1723862&view=auto
==============================================================================
--- subversion/branches/fs-node-api/subversion/libsvn_fs_fs/node.c (added)
+++ subversion/branches/fs-node-api/subversion/libsvn_fs_fs/node.c Sat Jan 9
16:23:58 2016
@@ -0,0 +1,119 @@
+/* node.c : FS node API to DAG filesystem
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ */
+#include "node.h"
+#include "svn_hash.h"
+#include "../libsvn_fs/fs-loader.h"
+
+typedef struct fs_node_data_t
+{
+ dag_node_t *dag_node;
+} fs_node_data_t;
+
+static svn_error_t *
+fs_node_kind(svn_node_kind_t *kind_p,
+ svn_fs_node_t *node,
+ apr_pool_t *scratch_pool)
+{
+ fs_node_data_t *fnd = node->fsap_data;
+ *kind_p = svn_fs_fs__dag_node_kind(fnd->dag_node);
+ return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+fs_node_has_props(svn_boolean_t *has_props,
+ svn_fs_node_t *node,
+ apr_pool_t *scratch_pool)
+{
+ fs_node_data_t *fnd = node->fsap_data;
+
+ SVN_ERR(svn_fs_fs__dag_has_props(has_props, fnd->dag_node, scratch_pool));
+
+ return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+fs_node_file_length(svn_filesize_t *length_p,
+ svn_fs_node_t *node,
+ apr_pool_t *pool)
+{
+ fs_node_data_t *fnd = node->fsap_data;
+
+ SVN_ERR(svn_fs_fs__dag_file_length(length_p, fnd->dag_node, pool));
+
+ return SVN_NO_ERROR;
+}
+
+static svn_error_t *
+fs_node_dir_entries(apr_hash_t **entries_p,
+ svn_fs_node_t *node,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ fs_node_data_t *fnd = node->fsap_data;
+ apr_array_header_t *entries;
+ apr_hash_t *result;
+ int i;
+
+ SVN_ERR(svn_fs_fs__dag_dir_entries(&entries, fnd->dag_node, scratch_pool));
+
+ result = apr_hash_make(result_pool);
+ for (i = 0; i < entries->nelts; i++)
+ {
+ svn_fs_dirent_t *dirent_v1 = APR_ARRAY_IDX(entries, i, svn_fs_dirent_t
*);
+ svn_fs_dirent2_t *dirent_v2 = apr_pcalloc(result_pool,
+ sizeof(*dirent_v2));
+ dag_node_t *dag_node;
+
+ /* TODO: Make partially bound dag_node or something like that. */
+ SVN_ERR(svn_fs_fs__dag_get_node(&dag_node,
+ svn_fs_fs__dag_get_fs(fnd->dag_node),
+ dirent_v1->id, result_pool));
+ dirent_v2->name = apr_pstrdup(result_pool, dirent_v1->name);
+ dirent_v2->kind = dirent_v1->kind;
+ dirent_v2->node = svn_fs_fs__node_create(dag_node, result_pool);
+ svn_hash_sets(result, dirent_v2->name, dirent_v2);
+ }
+
+ *entries_p = result;
+ return SVN_NO_ERROR;
+}
+
+static const node_vtable_t fs_node_vtable =
+{
+ fs_node_kind,
+ fs_node_has_props,
+ fs_node_file_length,
+ fs_node_dir_entries
+};
+
+svn_fs_node_t *
+svn_fs_fs__node_create(dag_node_t *dag_node,
+ apr_pool_t *result_pool)
+{
+ fs_node_data_t *fnd = apr_palloc(result_pool, sizeof(*fnd));
+ svn_fs_node_t *node = apr_palloc(result_pool, sizeof(*node));
+ fnd->dag_node = dag_node;
+ node->vtable = &fs_node_vtable;
+ node->fsap_data = fnd;
+
+ return node;
+}
Propchange: subversion/branches/fs-node-api/subversion/libsvn_fs_fs/node.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: subversion/branches/fs-node-api/subversion/libsvn_fs_fs/node.h
URL:
http://svn.apache.org/viewvc/subversion/branches/fs-node-api/subversion/libsvn_fs_fs/node.h?rev=1723862&view=auto
==============================================================================
--- subversion/branches/fs-node-api/subversion/libsvn_fs_fs/node.h (added)
+++ subversion/branches/fs-node-api/subversion/libsvn_fs_fs/node.h Sat Jan 9
16:23:58 2016
@@ -0,0 +1,47 @@
+/* node.h : FS node API to DAG filesystem
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ */
+
+#ifndef SVN_LIBSVN_FS_NODE_H
+#define SVN_LIBSVN_FS_NODE_H
+
+#include "svn_fs.h"
+
+#include "dag.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Returns instance of svn_fs_node_t object allocated in RESULT_POOL
+ * and based DAG_NODE. DAG_NODE must have lifetime longer or the
+ * the same as RESULT_POOL.
+ */
+svn_fs_node_t *
+svn_fs_fs__node_create(dag_node_t *dag_node,
+ apr_pool_t *result_pool);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* SVN_LIBSVN_FS_NODE_H */
+
Propchange: subversion/branches/fs-node-api/subversion/libsvn_fs_fs/node.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: subversion/branches/fs-node-api/subversion/libsvn_fs_fs/tree.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fs-node-api/subversion/libsvn_fs_fs/tree.c?rev=1723862&r1=1723861&r2=1723862&view=diff
==============================================================================
--- subversion/branches/fs-node-api/subversion/libsvn_fs_fs/tree.c (original)
+++ subversion/branches/fs-node-api/subversion/libsvn_fs_fs/tree.c Sat Jan 9
16:23:58 2016
@@ -62,6 +62,7 @@
#include "temp_serializer.h"
#include "transaction.h"
#include "util.h"
+#include "node.h"
#include "private/svn_mergeinfo_private.h"
#include "private/svn_subr_private.h"
@@ -3281,7 +3282,33 @@ fs_paths_changed(apr_hash_t **changed_pa
}
-
+static svn_error_t *
+fs_open_node(svn_fs_node_t **node_p,
+ svn_fs_root_t *root,
+ const char *path,
+ svn_boolean_t ignore_enoent,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ dag_node_t *node;
+ svn_error_t *err;
+
+ err = get_dag(&node, root, path, result_pool);
+ if (ignore_enoent && err &&
+ ((err->apr_err == SVN_ERR_FS_NOT_FOUND)
+ || (err->apr_err == SVN_ERR_FS_NOT_DIRECTORY)))
+ {
+ svn_error_clear(err);
+ *node_p = NULL;
+ return SVN_NO_ERROR;
+ }
+ else if (err)
+ return svn_error_trace(err);
+
+ *node_p = svn_fs_fs__node_create(node, result_pool);
+ return SVN_NO_ERROR;
+}
+
/* Our coolio opaque history object. */
typedef struct fs_history_data_t
{
@@ -4325,7 +4352,7 @@ fs_get_mergeinfo(svn_mergeinfo_catalog_t
/* The vtable associated with root objects. */
static root_vtable_t root_vtable = {
fs_paths_changed,
- NULL /* open_node */,
+ fs_open_node,
svn_fs_fs__check_path,
fs_node_history,
svn_fs_fs__node_id,