1nbd_can_block_status_payload(3)     LIBNBD     nbd_can_block_status_payload(3)
2
3
4

NAME

6       nbd_can_block_status_payload - does the server support the block status
7       payload flag?
8

SYNOPSIS

10        #include <libnbd.h>
11
12        int nbd_can_block_status_payload (
13              struct nbd_handle *h
14            );
15

DESCRIPTION

17       Returns true if the server supports the use of the
18       "LIBNBD_CMD_FLAG_PAYLOAD_LEN" flag to allow filtering of the block
19       status command (see nbd_block_status_filter(3)).  Returns false if the
20       server does not.  Note that this will never return true if
21       nbd_get_extended_headers_negotiated(3) is false.
22
23       This call does not block, because it returns data that is saved in the
24       handle from the NBD protocol handshake.
25

RETURN VALUE

27       This call returns a boolean value.
28

ERRORS

30       On error -1 is returned.
31
32       Refer to "ERROR HANDLING" in libnbd(3) for how to get further details
33       of the error.
34
35       The following parameters must not be NULL: "h".  For more information
36       see "Non-NULL parameters" in libnbd(3).
37

HANDLE STATE

39       The handle must be negotiating, or connected with the server, or shut
40       down, otherwise this call will return an error.
41

VERSION

43       This function first appeared in libnbd 1.18.
44
45       If you need to test if this function is available at compile time check
46       if the following macro is defined:
47
48        #define LIBNBD_HAVE_NBD_CAN_BLOCK_STATUS_PAYLOAD 1
49

EXAMPLE

51       This example is also available as examples/server-flags.c in the libnbd
52       source code.
53
54        /* This example shows how to connect to an NBD
55         * server and print the export flags.
56         *
57         * You can test it with nbdkit like this:
58         *
59         * nbdkit -U - memory 1M \
60         *   --run './server-flags $unixsocket'
61         */
62
63        #include <stdio.h>
64        #include <stdlib.h>
65
66        #include <libnbd.h>
67
68        int
69        main (int argc, char *argv[])
70        {
71          struct nbd_handle *nbd;
72          char *str;
73          int flag;
74
75          if (argc != 2) {
76            fprintf (stderr, "%s socket\n", argv[0]);
77            exit (EXIT_FAILURE);
78          }
79
80          /* Create the libnbd handle. */
81          nbd = nbd_create ();
82          if (nbd == NULL) {
83            fprintf (stderr, "%s\n", nbd_get_error ());
84            exit (EXIT_FAILURE);
85          }
86
87          /* Request full information. */
88        #if LIBNBD_HAVE_NBD_SET_FULL_INFO /* Added in 1.4 */
89          if (nbd_set_full_info (nbd, true) == -1) {
90            fprintf (stderr, "%s\n", nbd_get_error ());
91            exit (EXIT_FAILURE);
92          }
93        #endif
94
95          /* Connect to the NBD server over a
96           * Unix domain socket.
97           */
98          if (nbd_connect_unix (nbd, argv[1]) == -1) {
99            fprintf (stderr, "%s\n", nbd_get_error ());
100            exit (EXIT_FAILURE);
101          }
102
103          /* See if the server provided extra details,
104           * using functions added in 1.4
105           */
106        #if LIBNBD_HAVE_NBD_GET_EXPORT_DESCRIPTION
107          str = nbd_get_canonical_export_name (nbd);
108          if (str)
109            printf ("canonical_name = %s\n", str);
110          free (str);
111          str = nbd_get_export_description (nbd);
112          if (str)
113            printf ("description = %s\n", str);
114          free (str);
115        #endif
116
117          /* Read and print the flags. */
118        #define PRINT_FLAG(flag_fn)                     \
119          flag = flag_fn (nbd);                         \
120          if (flag == -1) {                             \
121            fprintf (stderr, "%s\n", nbd_get_error ()); \
122            exit (EXIT_FAILURE);                        \
123          }                                             \
124          printf (#flag_fn " = %s\n",                   \
125                  flag ? "true" : "false");
126
127          PRINT_FLAG (nbd_can_cache);
128          PRINT_FLAG (nbd_can_df);
129          PRINT_FLAG (nbd_can_flush);
130          PRINT_FLAG (nbd_can_fua);
131          PRINT_FLAG (nbd_can_multi_conn);
132          PRINT_FLAG (nbd_can_trim);
133          PRINT_FLAG (nbd_can_zero);
134        #if LIBNBD_HAVE_NBD_CAN_FAST_ZERO
135          /* Added in 1.2 */
136          PRINT_FLAG (nbd_can_fast_zero);
137        #endif
138        #if LIBNBD_HAVE_NBD_CAN_BLOCK_STATUS_PAYLOAD
139          /* Added in 1.18 */
140          PRINT_FLAG (nbd_can_block_status_payload);
141        #endif
142          PRINT_FLAG (nbd_is_read_only);
143          PRINT_FLAG (nbd_is_rotational);
144
145          /* Close the libnbd handle. */
146          nbd_close (nbd);
147
148          exit (EXIT_SUCCESS);
149        }
150

SEE ALSO

152       nbd_block_status_filter(3), nbd_create(3),
153       nbd_get_extended_headers_negotiated(3), nbd_opt_info(3), "Flag calls"
154       in libnbd(3), libnbd(3).
155

AUTHORS

157       Eric Blake
158
159       Richard W.M. Jones
160
162       Copyright Red Hat
163

LICENSE

165       This library is free software; you can redistribute it and/or modify it
166       under the terms of the GNU Lesser General Public License as published
167       by the Free Software Foundation; either version 2 of the License, or
168       (at your option) any later version.
169
170       This library is distributed in the hope that it will be useful, but
171       WITHOUT ANY WARRANTY; without even the implied warranty of
172       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
173       Lesser General Public License for more details.
174
175       You should have received a copy of the GNU Lesser General Public
176       License along with this library; if not, write to the Free Software
177       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
178       02110-1301 USA
179
180
181
182libnbd-1.18.1                     2023-10-31   nbd_can_block_status_payload(3)
Impressum