From: Rusty Russell Date: Tue, 15 Feb 2011 12:55:03 +0000 (+1030) Subject: failtest: don't insist parents and children write the same thing to files. X-Git-Url: https://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=fb9514a55b818d5d9bf929c2c2aaac37a4d68747 failtest: don't insist parents and children write the same thing to files. We insist they write the same things to pipes, since we can't "undo" them, but strictly speaking we don't care if they write different things into files. Note: it may indicate a bug if they do... --- diff --git a/ccan/failtest/failtest.c b/ccan/failtest/failtest.c index 56a1ad18..9102ba0a 100644 --- a/ccan/failtest/failtest.c +++ b/ccan/failtest/failtest.c @@ -663,8 +663,9 @@ ssize_t failtest_pwrite(int fd, const void *buf, size_t count, off_t off, call.off = off; p = add_history(FAILTEST_WRITE, file, line, &call); - /* If we're a child, tell parent about write. */ - if (control_fd != -1) { + /* If we're a child, we need to make sure we write the same thing + * to non-files as the parent does, so tell it. */ + if (control_fd != -1 && off == (off_t)-1) { enum info_type type = WRITE; write_all(control_fd, &type, sizeof(type)); @@ -678,7 +679,7 @@ ssize_t failtest_pwrite(int fd, const void *buf, size_t count, off_t off, p->error = EIO; } else { /* FIXME: We assume same write order in parent and child */ - if (child_writes_num != 0) { + if (off == (off_t)-1 && child_writes_num != 0) { if (child_writes[0].fd != fd) errx(1, "Child wrote to fd %u, not %u?", child_writes[0].fd, fd);