The xenstore header xs.h is producing conflicts with other software[1].
xs is a too short identifier and does not matche the library. Renaming
the headers to xenstore.h and xenstore_lib.h is the easiest way to make
them easy recognizable and prevent furthe problems.
[1]: http://bugs.debian.org/668550
[ Also update QEMU_TAG, to bring in corresponding change to
qemu-xen-traditional. -iwj ]
Signed-off-by: Bastian Blank <waldi@debian.org>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
--HG--
rename : tools/xenstore/xs.h => tools/xenstore/xenstore.h
rename : tools/xenstore/xs_lib.h => tools/xenstore/xenstore_lib.h
# CONFIG_QEMU ?= `pwd`/$(XEN_ROOT)/../qemu-xen.git
CONFIG_QEMU ?= $(QEMU_REMOTE)
-QEMU_TAG ?= b7469189669c4de0a5161a869f443738d84539ec
-# Fri May 11 12:40:42 2012 +0100
-# passthrough: Intel GPU passthrough, fix OpRegion mapping
+QEMU_TAG ?= 7bde54662d45b0bbc2ee78c7a8bf2c97c6655445
+# Mon May 14 17:05:48 2012 +0100
+# xenstore: Use <xenstore.h>
# Short answer -- do not enable this unless you know what you are
# doing and are prepared for some pain.
rm -rf $(D)$(BINDIR)/xenpvnetboot $(D)$(BINDIR)/qemu-*-xen
rm -rf $(D)$(INCLUDEDIR)/xenctrl* $(D)$(INCLUDEDIR)/xenguest.h
rm -rf $(D)$(INCLUDEDIR)/xs_lib.h $(D)$(INCLUDEDIR)/xs.h
+ rm -rf $(D)$(INCLUDEDIR)/xenstore-compat/xs_lib.h $(D)$(INCLUDEDIR)/xensotre-compat/xs.h
+ rm -rf $(D)$(INCLUDEDIR)/xenstore_lib.h $(D)$(INCLUDEDIR)/xenstore.h
rm -rf $(D)$(INCLUDEDIR)/xen
rm -rf $(D)$(INCLUDEDIR)/_libxl* $(D)$(INCLUDEDIR)/libxl*
rm -rf $(D)$(INCLUDEDIR)/xenstat.h $(D)$(INCLUDEDIR)/xentoollog.h
#include <blkfront.h>
#include <fbfront.h>
#include <xenbus.h>
-#include <xs.h>
+#include <xenstore.h>
#include <sys/types.h>
#include <sys/unistd.h>
#ifdef HAVE_LIBC
#include <os.h>
#include <lib.h>
-#include <xs.h>
+#include <xenstore.h>
#include <xenbus.h>
#include <stdlib.h>
#include <unistd.h>
--source-path=$$source \
--extra-cflags="-I$(XEN_ROOT)/tools/include \
-I$(XEN_ROOT)/tools/libxc \
- -I$(XEN_ROOT)/tools/xenstore" \
+ -I$(XEN_ROOT)/tools/xenstore \
+ -I$(XEN_ROOT)/tools/xenstore/compat" \
--extra-ldflags="-L$(XEN_ROOT)/tools/libxc \
-L$(XEN_ROOT)/tools/xenstore" \
--bindir=$(LIBEXEC) \
#include <sys/ioctl.h>
#include <string.h>
#include <unistd.h>
-#include <xs.h>
+#include <xenstore.h>
#include <sys/time.h>
#include <syslog.h>
#ifdef MEMSHR
#include <xen/xen.h>
#include <xen/io/blkif.h>
#include <xen/io/ring.h>
-#include <xs.h>
+#include <xenstore.h>
#include <sys/types.h>
#include <unistd.h>
#include <err.h>
#include <stdarg.h>
#include <errno.h>
-#include <xs.h>
+#include <xenstore.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <err.h>
#include <stdarg.h>
#include <errno.h>
-#include <xs.h>
+#include <xenstore.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/stropts.h>
#endif
-#include "xs.h"
+#include <xenstore.h>
#include "xenctrl.h"
#define ESCAPE_CHARACTER 0x1d
#include "utils.h"
#include "io.h"
-#include <xs.h>
+#include <xenstore.h>
#include <xen/io/console.h>
#include <stdlib.h>
#include <stdio.h>
#include <xenctrl.h>
-#include "xs.h"
+#include <xenstore.h>
void daemonize(const char *pidfile);
bool xen_setup(void);
#include <unistd.h>
#include <fcntl.h>
-#include <xs.h>
+#include <xenstore.h>
#include <xen/sys/evtchn.h>
#include <xen/sys/gntalloc.h>
#include <xen/sys/gntdev.h>
#include <sys/wait.h>
#include <sys/socket.h>
-#include <xs.h>
+#include <xenstore.h>
#include <xenctrl.h>
#include "xentoollog.h"
#include <stdio.h>
#include <xenctrl.h>
-#include <xs.h>
+#include <xenstore.h>
#include <stdlib.h>
#include <string.h>
#include <Python.h>
-#include <xs.h>
+#include <xenstore.h>
#include <xenctrl.h>
#include "checkpoint.h"
#include <time.h>
#include <xenguest.h>
-#include <xs.h>
+#include <xenstore.h>
typedef enum {
dt_unknown,
#include <xenctrl.h>
#include <xenguest.h>
-#include <xs.h>
+#include <xenstore.h>
#include "checkpoint.h"
#include <fcntl.h>
#include <errno.h>
-#include "xs.h"
+#include <xenstore.h>
/** @file
* Python interface to the Xen Store Daemon (xs).
#include <sys/time.h>
#include <xen/arch-x86/xen-mca.h>
#include <xg_save_restore.h>
-#include <xs.h>
+#include <xenstore.h>
#define MCi_type_CTL 0x0
#define MCi_type_STATUS 0x1
#include <fcntl.h>
#include <err.h>
-#include <xs.h>
+#include <xenstore.h>
#include <xenctrl.h>
#include <xenguest.h>
#include <string.h>
#include <syslog.h>
-#include <xs.h>
+#include <xenstore.h>
#define DEVTYPE_UNKNOWN 0
#define DEVTYPE_VIF 1
#include <unistd.h>
#include <poll.h>
#include <xc_private.h>
-#include <xs.h>
+#include <xenstore.h>
#include <getopt.h>
#include "xc_bitops.h"
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
-#include <xs.h>
+#include <xenstore.h>
/* #define RUN_STANDALONE */
#define RUN_IN_SIMULATE_MODE
#define XENSTAT_PRIV_H
#include <sys/types.h>
-#include <xs.h>
+#include <xenstore.h>
#include "xenstat.h"
#include "xenctrl.h"
This license (LGPL) applies to the xenstore library which interfaces
-with the xenstore daemon (as stated in xs.c, xs.h, xs_lib.c and
-xs_lib.h). The remaining files in the directory are licensed as
+with the xenstore daemon (as stated in xs.c, xenstore.h, xs_lib.c and
+xenstore_lib.h). The remaining files in the directory are licensed as
stated in the comments (as of this writing, GPL, see ../../COPYING).
$(INSTALL_DIR) $(DESTDIR)$(BINDIR)
$(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
$(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR)
+ $(INSTALL_DIR) $(DESTDIR)$(INCLUDEDIR)/xenstore-compat
$(INSTALL_DIR) $(DESTDIR)/var/run/xenstored
$(INSTALL_DIR) $(DESTDIR)/var/lib/xenstored
$(INSTALL_PROG) xenstored $(DESTDIR)$(SBINDIR)
ln -sf libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)$(LIBDIR)/libxenstore.so.$(MAJOR)
ln -sf libxenstore.so.$(MAJOR) $(DESTDIR)$(LIBDIR)/libxenstore.so
$(INSTALL_DATA) libxenstore.a $(DESTDIR)$(LIBDIR)
- $(INSTALL_DATA) xs.h $(DESTDIR)$(INCLUDEDIR)
- $(INSTALL_DATA) xs_lib.h $(DESTDIR)$(INCLUDEDIR)
+ $(INSTALL_DATA) xenstore.h $(DESTDIR)$(INCLUDEDIR)
+ $(INSTALL_DATA) xenstore_lib.h $(DESTDIR)$(INCLUDEDIR)
+ $(INSTALL_DATA) compat/xs.h $(DESTDIR)$(INCLUDEDIR)/xenstore-compat/xs.h
+ $(INSTALL_DATA) compat/xs_lib.h $(DESTDIR)$(INCLUDEDIR)/xenstore-compat/xs_lib.h
+ ln -sf xenstore-compat/xs.h $(DESTDIR)$(INCLUDEDIR)/xs.h
+ ln -sf xenstore-compat/xs_lib.h $(DESTDIR)$(INCLUDEDIR)/xs_lib.h
-include $(DEPS)
--- /dev/null
+#warning xs.h is deprecated use xenstore.h instead
+#include <xenstore.h>
--- /dev/null
+#warning xs_lib.h is deprecated use xenstore_lib.h instead
+#include <xenstore_lib.h>
#include <sys/mman.h>
#include <xenctrl.h>
#include <xc_dom.h>
-#include <xs.h>
+#include <xenstore.h>
#include <xen/sys/xenbus_dev.h>
static uint32_t domid = -1;
--- /dev/null
+/*
+ Xen Store Daemon providing simple tree-like database.
+ Copyright (C) 2005 Rusty Russell IBM Corporation
+
+ This library 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; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef XENSTORE_H
+#define XENSTORE_H
+
+#include <xenstore_lib.h>
+
+#define XBT_NULL 0
+
+#define XS_OPEN_READONLY 1UL<<0
+#define XS_OPEN_SOCKETONLY 1UL<<1
+
+struct xs_handle;
+typedef uint32_t xs_transaction_t;
+
+/* IMPORTANT: For details on xenstore protocol limits, see
+ * docs/misc/xenstore.txt in the Xen public source repository, and use the
+ * XENSTORE_*_MAX limit macros defined in xen/io/xs_wire.h.
+ */
+
+/* On failure, these routines set errno. */
+
+/* Open a connection to the xs daemon.
+ * Attempts to make a connection over the socket interface,
+ * and if it fails, then over the xenbus interface.
+ * Mode 0 specifies read-write access, XS_OPEN_READONLY for
+ * read-only access.
+ * Returns a handle or NULL.
+ */
+struct xs_handle *xs_open(unsigned long flags);
+
+/* Close the connection to the xs daemon. */
+void xs_close(struct xs_handle *xsh);
+
+/* Connect to the xs daemon.
+ * Returns a handle or NULL.
+ * Deprecated, please use xs_open(0) instead
+ */
+struct xs_handle *xs_daemon_open(void);
+struct xs_handle *xs_domain_open(void);
+
+/* Connect to the xs daemon (readonly for non-root clients).
+ * Returns a handle or NULL.
+ * Deprecated, please use xs_open(XS_OPEN_READONLY) instead
+ */
+struct xs_handle *xs_daemon_open_readonly(void);
+
+/* Close the connection to the xs daemon.
+ * Deprecated, please use xs_close() instead
+ */
+void xs_daemon_close(struct xs_handle *);
+
+/* Throw away the connection to the xs daemon, for use after fork(). */
+void xs_daemon_destroy_postfork(struct xs_handle *);
+
+/* Get contents of a directory.
+ * Returns a malloced array: call free() on it after use.
+ * Num indicates size.
+ */
+char **xs_directory(struct xs_handle *h, xs_transaction_t t,
+ const char *path, unsigned int *num);
+
+/* Get the value of a single file, nul terminated.
+ * Returns a malloced value: call free() on it after use.
+ * len indicates length in bytes, not including terminator.
+ */
+void *xs_read(struct xs_handle *h, xs_transaction_t t,
+ const char *path, unsigned int *len);
+
+/* Write the value of a single file.
+ * Returns false on failure.
+ */
+bool xs_write(struct xs_handle *h, xs_transaction_t t,
+ const char *path, const void *data, unsigned int len);
+
+/* Create a new directory.
+ * Returns false on failure, or success if it already exists.
+ */
+bool xs_mkdir(struct xs_handle *h, xs_transaction_t t,
+ const char *path);
+
+/* Destroy a file or directory (and children).
+ * Returns false on failure, or if it doesn't exist.
+ */
+bool xs_rm(struct xs_handle *h, xs_transaction_t t,
+ const char *path);
+
+/* Restrict a xenstore handle so that it acts as if it had the
+ * permissions of domain @domid. The handle must currently be
+ * using domain 0's credentials.
+ *
+ * Returns false on failure, in which case the handle continues
+ * to use the old credentials, or true on success.
+ */
+bool xs_restrict(struct xs_handle *h, unsigned domid);
+
+/* Get permissions of node (first element is owner, first perms is "other").
+ * Returns malloced array, or NULL: call free() after use.
+ */
+struct xs_permissions *xs_get_permissions(struct xs_handle *h,
+ xs_transaction_t t,
+ const char *path, unsigned int *num);
+
+/* Set permissions of node (must be owner).
+ * Returns false on failure.
+ */
+bool xs_set_permissions(struct xs_handle *h, xs_transaction_t t,
+ const char *path, struct xs_permissions *perms,
+ unsigned int num_perms);
+
+/* Watch a node for changes (poll on fd to detect, or call read_watch()).
+ * When the node (or any child) changes, fd will become readable.
+ * Token is returned when watch is read, to allow matching.
+ * Returns false on failure.
+ */
+bool xs_watch(struct xs_handle *h, const char *path, const char *token);
+
+/* Return the FD to poll on to see if a watch has fired. */
+int xs_fileno(struct xs_handle *h);
+
+/* Check for node changes. On success, returns a non-NULL pointer ret
+ * such that ret[0] and ret[1] are valid C strings, namely the
+ * triggering path (see docs/misc/xenstore.txt) and the token (from
+ * xs_watch). On error return value is NULL setting errno.
+ *
+ * Callers should, after xs_fileno has become readable, repeatedly
+ * call xs_check_watch until it returns NULL and sets errno to EAGAIN.
+ * (If the fd became readable, xs_check_watch is allowed to make it no
+ * longer show up as readable even if future calls to xs_check_watch
+ * will return more watch events.)
+ *
+ * After the caller is finished with the returned information it
+ * should be freed all in one go with free(ret).
+ */
+char **xs_check_watch(struct xs_handle *h);
+
+/* Find out what node change was on (will block if nothing pending).
+ * Returns array containing the path and token. Use XS_WATCH_* to access these
+ * elements. Call free() after use.
+ */
+char **xs_read_watch(struct xs_handle *h, unsigned int *num);
+
+/* Remove a watch on a node: implicitly acks any outstanding watch.
+ * Returns false on failure (no watch on that node).
+ */
+bool xs_unwatch(struct xs_handle *h, const char *path, const char *token);
+
+/* Start a transaction: changes by others will not be seen during this
+ * transaction, and changes will not be visible to others until end.
+ * Returns NULL on failure.
+ */
+xs_transaction_t xs_transaction_start(struct xs_handle *h);
+
+/* End a transaction.
+ * If abandon is true, transaction is discarded instead of committed.
+ * Returns false on failure: if errno == EAGAIN, you have to restart
+ * transaction.
+ */
+bool xs_transaction_end(struct xs_handle *h, xs_transaction_t t,
+ bool abort);
+
+/* Introduce a new domain.
+ * This tells the store daemon about a shared memory page, event channel and
+ * store path associated with a domain: the domain uses these to communicate.
+ */
+bool xs_introduce_domain(struct xs_handle *h,
+ unsigned int domid,
+ unsigned long mfn,
+ unsigned int eventchn);
+
+/* Set the target of a domain
+ * This tells the store daemon that a domain is targetting another one, so
+ * it should let it tinker with it.
+ */
+bool xs_set_target(struct xs_handle *h,
+ unsigned int domid,
+ unsigned int target);
+
+/* Resume a domain.
+ * Clear the shutdown flag for this domain in the store.
+ */
+bool xs_resume_domain(struct xs_handle *h, unsigned int domid);
+
+/* Release a domain.
+ * Tells the store domain to release the memory page to the domain.
+ */
+bool xs_release_domain(struct xs_handle *h, unsigned int domid);
+
+/* Query the home path of a domain. Call free() after use.
+ */
+char *xs_get_domain_path(struct xs_handle *h, unsigned int domid);
+
+/* Returns true if child is either equal to parent, or a node underneath
+ * parent; or false otherwise. Done by string comparison, so relative and
+ * absolute pathnames never in a parent/child relationship by this
+ * definition. Cannot fail.
+ */
+bool xs_path_is_subpath(const char *parent, const char *child);
+
+/* Return whether the domain specified has been introduced to xenstored.
+ */
+bool xs_is_domain_introduced(struct xs_handle *h, unsigned int domid);
+
+/* Only useful for DEBUG versions */
+char *xs_debug_command(struct xs_handle *h, const char *cmd,
+ void *data, unsigned int len);
+
+int xs_suspend_evtchn_port(int domid);
+#endif /* XENSTORE_H */
+
+/*
+ * Local variables:
+ * c-file-style: "linux"
+ * indent-tabs-mode: t
+ * c-indent-level: 8
+ * c-basic-offset: 8
+ * tab-width: 8
+ * End:
+ */
#include <string.h>
#include <termios.h>
#include <unistd.h>
-#include <xs.h>
+#include <xenstore.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <string.h>
-#include "xs.h"
+#include "xenstore.h"
int main(int argc, char **argv)
--- /dev/null
+/*
+ Common routines between Xen store user library and daemon.
+ Copyright (C) 2005 Rusty Russell IBM Corporation
+
+ This library 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; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#ifndef XENSTORE_LIB_H
+#define XENSTORE_LIB_H
+
+#include <stdbool.h>
+#include <limits.h>
+#include <errno.h>
+#include <stdint.h>
+#include <xen/io/xs_wire.h>
+
+/* Bitmask of permissions. */
+enum xs_perm_type {
+ XS_PERM_NONE = 0,
+ XS_PERM_READ = 1,
+ XS_PERM_WRITE = 2,
+ /* Internal use. */
+ XS_PERM_ENOENT_OK = 4,
+ XS_PERM_OWNER = 8,
+};
+
+struct xs_permissions
+{
+ unsigned int id;
+ enum xs_perm_type perms;
+};
+
+/* Each 10 bits takes ~ 3 digits, plus one, plus one for nul terminator. */
+#define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2)
+
+/* Path for various daemon things: env vars can override. */
+const char *xs_daemon_rootdir(void);
+const char *xs_daemon_rundir(void);
+const char *xs_daemon_socket(void);
+const char *xs_daemon_socket_ro(void);
+const char *xs_domain_dev(void);
+const char *xs_daemon_tdb(void);
+
+/* Simple write function: loops for you. */
+bool xs_write_all(int fd, const void *data, unsigned int len);
+
+/* Convert strings to permissions. False if a problem. */
+bool xs_strings_to_perms(struct xs_permissions *perms, unsigned int num,
+ const char *strings);
+
+/* Convert permissions to a string (up to len MAX_STRLEN(unsigned int)+1). */
+bool xs_perm_to_string(const struct xs_permissions *perm,
+ char *buffer, size_t buf_len);
+
+/* Given a string and a length, count how many strings (nul terms). */
+unsigned int xs_count_strings(const char *strings, unsigned int len);
+
+/* Sanitising (quoting) possibly-binary strings. */
+struct expanding_buffer {
+ char *buf;
+ int avail;
+};
+
+/* Ensure that given expanding buffer has at least min_avail characters. */
+char *expanding_buffer_ensure(struct expanding_buffer *, int min_avail);
+
+/* sanitise_value() may return NULL if malloc fails. */
+char *sanitise_value(struct expanding_buffer *, const char *val, unsigned len);
+
+/* *out_len_r on entry is ignored; out must be at least strlen(in)+1 bytes. */
+void unsanitise_value(char *out, unsigned *out_len_r, const char *in);
+
+#endif /* XENSTORE_LIB_H */
#include "utils.h"
#include "list.h"
#include "talloc.h"
-#include "xs_lib.h"
+#include "xenstore_lib.h"
#include "xenstored_core.h"
#include "xenstored_watch.h"
#include "xenstored_transaction.h"
#include <stdbool.h>
#include <stdint.h>
#include <errno.h>
-#include "xs_lib.h"
+#include "xenstore_lib.h"
#include "list.h"
#include "tdb.h"
#include "xenstored_transaction.h"
#include "xenstored_watch.h"
#include "xenstored_domain.h"
-#include "xs_lib.h"
+#include "xenstore_lib.h"
#include "utils.h"
struct changed_node
#include "talloc.h"
#include "list.h"
#include "xenstored_watch.h"
-#include "xs_lib.h"
+#include "xenstore_lib.h"
#include "utils.h"
#include "xenstored_domain.h"
#include <signal.h>
#include <stdint.h>
#include <errno.h>
-#include "xs.h"
+#include "xenstore.h"
#include "list.h"
#include "utils.h"
+++ /dev/null
-/*
- Xen Store Daemon providing simple tree-like database.
- Copyright (C) 2005 Rusty Russell IBM Corporation
-
- This library 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; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library 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.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#ifndef _XS_H
-#define _XS_H
-
-#include <xs_lib.h>
-
-#define XBT_NULL 0
-
-#define XS_OPEN_READONLY 1UL<<0
-#define XS_OPEN_SOCKETONLY 1UL<<1
-
-struct xs_handle;
-typedef uint32_t xs_transaction_t;
-
-/* IMPORTANT: For details on xenstore protocol limits, see
- * docs/misc/xenstore.txt in the Xen public source repository, and use the
- * XENSTORE_*_MAX limit macros defined in xen/io/xs_wire.h.
- */
-
-/* On failure, these routines set errno. */
-
-/* Open a connection to the xs daemon.
- * Attempts to make a connection over the socket interface,
- * and if it fails, then over the xenbus interface.
- * Mode 0 specifies read-write access, XS_OPEN_READONLY for
- * read-only access.
- * Returns a handle or NULL.
- */
-struct xs_handle *xs_open(unsigned long flags);
-
-/* Close the connection to the xs daemon. */
-void xs_close(struct xs_handle *xsh);
-
-/* Connect to the xs daemon.
- * Returns a handle or NULL.
- * Deprecated, please use xs_open(0) instead
- */
-struct xs_handle *xs_daemon_open(void);
-struct xs_handle *xs_domain_open(void);
-
-/* Connect to the xs daemon (readonly for non-root clients).
- * Returns a handle or NULL.
- * Deprecated, please use xs_open(XS_OPEN_READONLY) instead
- */
-struct xs_handle *xs_daemon_open_readonly(void);
-
-/* Close the connection to the xs daemon.
- * Deprecated, please use xs_close() instead
- */
-void xs_daemon_close(struct xs_handle *);
-
-/* Throw away the connection to the xs daemon, for use after fork(). */
-void xs_daemon_destroy_postfork(struct xs_handle *);
-
-/* Get contents of a directory.
- * Returns a malloced array: call free() on it after use.
- * Num indicates size.
- */
-char **xs_directory(struct xs_handle *h, xs_transaction_t t,
- const char *path, unsigned int *num);
-
-/* Get the value of a single file, nul terminated.
- * Returns a malloced value: call free() on it after use.
- * len indicates length in bytes, not including terminator.
- */
-void *xs_read(struct xs_handle *h, xs_transaction_t t,
- const char *path, unsigned int *len);
-
-/* Write the value of a single file.
- * Returns false on failure.
- */
-bool xs_write(struct xs_handle *h, xs_transaction_t t,
- const char *path, const void *data, unsigned int len);
-
-/* Create a new directory.
- * Returns false on failure, or success if it already exists.
- */
-bool xs_mkdir(struct xs_handle *h, xs_transaction_t t,
- const char *path);
-
-/* Destroy a file or directory (and children).
- * Returns false on failure, or if it doesn't exist.
- */
-bool xs_rm(struct xs_handle *h, xs_transaction_t t,
- const char *path);
-
-/* Restrict a xenstore handle so that it acts as if it had the
- * permissions of domain @domid. The handle must currently be
- * using domain 0's credentials.
- *
- * Returns false on failure, in which case the handle continues
- * to use the old credentials, or true on success.
- */
-bool xs_restrict(struct xs_handle *h, unsigned domid);
-
-/* Get permissions of node (first element is owner, first perms is "other").
- * Returns malloced array, or NULL: call free() after use.
- */
-struct xs_permissions *xs_get_permissions(struct xs_handle *h,
- xs_transaction_t t,
- const char *path, unsigned int *num);
-
-/* Set permissions of node (must be owner).
- * Returns false on failure.
- */
-bool xs_set_permissions(struct xs_handle *h, xs_transaction_t t,
- const char *path, struct xs_permissions *perms,
- unsigned int num_perms);
-
-/* Watch a node for changes (poll on fd to detect, or call read_watch()).
- * When the node (or any child) changes, fd will become readable.
- * Token is returned when watch is read, to allow matching.
- * Returns false on failure.
- */
-bool xs_watch(struct xs_handle *h, const char *path, const char *token);
-
-/* Return the FD to poll on to see if a watch has fired. */
-int xs_fileno(struct xs_handle *h);
-
-/* Check for node changes. On success, returns a non-NULL pointer ret
- * such that ret[0] and ret[1] are valid C strings, namely the
- * triggering path (see docs/misc/xenstore.txt) and the token (from
- * xs_watch). On error return value is NULL setting errno.
- *
- * Callers should, after xs_fileno has become readable, repeatedly
- * call xs_check_watch until it returns NULL and sets errno to EAGAIN.
- * (If the fd became readable, xs_check_watch is allowed to make it no
- * longer show up as readable even if future calls to xs_check_watch
- * will return more watch events.)
- *
- * After the caller is finished with the returned information it
- * should be freed all in one go with free(ret).
- */
-char **xs_check_watch(struct xs_handle *h);
-
-/* Find out what node change was on (will block if nothing pending).
- * Returns array containing the path and token. Use XS_WATCH_* to access these
- * elements. Call free() after use.
- */
-char **xs_read_watch(struct xs_handle *h, unsigned int *num);
-
-/* Remove a watch on a node: implicitly acks any outstanding watch.
- * Returns false on failure (no watch on that node).
- */
-bool xs_unwatch(struct xs_handle *h, const char *path, const char *token);
-
-/* Start a transaction: changes by others will not be seen during this
- * transaction, and changes will not be visible to others until end.
- * Returns NULL on failure.
- */
-xs_transaction_t xs_transaction_start(struct xs_handle *h);
-
-/* End a transaction.
- * If abandon is true, transaction is discarded instead of committed.
- * Returns false on failure: if errno == EAGAIN, you have to restart
- * transaction.
- */
-bool xs_transaction_end(struct xs_handle *h, xs_transaction_t t,
- bool abort);
-
-/* Introduce a new domain.
- * This tells the store daemon about a shared memory page, event channel and
- * store path associated with a domain: the domain uses these to communicate.
- */
-bool xs_introduce_domain(struct xs_handle *h,
- unsigned int domid,
- unsigned long mfn,
- unsigned int eventchn);
-
-/* Set the target of a domain
- * This tells the store daemon that a domain is targetting another one, so
- * it should let it tinker with it.
- */
-bool xs_set_target(struct xs_handle *h,
- unsigned int domid,
- unsigned int target);
-
-/* Resume a domain.
- * Clear the shutdown flag for this domain in the store.
- */
-bool xs_resume_domain(struct xs_handle *h, unsigned int domid);
-
-/* Release a domain.
- * Tells the store domain to release the memory page to the domain.
- */
-bool xs_release_domain(struct xs_handle *h, unsigned int domid);
-
-/* Query the home path of a domain. Call free() after use.
- */
-char *xs_get_domain_path(struct xs_handle *h, unsigned int domid);
-
-/* Returns true if child is either equal to parent, or a node underneath
- * parent; or false otherwise. Done by string comparison, so relative and
- * absolute pathnames never in a parent/child relationship by this
- * definition. Cannot fail.
- */
-bool xs_path_is_subpath(const char *parent, const char *child);
-
-/* Return whether the domain specified has been introduced to xenstored.
- */
-bool xs_is_domain_introduced(struct xs_handle *h, unsigned int domid);
-
-/* Only useful for DEBUG versions */
-char *xs_debug_command(struct xs_handle *h, const char *cmd,
- void *data, unsigned int len);
-
-int xs_suspend_evtchn_port(int domid);
-#endif /* _XS_H */
-
-/*
- * Local variables:
- * c-file-style: "linux"
- * indent-tabs-mode: t
- * c-indent-level: 8
- * c-basic-offset: 8
- * tab-width: 8
- * End:
- */
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
-#include "xs_lib.h"
+#include "xenstore_lib.h"
/* Common routines for the Xen store daemon and client library. */
+++ /dev/null
-/*
- Common routines between Xen store user library and daemon.
- Copyright (C) 2005 Rusty Russell IBM Corporation
-
- This library 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; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library 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.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-#ifndef _XS_LIB_H
-#define _XS_LIB_H
-
-#include <stdbool.h>
-#include <limits.h>
-#include <errno.h>
-#include <stdint.h>
-#include <xen/io/xs_wire.h>
-
-/* Bitmask of permissions. */
-enum xs_perm_type {
- XS_PERM_NONE = 0,
- XS_PERM_READ = 1,
- XS_PERM_WRITE = 2,
- /* Internal use. */
- XS_PERM_ENOENT_OK = 4,
- XS_PERM_OWNER = 8,
-};
-
-struct xs_permissions
-{
- unsigned int id;
- enum xs_perm_type perms;
-};
-
-/* Each 10 bits takes ~ 3 digits, plus one, plus one for nul terminator. */
-#define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2)
-
-/* Path for various daemon things: env vars can override. */
-const char *xs_daemon_rootdir(void);
-const char *xs_daemon_rundir(void);
-const char *xs_daemon_socket(void);
-const char *xs_daemon_socket_ro(void);
-const char *xs_domain_dev(void);
-const char *xs_daemon_tdb(void);
-
-/* Simple write function: loops for you. */
-bool xs_write_all(int fd, const void *data, unsigned int len);
-
-/* Convert strings to permissions. False if a problem. */
-bool xs_strings_to_perms(struct xs_permissions *perms, unsigned int num,
- const char *strings);
-
-/* Convert permissions to a string (up to len MAX_STRLEN(unsigned int)+1). */
-bool xs_perm_to_string(const struct xs_permissions *perm,
- char *buffer, size_t buf_len);
-
-/* Given a string and a length, count how many strings (nul terms). */
-unsigned int xs_count_strings(const char *strings, unsigned int len);
-
-/* Sanitising (quoting) possibly-binary strings. */
-struct expanding_buffer {
- char *buf;
- int avail;
-};
-
-/* Ensure that given expanding buffer has at least min_avail characters. */
-char *expanding_buffer_ensure(struct expanding_buffer *, int min_avail);
-
-/* sanitise_value() may return NULL if malloc fails. */
-char *sanitise_value(struct expanding_buffer *, const char *val, unsigned len);
-
-/* *out_len_r on entry is ignored; out must be at least strlen(in)+1 bytes. */
-void unsanitise_value(char *out, unsigned *out_len_r, const char *in);
-
-#endif /* _XS_LIB_H */
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
-#include "xs_lib.h"
+#include "xenstore_lib.h"
#include "tdb.h"
#include "talloc.h"
#include "utils.h"