Some experiments, such as profiling blktap, get a whole lot easier if
there's a simple way to wrap tapdisk processes in custom code. A
typical example would be running tapdisk processes through Valgrind.
This patch makes blktapctrl sensitive to an environment variable
TAPDISK, which can be set to point to a replacement program which
blktapctrl is then supposed to spawn instead. PATH search per execvp()
remains unaffected.
{
pid_t child;
char *argv[] = { "tapdisk", write_dev, read_dev, NULL };
+ const char *tapdisk;
int i;
if ((child = fork()) == -1)
i != STDERR_FILENO)
close(i);
- execvp("tapdisk", argv);
+ tapdisk = getenv("TAPDISK");
+ if (!tapdisk)
+ tapdisk = argv[0];
+
+ execvp(tapdisk, argv);
PERROR("execvp");
_exit(1);