1 /* vi: set sw=4 ts=4: */
3 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
9 /* transformer(), more than meets the eye */
11 * On MMU machine, the transform_prog is removed by macro magic
12 * in include/unarchive.h. On NOMMU, transformer is removed.
14 int FAST_FUNC open_transformer(int src_fd,
15 USE_DESKTOP(long long) int FAST_FUNC (*transformer)(int src_fd, int dst_fd),
16 const char *transform_prog)
18 struct fd_pair fd_pipe;
26 bb_perror_msg_and_die("can't fork");
30 bb_perror_msg_and_die("can't vfork");
35 close(fd_pipe.rd); /* We don't want to read from the parent */
36 // FIXME: error check?
38 transformer(src_fd, fd_pipe.wr);
39 if (ENABLE_FEATURE_CLEAN_UP) {
40 close(fd_pipe.wr); /* Send EOF */
43 /* must be _exit! bug was actually seen here */
49 xmove_fd(fd_pipe.wr, 1);
50 argv[0] = (char*)transform_prog;
51 argv[1] = (char*)"-cf";
54 BB_EXECVP(transform_prog, argv);
55 bb_perror_msg_and_die("can't exec %s", transform_prog);
62 close(fd_pipe.wr); /* Don't want to write to the child */
64 //TODO: get rid of return value (become void)?
65 xmove_fd(fd_pipe.rd, src_fd);