]> git.proxmox.com Git - mirror_zfs-debian.git/commit
Use dynamic file descriptor numbers in ztest.
authorEtienne Dechamps <etienne.dechamps@ovh.net>
Thu, 4 Oct 2012 14:09:12 +0000 (16:09 +0200)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 4 Oct 2012 20:19:09 +0000 (13:19 -0700)
commit9d81146b015e8f4f611357c4cef17fbfb2f4bd54
treebe885190d6faf4c916b91e6474551dca508f5af3
parent22257dc0d5582035347320130e9ee03b33dffb6f
Use dynamic file descriptor numbers in ztest.

Currently, ztest expects to get 3 and 4 as the file descriptors for
data and random files, respectively. This is quite fragile and breaks
easily if ztest is run with these file descriptors already opened
(e.g. in a complex shell script).

This patch fixes the issue by removing the assumptions on the file
descriptor numbers that open() returns.

For the random file (/dev/urandom), the new code doesn't rely on a
shared file descriptor; instead, it reopens the file in the child.

For the data file, the new code writes the file descriptor number into
a "ZTEST_FD_DATA" environment variable so that it can be recovered
after the execv() call.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
cmd/ztest/ztest.c