1nbd_aio_pread_structured(3)         LIBNBD         nbd_aio_pread_structured(3)
2
3
4

NAME

6       nbd_aio_pread_structured - read from the NBD server
7

SYNOPSIS

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 (struct nbd_handle *h,
26                                          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

DESCRIPTION

33       Issue a read command to the NBD server.
34
35       To check if the command completed, call nbd_aio_command_completed(3).
36       Or supply the optional "completion_callback" which will be invoked as
37       described in "Completion callbacks" in libnbd(3).
38
39       Note that you must ensure "buf" is valid until the command has
40       completed.  Furthermore, if the "error" parameter to
41       "completion_callback" is set or if nbd_aio_command_completed(3) reports
42       failure, and if nbd_get_pread_initialize(3) returns true, then libnbd
43       sanitized "buf", but it is unspecified whether the contents of "buf"
44       will read as zero or as partial results from the server.  If
45       nbd_get_pread_initialize(3) returns false, then libnbd did not sanitize
46       "buf", and the contents are undefined on failure.
47
48       Other parameters behave as documented in nbd_pread_structured(3).
49
50       By default, libnbd will reject attempts to use this function with
51       parameters that are likely to result in server failure, such as
52       requesting an unknown command flag.  The nbd_set_strict_mode(3)
53       function can be used to alter which scenarios should await a server
54       reply rather than failing fast.
55

RETURN VALUE

57       This call returns the 64 bit cookie of the command.  The cookie is ≥ 1.
58       Cookies are unique (per libnbd handle, not globally).
59

ERRORS

61       On error "-1" is returned.
62
63       Refer to "ERROR HANDLING" in libnbd(3) for how to get further details
64       of the error.
65
66       The following parameters must not be NULL: "h", "buf".  For more
67       information see "Non-NULL parameters" in libnbd(3).
68

HANDLE STATE

70       The handle must be connected with the server, otherwise this call will
71       return an error.
72

VERSION

74       This function first appeared in libnbd 1.0.
75
76       If you need to test if this function is available at compile time check
77       if the following macro is defined:
78
79        #define LIBNBD_HAVE_NBD_AIO_PREAD_STRUCTURED 1
80

SEE ALSO

82       nbd_aio_command_completed(3), nbd_aio_pread(3), nbd_create(3),
83       nbd_get_pread_initialize(3), nbd_pread_structured(3),
84       nbd_set_pread_initialize(3), nbd_set_strict_mode(3), "Issuing
85       asynchronous commands" in libnbd(3), libnbd(3).
86

AUTHORS

88       Eric Blake
89
90       Richard W.M. Jones
91
93       Copyright (C) 2019-2021 Red Hat Inc.
94

LICENSE

96       This library is free software; you can redistribute it and/or modify it
97       under the terms of the GNU Lesser General Public License as published
98       by the Free Software Foundation; either version 2 of the License, or
99       (at your option) any later version.
100
101       This library is distributed in the hope that it will be useful, but
102       WITHOUT ANY WARRANTY; without even the implied warranty of
103       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
104       Lesser General Public License for more details.
105
106       You should have received a copy of the GNU Lesser General Public
107       License along with this library; if not, write to the Free Software
108       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
109       02110-1301 USA
110
111
112
113libnbd-1.14.2                     2023-01-03       nbd_aio_pread_structured(3)
Impressum