Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (17 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/archival/libunarchive/open_transformer.c

    r821 r1765  
     1/* vi: set sw=4 ts=4: */
    12/*
    23 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
    34 */
    45
    5 #include <stdlib.h>
    6 #include <unistd.h>
    7 
    86#include "libbb.h"
    9 
    107#include "unarchive.h"
    118
    129/* transformer(), more than meets the eye */
    13 int open_transformer(int src_fd, int (*transformer)(int src_fd, int dst_fd))
     10/*
     11 * On MMU machine, the transform_prog and ... are stripped
     12 * by a macro in include/unarchive.h. On NOMMU, transformer is stripped.
     13 */
     14int open_transformer(int src_fd,
     15    USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd),
     16    const char *transform_prog, ...)
    1417{
    1518    int fd_pipe[2];
    1619    int pid;
    1720
    18     if (pipe(fd_pipe) != 0) {
    19         bb_perror_msg_and_die("Can't create pipe");
    20     }
     21    xpipe(fd_pipe);
    2122
     23#if BB_MMU
    2224    pid = fork();
    23     if (pid == -1) {
    24         bb_perror_msg_and_die("Fork failed");
    25     }
     25#else
     26    pid = vfork();
     27#endif
     28    if (pid == -1)
     29        bb_perror_msg_and_die("fork failed");
    2630
    2731    if (pid == 0) {
     32#if !BB_MMU
     33        va_list ap;
     34#endif
    2835        /* child process */
    29         close(fd_pipe[0]); /* We don't wan't to read from the parent */
    30         transformer(src_fd, fd_pipe[1]);
    31         close(fd_pipe[1]); /* Send EOF */
    32         close(src_fd);
    33         exit(0);
    34         /* notreached */
     36        close(fd_pipe[0]); /* We don't wan't to read from the parent */
     37        // FIXME: error check?
     38#if BB_MMU
     39        transformer(src_fd, fd_pipe[1]);
     40        if (ENABLE_FEATURE_CLEAN_UP) {
     41            close(fd_pipe[1]); /* Send EOF */
     42            close(src_fd);
     43        }
     44        exit(0);
     45#else
     46        xmove_fd(src_fd, 0);
     47        xmove_fd(fd_pipe[1], 1);
     48        va_start(ap, transform_prog);
     49        BB_EXECVP(transform_prog, ap);
     50        bb_perror_and_die("exec failed");
     51#endif
     52        /* notreached */
    3553    }
    3654
     
    3856    close(fd_pipe[1]); /* Don't want to write to the child */
    3957
    40     return(fd_pipe[0]);
     58    return fd_pipe[0];
    4159}
Note: See TracChangeset for help on using the changeset viewer.