2 * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
14 #include "readwrite.h"
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.
25 ssize_t
lttng_read(int fd
, void *buf
, size_t count
)
33 * Deny a read count that can be bigger then the returned value max size.
34 * This makes the function to never return an overflow value.
36 if (count
> SSIZE_MAX
) {
41 ret
= read(fd
, buf
+ i
, count
- i
);
44 continue; /* retry operation */
51 } while (count
- i
> 0 && ret
> 0);
63 ssize_t
lttng_write(int fd
, const void *buf
, size_t count
)
71 * Deny a write count that can be bigger then the returned value max size.
72 * This makes the function to never return an overflow value.
74 if (count
> SSIZE_MAX
) {
79 ret
= write(fd
, buf
+ i
, count
- i
);
82 continue; /* retry operation */
89 } while (count
- i
> 0 && ret
> 0);
This page took 0.031605 seconds and 4 git commands to generate.