diff options
author | Ian Campbell <ian.campbell@citrix.com> | 2012-05-14 17:15:36 +0100 |
---|---|---|
committer | Ian Campbell <ian.campbell@citrix.com> | 2012-05-14 17:15:36 +0100 |
commit | debddaa56c84f5809774f34fdd190bc5f4a6cf16 (patch) | |
tree | da59df5612d82de5a163d67c7f9e4b3d86d84fe3 /tools/xenstore/xenstore_lib.h | |
parent | 633979eeb74ecf9200a2f86eff9ed3f09c12bea9 (diff) | |
download | xen-debddaa56c84f5809774f34fdd190bc5f4a6cf16.tar.gz xen-debddaa56c84f5809774f34fdd190bc5f4a6cf16.tar.bz2 xen-debddaa56c84f5809774f34fdd190bc5f4a6cf16.zip |
nstore: rename public xenstore headers
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
Diffstat (limited to 'tools/xenstore/xenstore_lib.h')
-rw-r--r-- | tools/xenstore/xenstore_lib.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/tools/xenstore/xenstore_lib.h b/tools/xenstore/xenstore_lib.h new file mode 100644 index 0000000000..5c2baf6b40 --- /dev/null +++ b/tools/xenstore/xenstore_lib.h @@ -0,0 +1,85 @@ +/* + 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 */ |