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

HANDLE STATE

71       The handle must be negotiating, otherwise this call will return an
72       error.
73

VERSION

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

SEE ALSO

83       nbd_add_meta_context(3), nbd_aio_opt_list_meta_context(3),
84       nbd_can_meta_context(3), nbd_clear_meta_contexts(3),
85       nbd_connect_uri(3), nbd_create(3), nbd_opt_go(3),
86       nbd_set_export_name(3), nbd_set_opt_mode(3), libnbd(3).
87

AUTHORS

89       Eric Blake
90
91       Richard W.M. Jones
92
94       Copyright (C) 2019-2021 Red Hat Inc.
95

LICENSE

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