2 * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
12 #include <common/compat/errno.hpp>
14 #include "readwrite.hpp"
17 * lttng_read and lttng_write take care of EINTR and partial read/write.
18 * Upon success, they return the "count" received as parameter.
19 * They can return a negative value if an error occurs.
20 * If a value lower than the requested "count" is returned, it means an
22 * The error can be checked by querying errno.
24 ssize_t
lttng_read(int fd
, void *buf
, size_t count
)
32 * Deny a read count that can be bigger then the returned value max size.
33 * This makes the function to never return an overflow value.
35 if (count
> SSIZE_MAX
) {
40 ret
= read(fd
, (char *) buf
+ i
, count
- i
);
43 continue; /* retry operation */
49 LTTNG_ASSERT(i
<= count
);
50 } while (count
- i
> 0 && ret
> 0);
61 ssize_t
lttng_write(int fd
, const void *buf
, size_t count
)
69 * Deny a write count that can be bigger then the returned value max size.
70 * This makes the function to never return an overflow value.
72 if (count
> SSIZE_MAX
) {
77 ret
= write(fd
, (char *) buf
+ i
, count
- i
);
80 continue; /* retry operation */
86 LTTNG_ASSERT(i
<= count
);
87 } while (count
- i
> 0 && ret
> 0);
This page took 0.030568 seconds and 4 git commands to generate.