Lines Matching +full:num +full:- +full:strings
110 xs_suspend_active--; in xs_suspend_exit()
125 req->type = req->msg.type; in xs_request_enter()
135 if (req->type == XS_TRANSACTION_START && !req->user_req) in xs_request_enter()
148 xs_state_users--; in xs_request_exit()
149 if ((req->type == XS_TRANSACTION_START && req->msg.type == XS_ERROR) || in xs_request_exit()
150 (req->type == XS_TRANSACTION_END && !req->user_req && in xs_request_exit()
151 !WARN_ON_ONCE(req->msg.type == XS_ERROR && in xs_request_exit()
152 !strcmp(req->body, "ENOENT")))) in xs_request_exit()
153 xs_state_users--; in xs_request_exit()
165 if (i == ARRAY_SIZE(xsd_errors) - 1) { in get_error()
200 if (req->state == xb_req_state_got_reply || !xenbus_ok()) { in test_reply()
201 /* read req->state before all other fields */ in test_reply()
206 /* Make sure to reread req->state each time. */ in test_reply()
215 wait_event(req->wq, test_reply(req)); in read_reply()
219 * If we are in the process of being shut-down there is in read_reply()
220 * no point of trying to contact XenBus - it is either in read_reply()
224 return ERR_PTR(-EIO); in read_reply()
225 if (req->err) in read_reply()
226 return ERR_PTR(req->err); in read_reply()
228 } while (req->state != xb_req_state_got_reply); in read_reply()
230 return req->body; in read_reply()
237 req->msg = *msg; in xs_send()
238 req->err = 0; in xs_send()
239 req->state = xb_req_state_queued; in xs_send()
240 init_waitqueue_head(&req->wq); in xs_send()
243 req->caller_req_id = req->msg.req_id; in xs_send()
244 req->msg.req_id = xs_request_enter(req); in xs_send()
250 kref_get(&req->kref); in xs_send()
253 list_add_tail(&req->list, &xb_write_list); in xs_send()
269 msg->type = req->msg.type; in xs_wait_for_reply()
270 msg->len = req->msg.len; in xs_wait_for_reply()
273 if (req->state == xb_req_state_queued || in xs_wait_for_reply()
274 req->state == xb_req_state_wait_reply) in xs_wait_for_reply()
275 req->state = xb_req_state_aborted; in xs_wait_for_reply()
277 kref_put(&req->kref, xs_free_req); in xs_wait_for_reply()
285 wake_up(&req->wq); in xs_wake_up()
295 return -ENOMEM; in xenbus_dev_request_and_reply()
298 vec->iov_len = msg->len; in xenbus_dev_request_and_reply()
299 vec->iov_base = msg + 1; in xenbus_dev_request_and_reply()
301 req->vec = vec; in xenbus_dev_request_and_reply()
302 req->num_vecs = 1; in xenbus_dev_request_and_reply()
303 req->cb = xenbus_dev_queue_reply; in xenbus_dev_request_and_reply()
304 req->par = par; in xenbus_dev_request_and_reply()
305 req->user_req = true; in xenbus_dev_request_and_reply()
306 kref_init(&req->kref); in xenbus_dev_request_and_reply()
329 return ERR_PTR(-ENOMEM); in xs_talkv()
331 req->vec = iovec; in xs_talkv()
332 req->num_vecs = num_vecs; in xs_talkv()
333 req->cb = xs_wake_up; in xs_talkv()
334 req->user_req = false; in xs_talkv()
335 kref_init(&req->kref); in xs_talkv()
356 return ERR_PTR(-err); in xs_talkv()
363 return ERR_PTR(-EINVAL); in xs_talkv()
390 static unsigned int count_strings(const char *strings, unsigned int len) in count_strings() argument
392 unsigned int num; in count_strings() local
395 for (p = strings, num = 0; p < strings + len; p += strlen(p) + 1) in count_strings()
396 num++; in count_strings()
398 return num; in count_strings()
410 return (!buffer) ? ERR_PTR(-ENOMEM) : buffer; in join()
413 static char **split(char *strings, unsigned int len, unsigned int *num) in split() argument
417 /* Count the strings. */ in split()
418 *num = count_strings(strings, len); in split()
421 ret = kmalloc(*num * sizeof(char *) + len, GFP_NOIO | __GFP_HIGH); in split()
423 kfree(strings); in split()
424 return ERR_PTR(-ENOMEM); in split()
426 memcpy(&ret[*num], strings, len); in split()
427 kfree(strings); in split()
429 strings = (char *)&ret[*num]; in split()
430 for (p = strings, *num = 0; p < strings + len; p += strlen(p) + 1) in split()
431 ret[(*num)++] = p; in split()
437 const char *dir, const char *node, unsigned int *num) in xenbus_directory() argument
439 char *strings, *path; in xenbus_directory() local
446 strings = xs_single(t, XS_DIRECTORY, path, &len); in xenbus_directory()
448 if (IS_ERR(strings)) in xenbus_directory()
449 return ERR_CAST(strings); in xenbus_directory()
451 return split(strings, len, num); in xenbus_directory()
491 * Returns -err on failure.
559 t->id = simple_strtoul(id_str, NULL, 0); in xenbus_transaction_start()
581 /* Single read and scanf: returns -errno or num scanned. */
599 return -ERANGE; in xenbus_scanf()
619 /* Single printf and write: returns -errno or 0. */
632 return -ENOMEM; in xenbus_printf()
642 /* Takes tuples of names, scanf-style args, and void **, NULL terminated. */
662 ret = -EINVAL; in xenbus_gather()
713 if (count_strings(event->body, event->len) != 2) { in xs_watch_msg()
715 return -EINVAL; in xs_watch_msg()
717 event->path = (const char *)event->body; in xs_watch_msg()
718 event->token = (const char *)strchr(event->body, '\0') + 1; in xs_watch_msg()
721 event->handle = find_watch(event->token); in xs_watch_msg()
722 if (event->handle != NULL && in xs_watch_msg()
723 (!event->handle->will_handle || in xs_watch_msg()
724 event->handle->will_handle(event->handle, in xs_watch_msg()
725 event->path, event->token))) { in xs_watch_msg()
727 list_add_tail(&event->list, &watch_events); in xs_watch_msg()
728 event->handle->nr_pending++; in xs_watch_msg()
742 * control/platform-feature-xs_reset_watches.
769 "platform-feature-xs_reset_watches", 0)) in xs_reset_watches()
773 if (err && err != -EEXIST) in xs_reset_watches()
786 watch->nr_pending = 0; in register_xenbus_watch()
792 list_add(&watch->list, &watches); in register_xenbus_watch()
795 err = xs_watch(watch->node, token); in register_xenbus_watch()
799 list_del(&watch->list); in register_xenbus_watch()
821 list_del(&watch->list); in unregister_xenbus_watch()
824 err = xs_unwatch(watch->node, token); in unregister_xenbus_watch()
826 pr_warn("Failed to release watch %s: %i\n", watch->node, err); in unregister_xenbus_watch()
832 if (current->pid != xenwatch_pid) in unregister_xenbus_watch()
837 if (watch->nr_pending) { in unregister_xenbus_watch()
839 if (event->handle != watch) in unregister_xenbus_watch()
841 list_del(&event->list); in unregister_xenbus_watch()
844 watch->nr_pending = 0; in unregister_xenbus_watch()
848 if (current->pid != xenwatch_pid) in unregister_xenbus_watch()
875 xs_watch(watch->node, token); in xs_resume()
893 xenwatch_pid = current->pid; in xenwatch_thread()
908 list_del(&event->list); in xenwatch_thread()
909 event->handle->nr_pending--; in xenwatch_thread()
914 event->handle->callback(event->handle, event->path, in xenwatch_thread()
915 event->token); in xenwatch_thread()
939 wake_up(&req->wq); in xs_reboot_notify()
941 wake_up(&req->wq); in xs_reboot_notify()