From a6dcc7e5924f9c27d3e9c6560a448b02ec28b65f Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Mon, 9 Mar 2015 21:23:53 -0400 Subject: Introduce loop_read_exact helper Usually when using loop_read(), we want to read the full buffer. Add a helper that mirrors loop_write(), and returns 0 when full buffer was read, and an error otherwise. Use -ENODATA for the short read, to distinguish it from a read error. --- src/shared/util.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/shared/util.h') diff --git a/src/shared/util.h b/src/shared/util.h index 2de654f4cc..d2da3e2895 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -432,6 +432,7 @@ int sigaction_many(const struct sigaction *sa, ...); int fopen_temporary(const char *path, FILE **_f, char **_temp_path); ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll); +int loop_read_exact(int fd, void *buf, size_t nbytes, bool do_poll); int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll); bool is_device_path(const char *path); -- cgit v1.2.3-54-g00ecf