Commit 30b08baa authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

zdtm: open an one unlinked files two times

A few test check restoring of file descriptors to a one file struct.
Here is better to check, that a few file struct can be linked to one unlinked file.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent b11eeea3
......@@ -18,7 +18,7 @@ TEST_OPTION(filename, string, "file name", 1);
int main(int argc, char ** argv)
{
int fd, ret;
int fd, child_fd, ret;
pid_t pid;
uint32_t crc;
uint8_t buf[1000000];
......@@ -31,6 +31,12 @@ int main(int argc, char ** argv)
exit(1);
}
child_fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0644);
if (fd < 0) {
err("can't open %s: %m\n", filename);
exit(1);
}
if (unlink(filename)) {
err("can't unlink %s: %m\n", filename);
exit(1);
......@@ -43,17 +49,20 @@ int main(int argc, char ** argv)
}
if (pid == 0) { /* child writes to the unlinked file and returns */
close(fd);
test_waitsig();
crc = ~0;
datagen(buf, sizeof(buf), &crc);
if (write(fd, buf, sizeof(buf)) != sizeof(buf))
if (write(child_fd, buf, sizeof(buf)) != sizeof(buf))
_exit(errno);
close(fd);
close(child_fd);
_exit(0);
}
close(child_fd);
test_daemon();
test_waitsig();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment