summaryrefslogtreecommitdiffstats
path: root/util.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2021-04-15 14:34:55 -0400
committerTavian Barnes <tavianator@tavianator.com>2021-04-15 14:36:39 -0400
commit9870b77f9000c55bbe507bbb11d6d20fac2e8da0 (patch)
tree6dd24948300c2b1bd5cbca40ba52e4ac9178650c /util.h
parentb7111f2f01dce9516aea5250e765124300f2fa3a (diff)
downloadbfs-9870b77f9000c55bbe507bbb11d6d20fac2e8da0.tar.xz
util: Tweak the safe read/write functions
Diffstat (limited to 'util.h')
-rw-r--r--util.h27
1 files changed, 13 insertions, 14 deletions
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