return p->u.pipe.ret;
}
-ssize_t failtest_read(int fd, void *buf, size_t count,
- const char *file, unsigned line)
+ssize_t failtest_pread(int fd, void *buf, size_t count, off_t off,
+ const char *file, unsigned line)
{
struct failtest_call *p;
struct read_call call;
call.fd = fd;
call.buf = buf;
call.count = count;
+ call.off = off;
p = add_history(FAILTEST_READ, file, line, &call);
/* This is going to change seek offset, so save it. */
p->u.read.ret = -1;
p->error = EIO;
} else {
- p->u.read.ret = read(fd, buf, count);
+ p->u.read.ret = pread(fd, buf, count, off);
}
errno = p->error;
return p->u.read.ret;
return &writes[writes_num++];
}
-ssize_t failtest_write(int fd, const void *buf, size_t count,
- const char *file, unsigned line)
+ssize_t failtest_pwrite(int fd, const void *buf, size_t count, off_t off,
+ const char *file, unsigned line)
{
struct failtest_call *p;
struct write_call call;
call.fd = fd;
call.buf = buf;
call.count = count;
+ call.off = off;
p = add_history(FAILTEST_WRITE, file, line, &call);
offset = lseek(fd, 0, SEEK_CUR);
return p->u.write.ret;
}
}
- p->u.write.ret = write(fd, buf, count);
+ p->u.write.ret = pwrite(fd, buf, count, off);
}
errno = p->error;
return p->u.write.ret;
}
+ssize_t failtest_read(int fd, void *buf, size_t count,
+ const char *file, unsigned line)
+{
+ return failtest_pread(fd, buf, count, lseek(fd, 0, SEEK_CUR),
+ file, line);
+}
+
+ssize_t failtest_write(int fd, const void *buf, size_t count,
+ const char *file, unsigned line)
+{
+ return failtest_pwrite(fd, buf, count, lseek(fd, 0, SEEK_CUR),
+ file, line);
+}
+
static struct lock_info *WARN_UNUSED_RESULT
add_lock(struct lock_info *locks, int fd, off_t start, off_t end, int type)
{