2 * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
13 #include <common/compat/errno.h>
15 #include "readwrite.h"
18 * lttng_read and lttng_write take care of EINTR and partial read/write.
19 * Upon success, they return the "count" received as parameter.
20 * They can return a negative value if an error occurs.
21 * If a value lower than the requested "count" is returned, it means an
23 * The error can be checked by querying errno.
26 ssize_t
lttng_read(int fd
, void *buf
, size_t count
)
34 * Deny a read count that can be bigger then the returned value max size.
35 * This makes the function to never return an overflow value.
37 if (count
> SSIZE_MAX
) {
42 ret
= read(fd
, buf
+ i
, count
- i
);
45 continue; /* retry operation */
52 } while (count
- i
> 0 && ret
> 0);
64 ssize_t
lttng_write(int fd
, const void *buf
, size_t count
)
72 * Deny a write count that can be bigger then the returned value max size.
73 * This makes the function to never return an overflow value.
75 if (count
> SSIZE_MAX
) {
80 ret
= write(fd
, buf
+ i
, count
- i
);
83 continue; /* retry operation */
90 } while (count
- i
> 0 && ret
> 0);
This page took 0.038071 seconds and 4 git commands to generate.