1nbd_aio_pread_structured(3) LIBNBD nbd_aio_pread_structured(3)
2
3
4
6 nbd_aio_pread_structured - read from the NBD server
7
9 #include <libnbd.h>
10
11 typedef struct {
12 int (*callback) (void *user_data, const void *subbuf,
13 size_t count, uint64_t offset,
14 unsigned status, int *error);
15 void *user_data;
16 void (*free) (void *user_data);
17 } nbd_chunk_callback;
18
19 typedef struct {
20 int (*callback) (void *user_data, int *error);
21 void *user_data;
22 void (*free) (void *user_data);
23 } nbd_completion_callback;
24
25 int64_t nbd_aio_pread_structured (
26 struct nbd_handle *h, void *buf, size_t count,
27 uint64_t offset,
28 nbd_chunk_callback chunk_callback,
29 nbd_completion_callback completion_callback,
30 uint32_t flags
31 );
32
34 Issue a read command to the NBD server.
35
36 To check if the command completed, call nbd_aio_command_completed(3).
37 Or supply the optional "completion_callback" which will be invoked as
38 described in "Completion callbacks" in libnbd(3).
39
40 Note that you must ensure "buf" is valid until the command has
41 completed. Furthermore, if the "error" parameter to
42 "completion_callback" is set or if nbd_aio_command_completed(3) reports
43 failure, and if nbd_get_pread_initialize(3) returns true, then libnbd
44 sanitized "buf", but it is unspecified whether the contents of "buf"
45 will read as zero or as partial results from the server. If
46 nbd_get_pread_initialize(3) returns false, then libnbd did not sanitize
47 "buf", and the contents are undefined on failure.
48
49 Other parameters behave as documented in nbd_pread_structured(3).
50
51 By default, libnbd will reject attempts to use this function with
52 parameters that are likely to result in server failure, such as
53 requesting an unknown command flag. The nbd_set_strict_mode(3)
54 function can be used to alter which scenarios should await a server
55 reply rather than failing fast.
56
58 This call returns the 64 bit cookie of the command. The cookie is ≥ 1.
59 Cookies are unique (per libnbd handle, not globally).
60
62 On error -1 is returned.
63
64 Refer to "ERROR HANDLING" in libnbd(3) for how to get further details
65 of the error.
66
67 The following parameters must not be NULL: "h", "buf". For more
68 information see "Non-NULL parameters" in libnbd(3).
69
71 The handle must be connected with the server, otherwise this call will
72 return an error.
73
75 This function first appeared in libnbd 1.0.
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_AIO_PREAD_STRUCTURED 1
81
83 nbd_aio_command_completed(3), nbd_aio_pread(3), nbd_create(3),
84 nbd_get_pread_initialize(3), nbd_pread_structured(3),
85 nbd_set_pread_initialize(3), nbd_set_strict_mode(3), "Issuing
86 asynchronous commands" in libnbd(3), libnbd(3).
87
89 Eric Blake
90
91 Richard W.M. Jones
92
94 Copyright Red Hat
95
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.16.5 2023-09-26 nbd_aio_pread_structured(3)