1nbd_can_fast_zero(3)                LIBNBD                nbd_can_fast_zero(3)
2
3
4

NAME

6       nbd_can_fast_zero - does the server support the fast zero flag?
7

SYNOPSIS

9        #include <libnbd.h>
10
11        int nbd_can_fast_zero (struct nbd_handle *h);
12

DESCRIPTION

14       Returns true if the server supports the use of the
15       "LIBNBD_CMD_FLAG_FAST_ZERO" flag to the zero command (see "nbd_zero",
16       "nbd_aio_zero").  Returns false if the server does not.
17
18       This call does not block, because it returns data that is saved in the
19       handle from the NBD protocol handshake.
20

RETURN VALUE

22       This call returns a boolean value.
23

ERRORS

25       On error "-1" is returned.
26
27       Refer to "ERROR HANDLING" in libnbd(3) for how to get further details
28       of the error.
29

HANDLE STATE

31       The handle must be connected and finished handshaking with the server,
32       or shut down, otherwise this call will return an error.
33

VERSION

35       This function first appeared in libnbd 1.2.
36
37       If you need to test if this function is available at compile time check
38       if the following macro is defined:
39
40        #define LIBNBD_HAVE_NBD_CAN_FAST_ZERO 1
41

EXAMPLE

43       This example is also available as examples/server-flags.c in the libnbd
44       source code.
45
46        /* This example shows how to connect to an NBD
47         * server and print the export flags.
48         *
49         * You can test it with nbdkit like this:
50         *
51         * nbdkit -U - memory 1M \
52         *   --run './server-flags $unixsocket'
53         */
54
55        #include <stdio.h>
56        #include <stdlib.h>
57
58        #include <libnbd.h>
59
60        int
61        main (int argc, char *argv[])
62        {
63          struct nbd_handle *nbd;
64          int flag;
65
66          if (argc != 2) {
67            fprintf (stderr, "%s socket\n", argv[0]);
68            exit (EXIT_FAILURE);
69          }
70
71          /* Create the libnbd handle. */
72          nbd = nbd_create ();
73          if (nbd == NULL) {
74            fprintf (stderr, "%s\n", nbd_get_error ());
75            exit (EXIT_FAILURE);
76          }
77
78          /* Connect to the NBD server over a
79           * Unix domain socket.
80           */
81          if (nbd_connect_unix (nbd, argv[1]) == -1) {
82            fprintf (stderr, "%s\n", nbd_get_error ());
83            exit (EXIT_FAILURE);
84          }
85
86          /* Read and print the flags. */
87        #define PRINT_FLAG(flag_fn)                     \
88          flag = flag_fn (nbd);                         \
89          if (flag == -1) {                             \
90            fprintf (stderr, "%s\n", nbd_get_error ()); \
91            exit (EXIT_FAILURE);                        \
92          }                                             \
93          printf (#flag_fn " = %s\n",                   \
94                  flag ? "true" : "false");
95
96          PRINT_FLAG (nbd_can_cache);
97          PRINT_FLAG (nbd_can_df);
98          PRINT_FLAG (nbd_can_flush);
99          PRINT_FLAG (nbd_can_fua);
100          PRINT_FLAG (nbd_can_multi_conn);
101          PRINT_FLAG (nbd_can_trim);
102          PRINT_FLAG (nbd_can_zero);
103        #if LIBNBD_HAVE_NBD_CAN_FAST_ZERO /* Added in 1.2 */
104          PRINT_FLAG (nbd_can_fast_zero);
105        #endif
106          PRINT_FLAG (nbd_is_read_only);
107          PRINT_FLAG (nbd_is_rotational);
108
109          /* Close the libnbd handle. */
110          nbd_close (nbd);
111
112          exit (EXIT_SUCCESS);
113        }
114

SEE ALSO

116       "Flag calls" in libnbd(3), nbd_zero(3), nbd_aio_zero(3),
117       nbd_can_zero(3), nbd_create(3), libnbd(3).
118

AUTHORS

120       Eric Blake
121
122       Richard W.M. Jones
123
125       Copyright (C) 2019 Red Hat Inc.
126

LICENSE

128       This library is free software; you can redistribute it and/or modify it
129       under the terms of the GNU Lesser General Public License as published
130       by the Free Software Foundation; either version 2 of the License, or
131       (at your option) any later version.
132
133       This library is distributed in the hope that it will be useful, but
134       WITHOUT ANY WARRANTY; without even the implied warranty of
135       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
136       Lesser General Public License for more details.
137
138       You should have received a copy of the GNU Lesser General Public
139       License along with this library; if not, write to the Free Software
140       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
141       02110-1301 USA
142
143
144
145libnbd-1.2.1                      2019-11-14              nbd_can_fast_zero(3)
Impressum