Contents of /trunk/mkinitrd-magellan/busybox/archival/libunarchive/open_transformer.c
Parent Directory | Revision Log
Revision 532 -
(show annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (17 years ago) by niro
File MIME type: text/plain
File size: 884 byte(s)
Sat Sep 1 22:45:15 2007 UTC (17 years ago) by niro
File MIME type: text/plain
File size: 884 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd
1 | /* vi: set sw=4 ts=4: */ |
2 | /* |
3 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
4 | */ |
5 | |
6 | #include <stdlib.h> |
7 | #include <unistd.h> |
8 | |
9 | #include "libbb.h" |
10 | |
11 | #include "unarchive.h" |
12 | |
13 | /* transformer(), more than meets the eye */ |
14 | int open_transformer(int src_fd, |
15 | USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd)) |
16 | { |
17 | int fd_pipe[2]; |
18 | int pid; |
19 | |
20 | if (pipe(fd_pipe) != 0) { |
21 | bb_perror_msg_and_die("can't create pipe"); |
22 | } |
23 | |
24 | pid = fork(); |
25 | if (pid == -1) { |
26 | bb_perror_msg_and_die("fork failed"); |
27 | } |
28 | |
29 | if (pid == 0) { |
30 | /* child process */ |
31 | close(fd_pipe[0]); /* We don't wan't to read from the parent */ |
32 | // FIXME: error check? |
33 | transformer(src_fd, fd_pipe[1]); |
34 | close(fd_pipe[1]); /* Send EOF */ |
35 | close(src_fd); |
36 | exit(0); |
37 | /* notreached */ |
38 | } |
39 | |
40 | /* parent process */ |
41 | close(fd_pipe[1]); /* Don't want to write to the child */ |
42 | |
43 | return fd_pipe[0]; |
44 | } |