[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] oxenstored: avoid leading slash in paths in saved store state



commit 506114e9183de1640f3c2e5b66f4980b596164f7
Author:     Jonathan Davies <jonathan.davies@xxxxxxxxxx>
AuthorDate: Fri Apr 7 14:27:19 2017 +0100
Commit:     Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Mon Apr 10 14:46:21 2017 +0100

    oxenstored: avoid leading slash in paths in saved store state
    
    Internally, paths are represented as lists of strings, where
      * path "/" is represented by []
      * path "/local/domain/0" is represented by ["local"; "domain"; "0"]
    (see comment for Store.Path.t).
    
    However, the traversal function generated paths like
        [""; "local"; "domain"; "0"]
    because the name of the root node is "". Change it to generate paths
    correctly.
    
    Furthermore, the function passed to Store.dump_fct would render the node
    "foo" under the path [] as "//foo". Change this to return "/foo".
    
    Signed-off-by: Jonathan Davies <jonathan.davies@xxxxxxxxxx>
    Reviewed-by: Wei Liu <wei.liu2@xxxxxxxxxx>
    Reviewed-by: Christian Lindig <christian.lindig@xxxxxxxxxx>
    Release-acked-by: Julien Grall <julien.grall@xxxxxxx>
---
 tools/ocaml/xenstored/store.ml     | 8 +++++++-
 tools/ocaml/xenstored/xenstored.ml | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/ocaml/xenstored/store.ml b/tools/ocaml/xenstored/store.ml
index 9f619b8..13cf3b5 100644
--- a/tools/ocaml/xenstored/store.ml
+++ b/tools/ocaml/xenstored/store.ml
@@ -122,6 +122,11 @@ let of_string s =
                | "" :: path when is_valid path -> path
                | _ -> raise Define.Invalid_path
 
+let of_path_and_name path name =
+       match path, name with
+       | [], "" -> []
+       | _ -> path @ [name]
+
 let create path connection_path =
        of_string (Utils.path_validate path connection_path)
 
@@ -343,7 +348,8 @@ let path_exists store path =
 let traversal root_node f =
        let rec _traversal path node =
                f path node;
-               List.iter (_traversal (path @ [ Symbol.to_string node.Node.name 
])) node.Node.children
+               let node_path = Path.of_path_and_name path (Symbol.to_string 
node.Node.name) in
+               List.iter (_traversal node_path) node.Node.children
                in
        _traversal [] root_node
 
diff --git a/tools/ocaml/xenstored/xenstored.ml 
b/tools/ocaml/xenstored/xenstored.ml
index 09da257..77fd9e3 100644
--- a/tools/ocaml/xenstored/xenstored.ml
+++ b/tools/ocaml/xenstored/xenstored.ml
@@ -213,7 +213,7 @@ let to_channel store cons chan =
        (* dump the store *)
        Store.dump_fct store (fun path node ->
                let name, perms, value = Store.Node.unpack node in
-               let fullpath = (Store.Path.to_string path) ^ "/" ^ name in
+               let fullpath = Store.Path.to_string 
(Store.Path.of_path_and_name path name) in
                let permstr = Perms.Node.to_string perms in
                fprintf chan "store,%s,%s,%s\n" (hexify fullpath) (hexify 
permstr) (hexify value)
        );
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.