Changeset dbbcad4 in freewrt for tools/paxmirabilis


Ignore:
Timestamp:
Jul 16, 2006, 6:17:53 PM (19 years ago)
Author:
Thorsten Glaser <tg@…>
Branches:
freewrt_1_0, freewrt_2_0
Children:
006f3d5
Parents:
53c89c6
Message:

sync with MirCpio: introduce "extract to stdout" option

"schön" wbx@

git-svn-id: svn://www.freewrt.org/trunk/freewrt@207 afb5a338-a214-0410-bd46-81f09a774fd1

Location:
tools/paxmirabilis/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • tools/paxmirabilis/src/ar_subs.c

    r53c89c6 rdbbcad4  
     1/**     $MirOS: src/bin/pax/ar_subs.c,v 1.4 2006/07/16 16:14:50 tg Exp $ */
    12/*      $OpenBSD: ar_subs.c,v 1.29 2006/01/25 17:42:08 markus Exp $     */
    23/*      $NetBSD: ar_subs.c,v 1.5 1995/03/21 09:07:06 cgd Exp $  */
     
    3536 */
    3637
    37 #ifndef lint
    38 #if 0
    39 static const char sccsid[] = "@(#)ar_subs.c     8.2 (Berkeley) 4/18/94";
    40 #else
    41 static const char rcsid[] = "$OpenBSD: ar_subs.c,v 1.29 2006/01/25 17:42:08 markus Exp $";
    42 #endif
    43 #endif /* not lint */
    44 
    45 #include <sys/types.h>
     38#include <sys/param.h>
    4639#include <sys/time.h>
    4740#include <sys/stat.h>
    48 #include <sys/param.h>
    4941#include <signal.h>
    5042#include <string.h>
     
    5648#include "pax.h"
    5749#include "extern.h"
     50#include "options.h"
     51
     52__SCCSID("@(#)ar_subs.c 8.2 (Berkeley) 4/18/94");
     53__RCSID("$MirOS: src/bin/pax/ar_subs.c,v 1.4 2006/07/16 16:14:50 tg Exp $");
    5854
    5955static void wr_archive(ARCHD *, int is_app);
     
    302298                 */
    303299                if ((arcn->pat != NULL) && (arcn->pat->chdname != NULL))
    304                         if (chdir(arcn->pat->chdname) != 0)
     300                        if (!to_stdout && chdir(arcn->pat->chdname) != 0)
    305301                                syswarn(1, errno, "Cannot chdir to %s",
    306302                                    arcn->pat->chdname);
     
    315311                         * header (as determined by the format).
    316312                         */
    317                         if ((arcn->type == PAX_HLK) || (arcn->type == PAX_HRG))
    318                                 res = lnk_creat(arcn);
    319                         else
    320                                 res = node_creat(arcn);
     313                        if (!to_stdout) {
     314                                if ((arcn->type == PAX_HLK) || (arcn->type == PAX_HRG))
     315                                        res = lnk_creat(arcn);
     316                                else
     317                                        res = node_creat(arcn);
     318                        }
    321319
    322320                        (void)rd_skip(arcn->skip + arcn->pad);
     
    334332                 * over the data and purge the name from hard link table
    335333                 */
    336                 if ((fd = file_creat(arcn)) < 0) {
     334                if (to_stdout)
     335                        fd = STDOUT_FILENO;
     336                else if ((fd = file_creat(arcn)) < 0) {
    337337                        (void)rd_skip(arcn->skip + arcn->pad);
    338338                        purg_lnk(arcn);
     
    344344                 */
    345345                res = (*frmt->rd_data)(arcn, fd, &cnt);
    346                 file_close(arcn, fd);
     346                if (fd != STDOUT_FILENO)
     347                        file_close(arcn, fd);
    347348                if (vflag && vfpart) {
    348349                        (void)putc('\n', listf);
     
    356357                 */
    357358                if ((arcn->pat != NULL) && (arcn->pat->chdname != NULL))
    358                         if (fchdir(cwdfd) != 0)
     359                        if (!to_stdout && fchdir(cwdfd) != 0)
    359360                                syswarn(1, errno,
    360361                                    "Can't fchdir to starting directory");
     
    398399
    399400        /*
    400          * if this is not append, and there are no files, we do not write a 
     401         * if this is not append, and there are no files, we do not write a
    401402         * trailer
    402403         */
  • tools/paxmirabilis/src/options.c

    r53c89c6 rdbbcad4  
    1 /**     $MirOS: src/bin/pax/options.c,v 1.16 2006/06/23 23:03:56 tg Exp $ */
     1/**     $MirOS: src/bin/pax/options.c,v 1.18 2006/07/16 16:14:50 tg Exp $ */
    22/*      $OpenBSD: options.c,v 1.64 2006/04/09 03:35:34 jaredy Exp $     */
    33/*      $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $  */
     
    5858
    5959__SCCSID("@(#)options.c 8.2 (Berkeley) 4/18/94");
    60 __RCSID("$MirOS: src/bin/pax/options.c,v 1.16 2006/06/23 23:03:56 tg Exp $");
     60__RCSID("$MirOS: src/bin/pax/options.c,v 1.18 2006/07/16 16:14:50 tg Exp $");
    6161
    6262/*
     
    7979static void cpio_options(int, char **);
    8080static void cpio_usage(void);
     81int mkpath(char *);
    8182
    8283static void process_M(const char *, void (*)(void));
     
    161162int ford[] = {6, 5, 4, 3, 1, 0, -1 };
    162163
    163 /* Normalise archives? */
     164/* normalise archives */
    164165int anonarch = 0;
     166
     167/* extract to standard output */
     168int to_stdout = 0;
    165169
    166170/*
     
    690694                case 'O':
    691695                        Oflag = 1;
     696                        to_stdout = 2;
    692697                        break;
    693698                case 'o':
     
    858863         */
    859864        switch (act) {
     865        case EXTRACT:
     866                if (to_stdout == 2)
     867                        to_stdout = 1;
    860868        case LIST:
    861         case EXTRACT:
    862869        default:
    863870                {
    864871                        int sawpat = 0;
    865                         char *file, *dir;
     872                        char *file, *dir = NULL;
    866873
    867874                        while (nincfiles || *argv != NULL) {
     
    955962
    956963                while (nincfiles || *argv != NULL) {
    957                         char *file, *dir;
     964                        char *file, *dir = NULL;
    958965
    959966                        /*
     
    10161023                break;
    10171024        }
     1025        if (to_stdout != 1)
     1026                to_stdout = 0;
    10181027        if (!fstdin && ((arcname == NULL) || (*arcname == '\0'))) {
    10191028                arcname = getenv("TAPE");
     
    10241033        }
    10251034}
    1026 
    1027 int mkpath(char *);
    10281035
    10291036int
     
    16521659process_M(const char *arg, void (*call_usage)(void))
    16531660{
    1654         int j, k;
     1661        int j, k = 0;
    16551662
    16561663        if ((arg[0] >= '0') && (arg[0] <= '9')) {
  • tools/paxmirabilis/src/options.h

    r53c89c6 rdbbcad4  
    1 /**     $MirOS: src/bin/pax/options.h,v 1.2 2006/06/19 19:22:08 tg Exp $ */
     1/**     $MirOS: src/bin/pax/options.h,v 1.3 2006/07/16 16:14:50 tg Exp $ */
    22/*      $OpenBSD: options.h,v 1.4 2003/06/13 17:51:14 millert Exp $     */
    33/*      $NetBSD: options.h,v 1.3 1995/03/21 09:07:32 cgd Exp $  */
     
    127127extern int anonarch;
    128128void anonarch_init(void);
     129
     130extern int to_stdout;
  • tools/paxmirabilis/src/tar.1

    r53c89c6 rdbbcad4  
    1 .\"     $MirOS: src/bin/pax/tar.1,v 1.6 2006/06/19 20:31:05 tg Exp $
     1.\"     $MirOS: src/bin/pax/tar.1,v 1.7 2006/07/16 16:14:50 tg Exp $
    22.\"     $OpenBSD: tar.1,v 1.47 2005/05/24 16:33:45 jaredy Exp $
    33.\"
     
    196196Do not preserve modification time.
    197197.It Fl O
    198 Write old-style (non-POSIX) archives.
     198If reading, extract files to standard output.
     199.br
     200If writing, write old-style (non-POSIX) archives.
    199201.It Fl o
    200202Don't write directory information that the older (V7) style
Note: See TracChangeset for help on using the changeset viewer.