ia64/xen-unstable

annotate tools/xenstore/xs_lib.h @ 19731:01748ccc4da3

Intel VT-d: fix Stoakley boot issue with iommu=1

Signed-off-by: Weidong Han <Weidong.han@intel.com>
Signed-off-by: Allen Kay <allen.m.kay@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 05 09:25:50 2009 +0100 (2009-06-05)
parents b47849b774f1
children
rev   line source
cl349@5357 1 /*
cl349@5357 2 Common routines between Xen store user library and daemon.
cl349@5357 3 Copyright (C) 2005 Rusty Russell IBM Corporation
cl349@5357 4
kaf24@6023 5 This library is free software; you can redistribute it and/or
kaf24@6023 6 modify it under the terms of the GNU Lesser General Public
kaf24@6023 7 License as published by the Free Software Foundation; either
kaf24@6023 8 version 2.1 of the License, or (at your option) any later version.
cl349@5357 9
kaf24@6023 10 This library is distributed in the hope that it will be useful,
cl349@5357 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
kaf24@6023 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
kaf24@6023 13 Lesser General Public License for more details.
cl349@5357 14
kaf24@6023 15 You should have received a copy of the GNU Lesser General Public
kaf24@6023 16 License along with this library; if not, write to the Free Software
kaf24@6023 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
cl349@5357 18 */
cl349@5478 19
cl349@5478 20 #ifndef _XS_LIB_H
cl349@5478 21 #define _XS_LIB_H
cl349@5478 22
cl349@5357 23 #include <stdbool.h>
cl349@5357 24 #include <limits.h>
kaf24@7268 25 #include <errno.h>
kaf24@7349 26 #include <stdint.h>
kaf24@7268 27 #include <xen/io/xs_wire.h>
cl349@5357 28
cl349@5357 29 /* Bitmask of permissions. */
cl349@5357 30 enum xs_perm_type {
cl349@5357 31 XS_PERM_NONE = 0,
cl349@5357 32 XS_PERM_READ = 1,
cl349@5357 33 XS_PERM_WRITE = 2,
cl349@5357 34 /* Internal use. */
cl349@5993 35 XS_PERM_ENOENT_OK = 4,
cl349@5357 36 XS_PERM_OWNER = 8,
cl349@5357 37 };
cl349@5357 38
cl349@5357 39 struct xs_permissions
cl349@5357 40 {
rusty@7039 41 unsigned int id;
cl349@5357 42 enum xs_perm_type perms;
cl349@5357 43 };
cl349@5357 44
cl349@5357 45 /* Each 10 bits takes ~ 3 digits, plus one, plus one for nul terminator. */
cl349@5357 46 #define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2)
cl349@5357 47
cl349@5357 48 /* Path for various daemon things: env vars can override. */
vhanquez@10046 49 const char *xs_daemon_rootdir(void);
vhanquez@10046 50 const char *xs_daemon_rundir(void);
cl349@5357 51 const char *xs_daemon_socket(void);
cl349@5357 52 const char *xs_daemon_socket_ro(void);
cl349@6619 53 const char *xs_domain_dev(void);
rusty@7039 54 const char *xs_daemon_tdb(void);
cl349@5357 55
cl349@5357 56 /* Simple write function: loops for you. */
kaf24@5423 57 bool xs_write_all(int fd, const void *data, unsigned int len);
cl349@5357 58
cl349@5357 59 /* Convert strings to permissions. False if a problem. */
kaf24@5423 60 bool xs_strings_to_perms(struct xs_permissions *perms, unsigned int num,
cl349@5478 61 const char *strings);
cl349@5357 62
kaf24@7349 63 /* Convert permissions to a string (up to len MAX_STRLEN(unsigned int)+1). */
keir@16074 64 bool xs_perm_to_string(const struct xs_permissions *perm,
keir@16074 65 char *buffer, size_t buf_len);
cl349@5357 66
cl349@5357 67 /* Given a string and a length, count how many strings (nul terms). */
kaf24@5423 68 unsigned int xs_count_strings(const char *strings, unsigned int len);
cl349@5357 69
keir@16532 70 /* Sanitising (quoting) possibly-binary strings. */
keir@16532 71 struct expanding_buffer {
keir@16532 72 char *buf;
keir@16532 73 int avail;
keir@16532 74 };
keir@16532 75
keir@16532 76 /* Ensure that given expanding buffer has at least min_avail characters. */
keir@16532 77 char *expanding_buffer_ensure(struct expanding_buffer *, int min_avail);
keir@16532 78
keir@16532 79 /* sanitise_value() may return NULL if malloc fails. */
keir@16532 80 char *sanitise_value(struct expanding_buffer *, const char *val, unsigned len);
keir@16532 81
keir@16532 82 /* *out_len_r on entry is ignored; out must be at least strlen(in)+1 bytes. */
keir@16532 83 void unsanitise_value(char *out, unsigned *out_len_r, const char *in);
keir@16532 84
cl349@5357 85 #endif /* _XS_LIB_H */