diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2021-04-15 14:34:55 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2021-04-15 14:36:39 -0400 |
commit | 9870b77f9000c55bbe507bbb11d6d20fac2e8da0 (patch) | |
tree | 6dd24948300c2b1bd5cbca40ba52e4ac9178650c /util.h | |
parent | b7111f2f01dce9516aea5250e765124300f2fa3a (diff) | |
download | bfs-9870b77f9000c55bbe507bbb11d6d20fac2e8da0.tar.xz |
util: Tweak the safe read/write functions
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 27 |
1 files changed, 13 insertions, 14 deletions
@@ -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 |