cl349@5357: /* cl349@5357: Xen Store Daemon interface providing simple tree-like database. cl349@5357: Copyright (C) 2005 Rusty Russell IBM Corporation cl349@5357: kaf24@6008: This library is free software; you can redistribute it and/or kaf24@6008: modify it under the terms of the GNU Lesser General Public kaf24@6008: License as published by the Free Software Foundation; either kaf24@6008: version 2.1 of the License, or (at your option) any later version. cl349@5357: kaf24@6008: This library is distributed in the hope that it will be useful, cl349@5357: but WITHOUT ANY WARRANTY; without even the implied warranty of kaf24@6008: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU kaf24@6008: Lesser General Public License for more details. cl349@5357: kaf24@6008: You should have received a copy of the GNU Lesser General Public kaf24@6008: License along with this library; if not, write to the Free Software kaf24@6008: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA cl349@5357: */ cl349@5357: cl349@5357: #include cl349@5357: #include cl349@5357: #include cl349@5357: #include cl349@5357: #include cl349@5357: #include cl349@5357: #include cl349@5357: #include cl349@5357: #include cl349@5357: #include cl349@5357: #include cl349@5357: #include cl349@5357: #include cl349@5357: #include cl349@6601: #include cl349@5357: #include "xs.h" cl349@5357: #include "xenstored.h" cl349@5357: #include "xs_lib.h" cl349@5357: #include "utils.h" cl349@5357: cl349@5357: struct xs_handle cl349@5357: { cl349@5357: int fd; cl349@5357: }; cl349@5357: cl349@5357: /* Get the socket from the store daemon handle. cl349@5357: */ cl349@5357: int xs_fileno(struct xs_handle *h) cl349@5357: { cl349@5357: return h->fd; cl349@5357: } cl349@5357: cl349@5357: static struct xs_handle *get_socket(const char *connect_to) cl349@5357: { cl349@5357: struct sockaddr_un addr; cl349@5357: int sock, saved_errno; cl349@5357: struct xs_handle *h = NULL; cl349@5357: cl349@5357: sock = socket(PF_UNIX, SOCK_STREAM, 0); cl349@5357: if (sock < 0) cl349@5357: return NULL; cl349@5357: cl349@5357: addr.sun_family = AF_UNIX; cl349@5357: strcpy(addr.sun_path, connect_to); cl349@5357: cl349@5357: if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0) { cl349@5357: h = malloc(sizeof(*h)); cl349@5357: if (h) { cl349@5357: h->fd = sock; cl349@5357: return h; cl349@5357: } cl349@5357: } cl349@5357: cl349@5357: saved_errno = errno; cl349@5357: close(sock); cl349@6601: errno = saved_errno; cl349@6601: return NULL; cl349@6601: } cl349@6601: cl349@6601: static struct xs_handle *get_dev(const char *connect_to) cl349@6601: { cl349@6601: int fd, saved_errno; cl349@6749: struct xs_handle *h; cl349@6601: cl349@6749: fd = open(connect_to, O_RDWR); cl349@6601: if (fd < 0) cl349@6601: return NULL; cl349@6601: cl349@6601: h = malloc(sizeof(*h)); cl349@6601: if (h) { cl349@6601: h->fd = fd; cl349@6601: return h; cl349@6601: } cl349@6601: cl349@6601: saved_errno = errno; cl349@6601: close(fd); cl349@5357: errno = saved_errno; cl349@5357: return NULL; cl349@5357: } cl349@5357: cl349@6750: static struct xs_handle *get_handle(const char *connect_to) cl349@6750: { cl349@6750: struct stat buf; cl349@6750: cl349@6750: if (stat(connect_to, &buf) != 0) cl349@6750: return NULL; cl349@6750: cl349@6750: if (S_ISSOCK(buf.st_mode)) cl349@6750: return get_socket(connect_to); cl349@6750: else cl349@6750: return get_dev(connect_to); cl349@6750: } cl349@6750: cl349@5357: struct xs_handle *xs_daemon_open(void) cl349@5357: { cl349@6750: return get_handle(xs_daemon_socket()); cl349@5357: } cl349@5357: cl349@5357: struct xs_handle *xs_daemon_open_readonly(void) cl349@5357: { cl349@6750: return get_handle(xs_daemon_socket_ro()); cl349@5357: } cl349@5357: cl349@6601: struct xs_handle *xs_domain_open(void) cl349@6601: { cl349@6750: return get_handle(xs_domain_dev()); cl349@6601: } cl349@6601: cl349@5357: void xs_daemon_close(struct xs_handle *h) cl349@5357: { cl349@5357: if (h->fd >= 0) cl349@5357: close(h->fd); cl349@5357: free(h); cl349@5357: } cl349@5357: cl349@5357: static bool read_all(int fd, void *data, unsigned int len) cl349@5357: { cl349@5357: while (len) { cl349@5357: int done; cl349@5357: cl349@5357: done = read(fd, data, len); cl349@5357: if (done < 0) { cl349@5357: if (errno == EINTR) cl349@5357: continue; cl349@5357: return false; cl349@5357: } cl349@5357: if (done == 0) { cl349@5357: /* It closed fd on us? EBADF is appropriate. */ cl349@5357: errno = EBADF; cl349@5357: return false; cl349@5357: } cl349@5357: data += done; cl349@5357: len -= done; cl349@5357: } cl349@5357: cl349@5357: return true; cl349@5357: } cl349@5357: cl349@5357: #ifdef XSTEST cl349@5357: #define read_all read_all_choice kaf24@5423: #define xs_write_all write_all_choice cl349@5357: #endif cl349@5357: cl349@5357: static int get_error(const char *errorstring) cl349@5357: { cl349@5357: unsigned int i; cl349@5357: cl349@5357: for (i = 0; !streq(errorstring, xsd_errors[i].errstring); i++) cl349@5357: if (i == ARRAY_SIZE(xsd_errors) - 1) cl349@5357: return EINVAL; cl349@5357: return xsd_errors[i].errnum; cl349@5357: } cl349@5357: cl349@5522: /* Adds extra nul terminator, because we generally (always?) hold strings. */ cl349@5357: static void *read_reply(int fd, enum xsd_sockmsg_type *type, unsigned int *len) cl349@5357: { cl349@5357: struct xsd_sockmsg msg; cl349@5357: void *ret; cl349@5357: int saved_errno; cl349@5357: cl349@5357: if (!read_all(fd, &msg, sizeof(msg))) cl349@5357: return NULL; cl349@5357: cl349@5522: ret = malloc(msg.len + 1); cl349@5357: if (!ret) cl349@5357: return NULL; cl349@5357: cl349@5357: if (!read_all(fd, ret, msg.len)) { cl349@5357: saved_errno = errno; cl349@5357: free(ret); cl349@5357: errno = saved_errno; cl349@5357: return NULL; cl349@5357: } cl349@5357: cl349@5357: *type = msg.type; cl349@5357: if (len) cl349@5357: *len = msg.len; cl349@5522: ((char *)ret)[msg.len] = '\0'; cl349@5357: return ret; cl349@5357: } cl349@5357: cl349@5357: /* Send message to xs, get malloc'ed reply. NULL and set errno on error. */ cl349@6749: static void *xs_talkv(struct xs_handle *h, enum xsd_sockmsg_type type, cl349@6749: const struct iovec *iovec, unsigned int num_vecs, cl349@6749: unsigned int *len) cl349@5357: { cl349@5357: struct xsd_sockmsg msg; cl349@5357: void *ret = NULL; cl349@5357: int saved_errno; cl349@5357: unsigned int i; cl349@5357: struct sigaction ignorepipe, oldact; cl349@5357: cl349@5357: msg.type = type; cl349@5357: msg.len = 0; cl349@5357: for (i = 0; i < num_vecs; i++) cl349@5357: msg.len += iovec[i].iov_len; cl349@5357: cl349@5357: ignorepipe.sa_handler = SIG_IGN; cl349@5357: sigemptyset(&ignorepipe.sa_mask); cl349@5357: ignorepipe.sa_flags = 0; cl349@5357: sigaction(SIGPIPE, &ignorepipe, &oldact); cl349@5357: kaf24@5423: if (!xs_write_all(h->fd, &msg, sizeof(msg))) cl349@5357: goto fail; cl349@5357: cl349@5357: for (i = 0; i < num_vecs; i++) kaf24@5423: if (!xs_write_all(h->fd, iovec[i].iov_base, iovec[i].iov_len)) cl349@5357: goto fail; cl349@5357: cl349@5357: /* Watches can have fired before reply comes: daemon detects cl349@5357: * and re-transmits, so we can ignore this. */ cl349@5357: do { cl349@5357: free(ret); cl349@5357: ret = read_reply(h->fd, &msg.type, len); cl349@5357: if (!ret) cl349@5357: goto fail; cl349@5357: } while (msg.type == XS_WATCH_EVENT); cl349@5357: cl349@5357: sigaction(SIGPIPE, &oldact, NULL); cl349@5357: if (msg.type == XS_ERROR) { cl349@5357: saved_errno = get_error(ret); cl349@5357: free(ret); cl349@5357: errno = saved_errno; cl349@5357: return NULL; cl349@5357: } cl349@5357: kaf24@6043: if (msg.type != type) { kaf24@6043: free(ret); kaf24@6043: saved_errno = EBADF; kaf24@6043: goto close_fd; kaf24@6043: kaf24@6043: } cl349@5357: return ret; cl349@5357: cl349@5357: fail: cl349@5357: /* We're in a bad state, so close fd. */ cl349@5357: saved_errno = errno; cl349@5357: sigaction(SIGPIPE, &oldact, NULL); kaf24@6043: close_fd: cl349@5357: close(h->fd); cl349@5357: h->fd = -1; cl349@5357: errno = saved_errno; cl349@5357: return NULL; cl349@5357: } cl349@5357: cl349@5357: /* free(), but don't change errno. */ cl349@5357: static void free_no_errno(void *p) cl349@5357: { cl349@5357: int saved_errno = errno; cl349@5357: free(p); cl349@5357: errno = saved_errno; cl349@5357: } cl349@5357: cl349@5357: /* Simplified version of xs_talkv: single message. */ cl349@5357: static void *xs_single(struct xs_handle *h, enum xsd_sockmsg_type type, cl349@5357: const char *string, unsigned int *len) cl349@5357: { cl349@5357: struct iovec iovec; cl349@5357: cl349@5357: iovec.iov_base = (void *)string; cl349@5357: iovec.iov_len = strlen(string) + 1; cl349@5357: return xs_talkv(h, type, &iovec, 1, len); cl349@5357: } cl349@5357: cl349@5357: static bool xs_bool(char *reply) cl349@5357: { cl349@5357: if (!reply) cl349@5357: return false; cl349@5357: free(reply); cl349@5357: return true; cl349@5357: } cl349@5357: cl349@5357: char **xs_directory(struct xs_handle *h, const char *path, unsigned int *num) cl349@5357: { cl349@5357: char *strings, *p, **ret; cl349@5357: unsigned int len; cl349@5357: cl349@5357: strings = xs_single(h, XS_DIRECTORY, path, &len); cl349@5357: if (!strings) cl349@5357: return NULL; cl349@5357: cl349@5357: /* Count the strings. */ kaf24@5423: *num = xs_count_strings(strings, len); cl349@5357: cl349@5357: /* Transfer to one big alloc for easy freeing. */ cl349@5357: ret = malloc(*num * sizeof(char *) + len); cl349@5357: if (!ret) { cl349@5357: free_no_errno(strings); cl349@5357: return NULL; cl349@5357: } cl349@5357: memcpy(&ret[*num], strings, len); cl349@5357: free_no_errno(strings); cl349@5357: cl349@5357: strings = (char *)&ret[*num]; cl349@5357: for (p = strings, *num = 0; p < strings + len; p += strlen(p) + 1) cl349@5357: ret[(*num)++] = p; cl349@5357: return ret; cl349@5357: } cl349@5357: cl349@5522: /* Get the value of a single file, nul terminated. cl349@5357: * Returns a malloced value: call free() on it after use. cl349@5522: * len indicates length in bytes, not including the nul. cl349@5357: */ cl349@5357: void *xs_read(struct xs_handle *h, const char *path, unsigned int *len) cl349@5357: { cl349@5357: return xs_single(h, XS_READ, path, len); cl349@5357: } cl349@5357: cl349@5357: /* Write the value of a single file. cl349@5357: * Returns false on failure. createflags can be 0, O_CREAT, or O_CREAT|O_EXCL. cl349@5357: */ cl349@5357: bool xs_write(struct xs_handle *h, const char *path, cl349@5357: const void *data, unsigned int len, int createflags) cl349@5357: { cl349@5357: const char *flags; cl349@5357: struct iovec iovec[3]; cl349@5357: cl349@5357: /* Format: Flags (as string), path, data. */ cl349@5357: if (createflags == 0) cl349@5357: flags = XS_WRITE_NONE; cl349@5357: else if (createflags == O_CREAT) cl349@5357: flags = XS_WRITE_CREATE; cl349@5357: else if (createflags == (O_CREAT|O_EXCL)) cl349@5357: flags = XS_WRITE_CREATE_EXCL; cl349@5357: else { cl349@5357: errno = EINVAL; cl349@5357: return false; cl349@5357: } cl349@5357: cl349@5357: iovec[0].iov_base = (void *)path; cl349@5357: iovec[0].iov_len = strlen(path) + 1; cl349@5357: iovec[1].iov_base = (void *)flags; cl349@5357: iovec[1].iov_len = strlen(flags) + 1; cl349@5357: iovec[2].iov_base = (void *)data; cl349@5357: iovec[2].iov_len = len; cl349@5357: cl349@5357: return xs_bool(xs_talkv(h, XS_WRITE, iovec, ARRAY_SIZE(iovec), NULL)); cl349@5357: } cl349@5357: cl349@5357: /* Create a new directory. cl349@5357: * Returns false on failure. cl349@5357: */ cl349@5357: bool xs_mkdir(struct xs_handle *h, const char *path) cl349@5357: { cl349@5357: return xs_bool(xs_single(h, XS_MKDIR, path, NULL)); cl349@5357: } cl349@5357: cl349@5357: /* Destroy a file or directory (directories must be empty). cl349@5357: * Returns false on failure. cl349@5357: */ cl349@5357: bool xs_rm(struct xs_handle *h, const char *path) cl349@5357: { cl349@5357: return xs_bool(xs_single(h, XS_RM, path, NULL)); cl349@5357: } cl349@5357: cl349@5357: /* Get permissions of node (first element is owner). cl349@5357: * Returns malloced array, or NULL: call free() after use. cl349@5357: */ cl349@5357: struct xs_permissions *xs_get_permissions(struct xs_handle *h, cl349@5478: const char *path, unsigned int *num) cl349@5357: { cl349@5357: char *strings; cl349@5357: unsigned int len; cl349@5357: struct xs_permissions *ret; cl349@5357: cl349@5357: strings = xs_single(h, XS_GET_PERMS, path, &len); cl349@5357: if (!strings) cl349@5357: return NULL; cl349@5357: cl349@5357: /* Count the strings: each one perms then domid. */ kaf24@5423: *num = xs_count_strings(strings, len); cl349@5357: cl349@5357: /* Transfer to one big alloc for easy freeing. */ cl349@5357: ret = malloc(*num * sizeof(struct xs_permissions)); cl349@5357: if (!ret) { cl349@5357: free_no_errno(strings); cl349@5357: return NULL; cl349@5357: } cl349@5357: kaf24@5423: if (!xs_strings_to_perms(ret, *num, strings)) { cl349@5357: free_no_errno(ret); cl349@5357: ret = NULL; cl349@5357: } cl349@5357: cl349@5357: free(strings); cl349@5357: return ret; cl349@5357: } cl349@5357: cl349@5357: /* Set permissions of node (must be owner). cl349@5357: * Returns false on failure. cl349@5357: */ cl349@5357: bool xs_set_permissions(struct xs_handle *h, const char *path, cl349@5357: struct xs_permissions *perms, cl349@5357: unsigned int num_perms) cl349@5357: { cl349@5357: unsigned int i; cl349@5357: struct iovec iov[1+num_perms]; cl349@5357: cl349@5357: iov[0].iov_base = (void *)path; cl349@5357: iov[0].iov_len = strlen(path) + 1; cl349@5357: cl349@5357: for (i = 0; i < num_perms; i++) { cl349@5357: char buffer[MAX_STRLEN(domid_t)+1]; cl349@5357: kaf24@5423: if (!xs_perm_to_string(&perms[i], buffer)) cl349@5357: goto unwind; cl349@5357: cl349@5357: iov[i+1].iov_base = strdup(buffer); cl349@5357: iov[i+1].iov_len = strlen(buffer) + 1; cl349@5357: if (!iov[i+1].iov_base) cl349@5357: goto unwind; cl349@5357: } cl349@5357: cl349@5357: if (!xs_bool(xs_talkv(h, XS_SET_PERMS, iov, 1+num_perms, NULL))) cl349@5357: goto unwind; cl349@5357: for (i = 0; i < num_perms; i++) cl349@5357: free(iov[i+1].iov_base); cl349@5357: return true; cl349@5357: cl349@5357: unwind: cl349@5357: num_perms = i; cl349@5357: for (i = 0; i < num_perms; i++) cl349@5357: free_no_errno(iov[i+1].iov_base); cl349@5357: return false; cl349@5357: } cl349@5357: cl349@5357: /* Watch a node for changes (poll on fd to detect, or call read_watch()). cl349@5357: * When the node (or any child) changes, fd will become readable. cl349@5478: * Token is returned when watch is read, to allow matching. cl349@5357: * Returns false on failure. cl349@5357: */ cl349@5856: bool xs_watch(struct xs_handle *h, const char *path, const char *token) cl349@5357: { cl349@5856: struct iovec iov[2]; cl349@5357: cl349@5357: iov[0].iov_base = (void *)path; cl349@5357: iov[0].iov_len = strlen(path) + 1; cl349@5478: iov[1].iov_base = (void *)token; cl349@5478: iov[1].iov_len = strlen(token) + 1; cl349@5357: cl349@5357: return xs_bool(xs_talkv(h, XS_WATCH, iov, ARRAY_SIZE(iov), NULL)); cl349@5357: } cl349@5357: cl349@5357: /* Find out what node change was on (will block if nothing pending). cl349@5478: * Returns array of two pointers: path and token, or NULL. cl349@5478: * Call free() after use. cl349@5357: */ cl349@5478: char **xs_read_watch(struct xs_handle *h) cl349@5357: { cl349@5357: struct xsd_sockmsg msg; cl349@5478: char **ret; cl349@5357: cl349@5357: if (!read_all(h->fd, &msg, sizeof(msg))) cl349@5357: return NULL; cl349@5357: cl349@5357: assert(msg.type == XS_WATCH_EVENT); cl349@5478: ret = malloc(sizeof(char *)*2 + msg.len); cl349@5478: if (!ret) cl349@5357: return NULL; cl349@5357: cl349@5478: ret[0] = (char *)(ret + 2); cl349@5478: if (!read_all(h->fd, ret[0], msg.len)) { cl349@5478: free_no_errno(ret); cl349@5357: return NULL; cl349@5357: } cl349@5478: ret[1] = ret[0] + strlen(ret[0]) + 1; cl349@5478: return ret; cl349@5357: } cl349@5357: cl349@5357: /* Acknowledge watch on node. Watches must be acknowledged before cl349@5357: * any other watches can be read. cl349@5357: * Returns false on failure. cl349@5357: */ cl349@5478: bool xs_acknowledge_watch(struct xs_handle *h, const char *token) cl349@5357: { cl349@5478: return xs_bool(xs_single(h, XS_WATCH_ACK, token, NULL)); cl349@5357: } cl349@5357: cl349@5357: /* Remove a watch on a node. cl349@5357: * Returns false on failure (no watch on that node). cl349@5357: */ cl349@5478: bool xs_unwatch(struct xs_handle *h, const char *path, const char *token) cl349@5357: { cl349@5478: struct iovec iov[2]; cl349@5478: cl349@5478: iov[0].iov_base = (char *)path; cl349@5478: iov[0].iov_len = strlen(path) + 1; cl349@5478: iov[1].iov_base = (char *)token; cl349@5478: iov[1].iov_len = strlen(token) + 1; cl349@5478: cl349@5478: return xs_bool(xs_talkv(h, XS_UNWATCH, iov, ARRAY_SIZE(iov), NULL)); cl349@5357: } cl349@5357: cl349@5357: /* Start a transaction: changes by others will not be seen during this cl349@5357: * transaction, and changes will not be visible to others until end. cl349@5357: * Transaction only applies to the given subtree. cl349@5357: * You can only have one transaction at any time. cl349@5357: * Returns false on failure. cl349@5357: */ cl349@5357: bool xs_transaction_start(struct xs_handle *h, const char *subtree) cl349@5357: { cl349@5357: return xs_bool(xs_single(h, XS_TRANSACTION_START, subtree, NULL)); cl349@5357: } cl349@5357: cl349@5357: /* End a transaction. cl349@5357: * If abandon is true, transaction is discarded instead of committed. cl349@5357: * Returns false on failure, which indicates an error: transactions will cl349@5357: * not fail spuriously. cl349@5357: */ cl349@5357: bool xs_transaction_end(struct xs_handle *h, bool abort) cl349@5357: { cl349@5357: char abortstr[2]; cl349@5357: cl349@5357: if (abort) cl349@5357: strcpy(abortstr, "F"); cl349@5357: else cl349@5357: strcpy(abortstr, "T"); cl349@5357: return xs_bool(xs_single(h, XS_TRANSACTION_END, abortstr, NULL)); cl349@5357: } cl349@5357: cl349@5357: /* Introduce a new domain. cl349@5357: * This tells the store daemon about a shared memory page and event channel cl349@5357: * associated with a domain: the domain uses these to communicate. cl349@5357: */ cl349@5478: bool xs_introduce_domain(struct xs_handle *h, domid_t domid, unsigned long mfn, cl349@5478: unsigned int eventchn, const char *path) cl349@5357: { cl349@5357: char domid_str[MAX_STRLEN(domid)]; cl349@5357: char mfn_str[MAX_STRLEN(mfn)]; cl349@5357: char eventchn_str[MAX_STRLEN(eventchn)]; cl349@5357: struct iovec iov[4]; cl349@5357: cl349@5357: sprintf(domid_str, "%u", domid); cl349@5357: sprintf(mfn_str, "%lu", mfn); cl349@5357: sprintf(eventchn_str, "%u", eventchn); cl349@5357: cl349@5357: iov[0].iov_base = domid_str; cl349@5357: iov[0].iov_len = strlen(domid_str) + 1; cl349@5357: iov[1].iov_base = mfn_str; cl349@5357: iov[1].iov_len = strlen(mfn_str) + 1; cl349@5357: iov[2].iov_base = eventchn_str; cl349@5357: iov[2].iov_len = strlen(eventchn_str) + 1; cl349@5357: iov[3].iov_base = (char *)path; cl349@5357: iov[3].iov_len = strlen(path) + 1; cl349@5357: cl349@5357: return xs_bool(xs_talkv(h, XS_INTRODUCE, iov, ARRAY_SIZE(iov), NULL)); cl349@5357: } cl349@5357: cl349@5478: bool xs_release_domain(struct xs_handle *h, domid_t domid) cl349@5357: { cl349@5357: char domid_str[MAX_STRLEN(domid)]; cl349@5357: cl349@5357: sprintf(domid_str, "%u", domid); cl349@5357: cl349@5357: return xs_bool(xs_single(h, XS_RELEASE, domid_str, NULL)); cl349@5357: } cl349@5357: cl349@6625: char *xs_get_domain_path(struct xs_handle *h, domid_t domid) cl349@6625: { cl349@6625: char domid_str[MAX_STRLEN(domid)]; cl349@6625: cl349@6625: sprintf(domid_str, "%u", domid); cl349@6625: cl349@6625: return xs_single(h, XS_GET_DOMAIN_PATH, domid_str, NULL); cl349@6625: } cl349@6625: cl349@5357: bool xs_shutdown(struct xs_handle *h) cl349@5357: { cl349@5357: bool ret = xs_bool(xs_single(h, XS_SHUTDOWN, "", NULL)); cl349@5357: if (ret) { cl349@5357: char c; cl349@5357: /* Wait for it to actually shutdown. */ kaf24@6636: while ((read(h->fd, &c, 1) < 0) && (errno == EINTR)) kaf24@6636: continue; cl349@5357: } cl349@5357: return ret; cl349@5357: } cl349@5357: cl349@5357: /* Only useful for DEBUG versions */ cl349@5357: char *xs_debug_command(struct xs_handle *h, const char *cmd, cl349@5357: void *data, unsigned int len) cl349@5357: { cl349@5357: struct iovec iov[2]; cl349@5357: cl349@5357: iov[0].iov_base = (void *)cmd; cl349@5357: iov[0].iov_len = strlen(cmd) + 1; cl349@5357: iov[1].iov_base = data; cl349@5357: iov[1].iov_len = len; cl349@5357: cl349@5357: return xs_talkv(h, XS_DEBUG, iov, ARRAY_SIZE(iov), NULL); cl349@5357: }