1nbd_opt_list_meta_context(3)        LIBNBD        nbd_opt_list_meta_context(3)
2
3
4

NAME

6       nbd_opt_list_meta_context - request the server to list available meta
7       contexts
8

SYNOPSIS

10        #include <libnbd.h>
11
12        typedef struct {
13          int (*callback) (void *user_data, const char *name);
14          void *user_data;
15          void (*free) (void *user_data);
16        } nbd_context_callback;
17
18        int nbd_opt_list_meta_context (struct nbd_handle *h,
19                                       nbd_context_callback context_callback);
20

DESCRIPTION

22       Request that the server list available meta contexts associated with
23       the export previously specified by the most recent
24       nbd_set_export_name(3) or nbd_connect_uri(3).  This can only be used if
25       nbd_set_opt_mode(3) enabled option mode.
26
27       The NBD protocol allows a client to decide how many queries to ask the
28       server.  Rather than taking that list of queries as a parameter to this
29       function, libnbd reuses the current list of requested meta contexts as
30       set by nbd_add_meta_context(3); you can use nbd_clear_meta_contexts(3)
31       to set up a different list of queries.  When the list is empty, a
32       server will typically reply with all contexts that it supports; when
33       the list is non-empty, the server will reply only with supported
34       contexts that match the client's request.  Note that a reply by the
35       server might be encoded to represent several feasible contexts within
36       one string, rather than multiple strings per actual context name that
37       would actually succeed during nbd_opt_go(3); so it is still necessary
38       to use nbd_can_meta_context(3) after connecting to see which contexts
39       are actually supported.
40
41       The "context" function is called once per server reply, with any
42       "user_data" passed to this function, and with "name" supplied by the
43       server.  Remember that it is not safe to call nbd_add_meta_context(3)
44       from within the context of the callback function; rather, your code
45       must copy any "name" needed for later use after this function
46       completes.  At present, the return value of the callback is ignored,
47       although a return of -1 should be avoided.
48
49       For convenience, when this function succeeds, it returns the number of
50       replies returned by the server.
51
52       Not all servers understand this request, and even when it is
53       understood, the server might intentionally send an empty list because
54       it does not support the requested context, or may encounter a failure
55       after delivering partial results.  Thus, this function may succeed even
56       when no contexts are reported, or may fail but have a non-empty list.
57       Likewise, the NBD protocol does not specify an upper bound for the
58       number of replies that might be advertised, so client code should be
59       aware that a server may send a lengthy list.
60

RETURN VALUE

62       This call returns an integer ≥ 0.
63

ERRORS

65       On error "-1" is returned.
66
67       Refer to "ERROR HANDLING" in libnbd(3) for how to get further details
68       of the error.
69
70       The following parameters must not be NULL: "h".  For more information
71       see "Non-NULL parameters" in libnbd(3).
72

HANDLE STATE

74       The handle must be negotiating, otherwise this call will return an
75       error.
76

VERSION

78       This function first appeared in libnbd 1.6.
79
80       If you need to test if this function is available at compile time check
81       if the following macro is defined:
82
83        #define LIBNBD_HAVE_NBD_OPT_LIST_META_CONTEXT 1
84

SEE ALSO

86       nbd_add_meta_context(3), nbd_aio_opt_list_meta_context(3),
87       nbd_can_meta_context(3), nbd_clear_meta_contexts(3),
88       nbd_connect_uri(3), nbd_create(3), nbd_opt_go(3),
89       nbd_set_export_name(3), nbd_set_opt_mode(3), libnbd(3).
90

AUTHORS

92       Eric Blake
93
94       Richard W.M. Jones
95
97       Copyright (C) 2019-2021 Red Hat Inc.
98

LICENSE

100       This library is free software; you can redistribute it and/or modify it
101       under the terms of the GNU Lesser General Public License as published
102       by the Free Software Foundation; either version 2 of the License, or
103       (at your option) any later version.
104
105       This library is distributed in the hope that it will be useful, but
106       WITHOUT ANY WARRANTY; without even the implied warranty of
107       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
108       Lesser General Public License for more details.
109
110       You should have received a copy of the GNU Lesser General Public
111       License along with this library; if not, write to the Free Software
112       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
113       02110-1301 USA
114
115
116
117libnbd-1.14.2                     2023-01-03      nbd_opt_list_meta_context(3)
Impressum