From 9870b77f9000c55bbe507bbb11d6d20fac2e8da0 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 15 Apr 2021 14:34:55 -0400 Subject: util: Tweak the safe read/write functions --- util.h | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'util.h') diff --git a/util.h b/util.h index 7293d50..1b52513 100644 --- a/util.h +++ b/util.h @@ -226,23 +226,22 @@ int bfs_major(dev_t dev); int bfs_minor(dev_t dev); /** - * A safe version of read() that handles interrupted system calls. - */ -ssize_t safe_read(int fd, void *buf, size_t nbytes); - -/** - * A safe version of read() that handles interrupted system calls and partial reads. - */ -ssize_t safe_read_all(int fd, void *buf, size_t nbytes); - -/** - * A safe version of write() that handles interrupted system calls. + * A safe version of read() that handles interrupted system calls and partial + * reads. + * + * @return + * The number of bytes read. A value != nbytes indicates an error + * (errno != 0) or end of file (errno == 0). */ -ssize_t safe_write(int fd, const void *buf, size_t nbytes); +size_t xread(int fd, void *buf, size_t nbytes); /** - * A safe version of write() that handles interrupted system calls and partial writes. + * A safe version of write() that handles interrupted system calls and partial + * writes. + * + * @return + The number of bytes written. A value != nbytes indicates an error. */ -ssize_t safe_write_all(int fd, const void *buf, size_t nbytes); +size_t xwrite(int fd, const void *buf, size_t nbytes); #endif // BFS_UTIL_H -- cgit v1.2.3