diff --git a/write_or_die.c b/write_or_die.c
index 650f13fc012b14a6aaa62534727d4ef9cdce58bd..6db1d3123d1761dee4850e0a56a9b86b4bf1722a 100644 (file)
--- a/write_or_die.c
+++ b/write_or_die.c
#include "cache.h"
#include "cache.h"
+void read_or_die(int fd, void *buf, size_t count)
+{
+ char *p = buf;
+ ssize_t loaded;
+
+ while (count > 0) {
+ loaded = xread(fd, p, count);
+ if (loaded == 0)
+ die("unexpected end of file");
+ else if (loaded < 0)
+ die("read error (%s)", strerror(errno));
+ count -= loaded;
+ p += loaded;
+ }
+}
+
void write_or_die(int fd, const void *buf, size_t count)
{
const char *p = buf;
void write_or_die(int fd, const void *buf, size_t count)
{
const char *p = buf;