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 (struct nbd_handle *h);
12

DESCRIPTION

14       Returns true if the disk exposed over NBD is rotational (like a
15       traditional floppy or hard disk).  Returns false if the disk has no
16       penalty for random access (like an SSD or RAM disk).
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.0.
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_IS_ROTATIONAL 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_create(3), libnbd(3).
117

AUTHORS

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

LICENSE

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