Files
Edwin Török 3068dfd641 tools/oxenstored: Use more efficient node trees
This changes the output of xenstore-ls to be sorted.  Previously the keys were
listed in the order in which they were inserted in.  docs/misc/xenstore.txt
doesn't specify in what order keys are listed.

Map.update is used to retain semantics with replace_child: only an existing
child is replaced, if it wasn't part of the original map we don't add it.
Similarly exception behaviour is retained for del_childname and related
functions.

Entries are stored in reverse sort order, so that upon Map.fold the
constructed list is sorted in ascending order and there is no need for a
List.rev.

This changes the semantics and is not suitable as is for a backport.  It
reveals bugs in buggy clients that depend on xenstore entry order, however
those clients should be fixed.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
2021-01-22 18:01:35 +00:00

43 lines
1.4 KiB
OCaml

(*
* Copyright (C) 2006-2007 XenSource Ltd.
* Copyright (C) 2008 Citrix Ltd.
* Author Thomas Gazagnaire <thomas.gazagnaire@eu.citrix.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; version 2.1 only. with the special
* exception on linking described in file LICENSE.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*)
(** Node names *)
(** Xenstore nodes names are often the same, ie. "local", "domain", "device", ... so it is worth to
manipulate them through the use of small identifiers that we call symbols. These symbols can be
compared in constant time (as opposite to strings) and should help the ocaml GC. *)
type t
(** The type of symbols. *)
val of_string : string -> t
(** Convert a string into a symbol. *)
val to_string : t -> string
(** Convert a symbol into a string. *)
val equal: t -> t -> bool
(** Compare two symbols for equality *)
val compare: t -> t -> int
(** Compare two symbols *)
(** {6 Statistics } *)
val stats : unit -> int * int
(** Get the table size and number of entries. *)