busybox/archival/cpio.c
<<
>>
Prefs
   1/* vi: set sw=4 ts=4: */
   2/*
   3 * Mini cpio implementation for busybox
   4 *
   5 * Copyright (C) 2001 by Glenn McGrath
   6 *
   7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
   8 *
   9 * Limitations:
  10 * Doesn't check CRC's
  11 * Only supports new ASCII and CRC formats
  12 */
  13//config:config CPIO
  14//config:       bool "cpio (15 kb)"
  15//config:       default y
  16//config:       help
  17//config:       cpio is an archival utility program used to create, modify, and
  18//config:       extract contents from archives.
  19//config:       cpio has 110 bytes of overheads for every stored file.
  20//config:
  21//config:       This implementation of cpio can extract cpio archives created in the
  22//config:       "newc" or "crc" format.
  23//config:
  24//config:       Unless you have a specific application which requires cpio, you
  25//config:       should probably say N here.
  26//config:
  27//config:config FEATURE_CPIO_O
  28//config:       bool "Support archive creation"
  29//config:       default y
  30//config:       depends on CPIO
  31//config:       help
  32//config:       This implementation of cpio can create cpio archives in the "newc"
  33//config:       format only.
  34//config:
  35//config:config FEATURE_CPIO_P
  36//config:       bool "Support passthrough mode"
  37//config:       default y
  38//config:       depends on FEATURE_CPIO_O
  39//config:       help
  40//config:       Passthrough mode. Rarely used.
  41//config:
  42//config:config FEATURE_CPIO_IGNORE_DEVNO
  43//config:       bool "Support --ignore-devno like GNU cpio"
  44//config:       default y
  45//config:       depends on FEATURE_CPIO_O && LONG_OPTS
  46//config:       help
  47//config:       Optionally ignore device numbers when creating archives.
  48//config:
  49//config:config FEATURE_CPIO_RENUMBER_INODES
  50//config:       bool "Support --renumber-inodes like GNU cpio"
  51//config:       default y
  52//config:       depends on FEATURE_CPIO_O && LONG_OPTS
  53//config:       help
  54//config:       Optionally renumber inodes when creating archives.
  55
  56//applet:IF_CPIO(APPLET(cpio, BB_DIR_BIN, BB_SUID_DROP))
  57
  58//kbuild:lib-$(CONFIG_CPIO) += cpio.o
  59
  60//usage:#define cpio_trivial_usage
  61//usage:       "[-dmvu] [-F FILE] [-R USER[:GRP]]" IF_FEATURE_CPIO_O(" [-H newc]")
  62//usage:       " [-ti"IF_FEATURE_CPIO_O("o")"]" IF_FEATURE_CPIO_P(" [-p DIR]")
  63//usage:       " [EXTR_FILE]..."
  64//usage:#define cpio_full_usage "\n\n"
  65//usage:       "Extract (-i) or list (-t) files from a cpio archive"
  66//usage:        IF_FEATURE_CPIO_O(", or"
  67//usage:     "\ntake file list from stdin and create an archive (-o)"
  68//usage:                IF_FEATURE_CPIO_P(" or copy files (-p)")
  69//usage:        )
  70//usage:     "\n"
  71//usage:     "\nMain operation mode:"
  72//usage:     "\n        -t      List"
  73//usage:     "\n        -i      Extract EXTR_FILEs (or all)"
  74//usage:        IF_FEATURE_CPIO_O(
  75//usage:     "\n        -o      Create (requires -H newc)"
  76//usage:        )
  77//usage:        IF_FEATURE_CPIO_P(
  78//usage:     "\n        -p DIR  Copy files to DIR"
  79//usage:        )
  80//usage:     "\nOptions:"
  81//usage:        IF_FEATURE_CPIO_O(
  82//usage:     "\n        -H newc Archive format"
  83//usage:        )
  84//usage:     "\n        -d      Make leading directories"
  85//usage:     "\n        -m      Restore mtime"
  86//usage:     "\n        -v      Verbose"
  87//usage:     "\n        -u      Overwrite"
  88//usage:     "\n        -F FILE Input (-t,-i,-p) or output (-o) file"
  89//usage:     "\n        -R USER[:GRP]   Set owner of created files"
  90//usage:     "\n        -L      Dereference symlinks"
  91//usage:     "\n        -0      NUL terminated input"
  92//usage:        IF_FEATURE_CPIO_IGNORE_DEVNO(
  93//usage:     "\n        --ignore-devno"
  94//usage:        )
  95//usage:        IF_FEATURE_CPIO_RENUMBER_INODES(
  96//usage:     "\n        --renumber-inodes"
  97//usage:        )
  98
  99/* GNU cpio 2.9 --help (abridged):
 100
 101 Modes:
 102  -t, --list                 List the archive
 103  -i, --extract              Extract files from an archive
 104  -o, --create               Create the archive
 105  -p, --pass-through         Copy-pass mode
 106
 107 Options valid in any mode:
 108      --block-size=SIZE      I/O block size = SIZE * 512 bytes
 109  -B                         I/O block size = 5120 bytes
 110  -c                         Use the old portable (ASCII) archive format
 111  -C, --io-size=NUMBER       I/O block size in bytes
 112  -f, --nonmatching          Only copy files that do not match given pattern
 113  -F, --file=FILE            Use FILE instead of standard input or output
 114  -H, --format=FORMAT        Use given archive FORMAT
 115  -M, --message=STRING       Print STRING when the end of a volume of the
 116                             backup media is reached
 117  -n, --numeric-uid-gid      If -v, show numeric UID and GID
 118      --quiet                Do not print the number of blocks copied
 119      --rsh-command=COMMAND  Use remote COMMAND instead of rsh
 120  -v, --verbose              Verbosely list the files processed
 121  -V, --dot                  Print a "." for each file processed
 122  -W, --warning=FLAG         Control warning display: 'none','truncate','all';
 123                             multiple options accumulate
 124
 125 Options valid only in --extract mode:
 126  -b, --swap                 Swap both halfwords of words and bytes of
 127                             halfwords in the data (equivalent to -sS)
 128  -r, --rename               Interactively rename files
 129  -s, --swap-bytes           Swap the bytes of each halfword in the files
 130  -S, --swap-halfwords       Swap the halfwords of each word (4 bytes)
 131      --to-stdout            Extract files to standard output
 132  -E, --pattern-file=FILE    Read additional patterns specifying filenames to
 133                             extract or list from FILE
 134      --only-verify-crc      Verify CRC's, don't actually extract the files
 135
 136 Options valid only in --create mode:
 137  -A, --append               Append to an existing archive
 138  -O FILE                    File to use instead of standard output
 139
 140 Options valid only in --pass-through mode:
 141  -l, --link                 Link files instead of copying them, when possible
 142
 143 Options valid in --extract and --create modes:
 144      --absolute-filenames   Do not strip file system prefix components from
 145                             the file names
 146      --no-absolute-filenames Create all files relative to the current dir
 147
 148 Options valid in --create and --pass-through modes:
 149  -0, --null                 A list of filenames is terminated by a NUL
 150  -a, --reset-access-time    Reset the access times of files after reading them
 151  -I FILE                    File to use instead of standard input
 152  -L, --dereference          Dereference symbolic links (copy the files
 153                             that they point to instead of copying the links)
 154  -R, --owner=[USER][:.][GRP] Set owner of created files
 155
 156 Options valid in --extract and --pass-through modes:
 157  -d, --make-directories     Create leading directories where needed
 158  -m, --preserve-modification-time  Retain mtime when creating files
 159      --no-preserve-owner    Do not change the ownership of the files
 160      --sparse               Write files with blocks of zeros as sparse files
 161  -u, --unconditional        Replace all files unconditionally
 162 */
 163
 164#include "libbb.h"
 165#include "common_bufsiz.h"
 166#include "bb_archive.h"
 167
 168enum {
 169        OPT_EXTRACT            = (1 << 0),
 170        OPT_TEST               = (1 << 1),
 171        OPT_NUL_TERMINATED     = (1 << 2),
 172        OPT_UNCONDITIONAL      = (1 << 3),
 173        OPT_VERBOSE            = (1 << 4),
 174        OPT_CREATE_LEADING_DIR = (1 << 5),
 175        OPT_PRESERVE_MTIME     = (1 << 6),
 176        OPT_DEREF              = (1 << 7),
 177        OPT_FILE               = (1 << 8),
 178        OPT_OWNER              = (1 << 9),
 179        OPTBIT_OWNER = 9,
 180        IF_FEATURE_CPIO_O(OPTBIT_CREATE     ,)
 181        IF_FEATURE_CPIO_O(OPTBIT_FORMAT     ,)
 182        IF_FEATURE_CPIO_P(OPTBIT_PASSTHROUGH,)
 183        IF_LONG_OPTS(     OPTBIT_QUIET      ,)
 184        IF_LONG_OPTS(     OPTBIT_2STDOUT    ,)
 185        IF_FEATURE_CPIO_IGNORE_DEVNO(OPTBIT_IGNORE_DEVNO,)
 186        IF_FEATURE_CPIO_RENUMBER_INODES(OPTBIT_RENUMBER_INODES,)
 187        OPT_CREATE             = IF_FEATURE_CPIO_O((1 << OPTBIT_CREATE     )) + 0,
 188        OPT_FORMAT             = IF_FEATURE_CPIO_O((1 << OPTBIT_FORMAT     )) + 0,
 189        OPT_PASSTHROUGH        = IF_FEATURE_CPIO_P((1 << OPTBIT_PASSTHROUGH)) + 0,
 190        OPT_QUIET              = IF_LONG_OPTS(     (1 << OPTBIT_QUIET      )) + 0,
 191        OPT_2STDOUT            = IF_LONG_OPTS(     (1 << OPTBIT_2STDOUT    )) + 0,
 192        OPT_IGNORE_DEVNO       = IF_FEATURE_CPIO_IGNORE_DEVNO((1 << OPTBIT_IGNORE_DEVNO)) + 0,
 193        OPT_RENUMBER_INODES    = IF_FEATURE_CPIO_RENUMBER_INODES((1 << OPTBIT_RENUMBER_INODES)) + 0,
 194};
 195
 196#define OPTION_STR "it0uvdmLF:R:"
 197
 198struct globals {
 199        struct bb_uidgid_t owner_ugid;
 200        ino_t next_inode;
 201} FIX_ALIASING;
 202#define G (*(struct globals*)bb_common_bufsiz1)
 203void BUG_cpio_globals_too_big(void);
 204#define INIT_G() do { \
 205        setup_common_bufsiz(); \
 206        G.owner_ugid.uid = -1L; \
 207        G.owner_ugid.gid = -1L; \
 208} while (0)
 209
 210#if ENABLE_FEATURE_CPIO_O
 211static off_t cpio_pad4(off_t size)
 212{
 213        int i;
 214
 215        i = (- size) & 3;
 216        size += i;
 217        while (--i >= 0)
 218                bb_putchar('\0');
 219        return size;
 220}
 221
 222/* Return value will become exit code.
 223 * It's ok to exit instead of return. */
 224static NOINLINE int cpio_o(void)
 225{
 226        struct name_s {
 227                struct name_s *next;
 228                char name[1];
 229        };
 230        struct inodes_s {
 231                struct inodes_s *next;
 232                struct name_s *names;
 233                struct stat st;
 234#if ENABLE_FEATURE_CPIO_RENUMBER_INODES
 235                ino_t mapped_inode;
 236#endif
 237        };
 238
 239        struct inodes_s *links = NULL;
 240        off_t bytes = 0; /* output bytes count */
 241
 242        while (1) {
 243                const char *name;
 244                char *line;
 245                struct stat st;
 246
 247                line = (option_mask32 & OPT_NUL_TERMINATED)
 248                                ? bb_get_chunk_from_file(stdin, NULL)
 249                                : xmalloc_fgetline(stdin);
 250
 251                if (line) {
 252                        /* Strip leading "./[./]..." from the filename */
 253                        name = line;
 254                        while (name[0] == '.' && name[1] == '/') {
 255                                while (*++name == '/')
 256                                        continue;
 257                        }
 258                        if (!*name) { /* line is empty */
 259                                free(line);
 260                                continue;
 261                        }
 262                        if ((option_mask32 & OPT_DEREF)
 263                                        ? stat(name, &st)
 264                                        : lstat(name, &st)
 265                        ) {
 266 abort_cpio_o:
 267                                bb_simple_perror_msg_and_die(name);
 268                        }
 269
 270                        if (G.owner_ugid.uid != (uid_t)-1L)
 271                                st.st_uid = G.owner_ugid.uid;
 272                        if (G.owner_ugid.gid != (gid_t)-1L)
 273                                st.st_gid = G.owner_ugid.gid;
 274
 275                        if (!(S_ISLNK(st.st_mode) || S_ISREG(st.st_mode)))
 276                                st.st_size = 0; /* paranoia */
 277
 278                        /* Store hardlinks for later processing, dont output them */
 279                        if (!S_ISDIR(st.st_mode) && st.st_nlink > 1) {
 280                                struct name_s *n;
 281                                struct inodes_s *l;
 282
 283                                /* Do we have this hardlink remembered? */
 284                                l = links;
 285                                while (1) {
 286                                        if (l == NULL) {
 287                                                /* Not found: add new item to "links" list */
 288                                                l = xzalloc(sizeof(*l));
 289                                                l->st = st;
 290                                                l->next = links;
 291#if ENABLE_FEATURE_CPIO_RENUMBER_INODES
 292                                                if (option_mask32 & OPT_RENUMBER_INODES)
 293                                                        l->mapped_inode = ++G.next_inode;
 294#endif
 295                                                links = l;
 296                                                break;
 297                                        }
 298                                        if (l->st.st_ino == st.st_ino) {
 299                                                /* found */
 300                                                break;
 301                                        }
 302                                        l = l->next;
 303                                }
 304                                /* Add new name to "l->names" list */
 305                                n = xmalloc(sizeof(*n) + strlen(name));
 306                                strcpy(n->name, name);
 307                                n->next = l->names;
 308                                l->names = n;
 309
 310                                free(line);
 311                                continue;
 312                        }
 313#if ENABLE_FEATURE_CPIO_RENUMBER_INODES
 314                        else if (option_mask32 & OPT_RENUMBER_INODES) {
 315                                st.st_ino = ++G.next_inode;
 316                        }
 317#endif
 318                } else { /* line == NULL: EOF */
 319 next_link:
 320                        if (links) {
 321                                /* Output hardlink's data */
 322                                st = links->st;
 323                                name = links->names->name;
 324                                links->names = links->names->next;
 325#if ENABLE_FEATURE_CPIO_RENUMBER_INODES
 326                                if (links->mapped_inode)
 327                                        st.st_ino = links->mapped_inode;
 328#endif
 329                                /* GNU cpio is reported to emit file data
 330                                 * only for the last instance. Mimic that. */
 331                                if (links->names == NULL)
 332                                        links = links->next;
 333                                else
 334                                        st.st_size = 0;
 335                                /* NB: we leak links->names and/or links,
 336                                 * this is intended (we exit soon anyway) */
 337                        } else {
 338                                /* If no (more) hardlinks to output,
 339                                 * output "trailer" entry */
 340                                name = cpio_TRAILER;
 341                                /* st.st_size == 0 is a must, but for uniformity
 342                                 * in the output, we zero out everything */
 343                                memset(&st, 0, sizeof(st));
 344                                /* st.st_nlink = 1; - GNU cpio does this */
 345                        }
 346                }
 347
 348#if ENABLE_FEATURE_CPIO_IGNORE_DEVNO
 349                if (option_mask32 & OPT_IGNORE_DEVNO)
 350                        st.st_dev = st.st_rdev = 0;
 351#endif
 352
 353                bytes += printf("070701"
 354                                "%08X%08X%08X%08X%08X%08X%08X"
 355                                "%08X%08X%08X%08X" /* GNU cpio uses uppercase hex */
 356                                /* strlen+1: */ "%08X"
 357                                /* chksum: */   "00000000" /* (only for "070702" files) */
 358                                /* name,NUL: */ "%s%c",
 359                                (unsigned)(uint32_t) st.st_ino,
 360                                (unsigned)(uint32_t) st.st_mode,
 361                                (unsigned)(uint32_t) st.st_uid,
 362                                (unsigned)(uint32_t) st.st_gid,
 363                                (unsigned)(uint32_t) st.st_nlink,
 364                                (unsigned)(uint32_t) st.st_mtime,
 365                                (unsigned)(uint32_t) st.st_size,
 366                                (unsigned)(uint32_t) major(st.st_dev),
 367                                (unsigned)(uint32_t) minor(st.st_dev),
 368                                (unsigned)(uint32_t) major(st.st_rdev),
 369                                (unsigned)(uint32_t) minor(st.st_rdev),
 370                                (unsigned)(strlen(name) + 1),
 371                                name, '\0');
 372                bytes = cpio_pad4(bytes);
 373
 374                if (st.st_size) {
 375                        if (S_ISLNK(st.st_mode)) {
 376                                char *lpath = xmalloc_readlink_or_warn(name);
 377                                if (!lpath)
 378                                        goto abort_cpio_o;
 379                                bytes += printf("%s", lpath);
 380                                free(lpath);
 381                        } else { /* S_ISREG */
 382                                int fd = xopen(name, O_RDONLY);
 383                                fflush_all();
 384                                /* We must abort if file got shorter too! */
 385                                bb_copyfd_exact_size(fd, STDOUT_FILENO, st.st_size);
 386                                bytes += st.st_size;
 387                                close(fd);
 388                        }
 389                        bytes = cpio_pad4(bytes);
 390                }
 391
 392                if (!line) {
 393                        if (name != cpio_TRAILER)
 394                                goto next_link;
 395                        /* TODO: GNU cpio pads trailer to 512 bytes, do we want that? */
 396                        return EXIT_SUCCESS;
 397                }
 398
 399                free(line);
 400        } /* end of "while (1)" */
 401}
 402#endif
 403
 404int cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 405int cpio_main(int argc UNUSED_PARAM, char **argv)
 406{
 407        archive_handle_t *archive_handle;
 408        char *cpio_filename;
 409        char *cpio_owner;
 410        IF_FEATURE_CPIO_O(const char *cpio_fmt = "";)
 411        unsigned opt;
 412#if ENABLE_LONG_OPTS
 413        const char *long_opts =
 414                "extract\0"      No_argument       "i"
 415                "list\0"         No_argument       "t"
 416#if ENABLE_FEATURE_CPIO_O
 417                "create\0"       No_argument       "o"
 418                "format\0"       Required_argument "H"
 419#if ENABLE_FEATURE_CPIO_P
 420                "pass-through\0" No_argument       "p"
 421#endif
 422#endif
 423                "owner\0"        Required_argument "R"
 424                "verbose\0"      No_argument       "v"
 425                "null\0"         No_argument       "0"
 426                "quiet\0"        No_argument       "\xff"
 427                "to-stdout\0"    No_argument       "\xfe"
 428#if ENABLE_FEATURE_CPIO_IGNORE_DEVNO
 429                "ignore-devno\0" No_argument       "\xfd"
 430#endif
 431#if ENABLE_FEATURE_CPIO_RENUMBER_INODES
 432                "renumber-inodes\0" No_argument    "\xfc"
 433#endif
 434                ;
 435#endif
 436
 437        INIT_G();
 438        archive_handle = init_handle();
 439        /* archive_handle->src_fd = STDIN_FILENO; - done by init_handle */
 440        archive_handle->ah_flags = ARCHIVE_EXTRACT_NEWER;
 441
 442        /* As of now we do not enforce this: */
 443        /* -i,-t,-o,-p are mutually exclusive */
 444        /* -u,-d,-m make sense only with -i or -p */
 445        /* -L makes sense only with -o or -p */
 446
 447#if !ENABLE_FEATURE_CPIO_O
 448        opt = getopt32long(argv, OPTION_STR, long_opts, &cpio_filename, &cpio_owner);
 449#else
 450        opt = getopt32long(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), long_opts,
 451                       &cpio_filename, &cpio_owner, &cpio_fmt);
 452#endif
 453        argv += optind;
 454        if (opt & OPT_OWNER) { /* -R */
 455                parse_chown_usergroup_or_die(&G.owner_ugid, cpio_owner);
 456                archive_handle->cpio__owner = G.owner_ugid;
 457        }
 458#if !ENABLE_FEATURE_CPIO_O
 459        if (opt & OPT_FILE) { /* -F */
 460                xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO);
 461        }
 462#else
 463        if ((opt & (OPT_FILE|OPT_CREATE)) == OPT_FILE) { /* -F without -o */
 464                xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO);
 465        }
 466        if (opt & OPT_PASSTHROUGH) {
 467                pid_t pid;
 468                struct fd_pair pp;
 469
 470                if (argv[0] == NULL)
 471                        bb_show_usage();
 472                if (opt & OPT_CREATE_LEADING_DIR)
 473                        /* GNU cpio 2.13: "cpio -d -p a/b/c" works */
 474                        bb_make_directory(argv[0], -1, FILEUTILS_RECUR);
 475                /* Crude existence check:
 476                 * close(xopen(argv[0], O_RDONLY | O_DIRECTORY));
 477                 * We can also xopen, fstat, IS_DIR, later fchdir.
 478                 * This would check for existence earlier and cleaner.
 479                 * As it stands now, if we fail xchdir later,
 480                 * child dies on EPIPE, unless it caught
 481                 * a diffrerent problem earlier.
 482                 * This is good enough for now.
 483                 */
 484//FIXME: GNU cpio -d -p DIR does not immediately create DIR -
 485//it just prepends "DIR/" to the names of files to be created.
 486//The first file (fails to) be copied, and then the -d logic
 487//triggers and creates all necessary directories.
 488//IOW: bare "cpio -d -p DIR" + ^C shouldn't create anything.
 489#if !BB_MMU
 490                pp.rd = 3;
 491                pp.wr = 4;
 492                if (!re_execed) {
 493                        close(3);
 494                        close(4);
 495                        xpiped_pair(pp);
 496                }
 497#else
 498                xpiped_pair(pp);
 499#endif
 500                pid = fork_or_rexec(argv - optind);
 501                if (pid == 0) { /* child */
 502                        close(pp.rd);
 503                        xmove_fd(pp.wr, STDOUT_FILENO);
 504                        goto dump;
 505                }
 506                /* parent */
 507                USE_FOR_NOMMU(argv[-optind][0] &= 0x7f); /* undo fork_or_rexec() damage */
 508                xchdir(*argv++);
 509                close(pp.wr);
 510                xmove_fd(pp.rd, STDIN_FILENO);
 511                //opt &= ~OPT_PASSTHROUGH;
 512                opt |= OPT_EXTRACT;
 513                goto skip;
 514        }
 515        /* -o */
 516        if (opt & OPT_CREATE) {
 517                if (cpio_fmt[0] != 'n') /* we _require_ "-H newc" */
 518                        bb_show_usage();
 519                if (opt & OPT_FILE) {
 520                        xmove_fd(xopen(cpio_filename, O_WRONLY | O_CREAT | O_TRUNC), STDOUT_FILENO);
 521                }
 522 dump:
 523                return cpio_o();
 524        }
 525 skip:
 526#endif
 527
 528        /* One of either extract or test options must be given */
 529        if ((opt & (OPT_TEST | OPT_EXTRACT)) == 0) {
 530                bb_show_usage();
 531        }
 532
 533        if (opt & OPT_TEST) {
 534                /* if both extract and test options are given, ignore extract option */
 535                opt &= ~OPT_EXTRACT;
 536                archive_handle->action_header = header_list;
 537        }
 538        if (opt & OPT_EXTRACT) {
 539                archive_handle->action_data = data_extract_all;
 540                if (opt & OPT_2STDOUT)
 541                        archive_handle->action_data = data_extract_to_stdout;
 542        }
 543        if (opt & OPT_UNCONDITIONAL) {
 544                archive_handle->ah_flags |= ARCHIVE_UNLINK_OLD;
 545                archive_handle->ah_flags &= ~ARCHIVE_EXTRACT_NEWER;
 546        }
 547        if (opt & OPT_VERBOSE) {
 548                if (archive_handle->action_header == header_list) {
 549                        archive_handle->action_header = header_verbose_list;
 550                } else {
 551                        archive_handle->action_header = header_list;
 552                }
 553        }
 554        if (opt & OPT_CREATE_LEADING_DIR) {
 555                archive_handle->ah_flags |= ARCHIVE_CREATE_LEADING_DIRS;
 556        }
 557        if (opt & OPT_PRESERVE_MTIME) {
 558                archive_handle->ah_flags |= ARCHIVE_RESTORE_DATE;
 559        }
 560
 561        while (*argv) {
 562                archive_handle->filter = filter_accept_list;
 563                llist_add_to(&archive_handle->accept, *argv);
 564                argv++;
 565        }
 566
 567        /* see get_header_cpio */
 568        archive_handle->cpio__blocks = (off_t)-1;
 569        while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
 570                continue;
 571
 572        create_links_from_list(archive_handle->link_placeholders);
 573
 574        if (archive_handle->cpio__blocks != (off_t)-1
 575         && !(opt & OPT_QUIET)
 576        ) {
 577                fflush_all();
 578                fprintf(stderr, "%"OFF_FMT"u blocks\n", archive_handle->cpio__blocks);
 579        }
 580
 581        return EXIT_SUCCESS;
 582}
 583