1nbd_is_rotational(3)                LIBNBD                nbd_is_rotational(3)
2
3
4

NAME

6       nbd_is_rotational - is the NBD disk rotational (like a disk)?
7

SYNOPSIS

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

DESCRIPTION

16       Returns true if the disk exposed over NBD is rotational (like a
17       traditional floppy or hard disk).  Returns false if the disk has no
18       penalty for random access (like an SSD or RAM disk).
19
20       This call does not block, because it returns data that is saved in the
21       handle from the NBD protocol handshake.
22

RETURN VALUE

24       This call returns a boolean value.
25

ERRORS

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

HANDLE STATE

36       The handle must be negotiating, or connected with the server, or shut
37       down, otherwise this call will return an error.
38

VERSION

40       This function first appeared in libnbd 1.0.
41
42       If you need to test if this function is available at compile time check
43       if the following macro is defined:
44
45        #define LIBNBD_HAVE_NBD_IS_ROTATIONAL 1
46

EXAMPLE

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

SEE ALSO

144       nbd_create(3), nbd_opt_info(3), "Flag calls" in libnbd(3), libnbd(3).
145

AUTHORS

147       Eric Blake
148
149       Richard W.M. Jones
150
152       Copyright Red Hat
153

LICENSE

155       This library is free software; you can redistribute it and/or modify it
156       under the terms of the GNU Lesser General Public License as published
157       by the Free Software Foundation; either version 2 of the License, or
158       (at your option) any later version.
159
160       This library is distributed in the hope that it will be useful, but
161       WITHOUT ANY WARRANTY; without even the implied warranty of
162       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
163       Lesser General Public License for more details.
164
165       You should have received a copy of the GNU Lesser General Public
166       License along with this library; if not, write to the Free Software
167       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
168       02110-1301 USA
169
170
171
172libnbd-1.16.5                     2023-09-26              nbd_is_rotational(3)
Impressum