Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Seems cpio really can't deal with "TRAILER!!!" files:

  $ cd $(mktemp -d)
  $ echo foo > 'TRAILER!!!'     
  $ echo bar > barfile
  $ echo 'TRAILER!!!' | cpio -o | xxd -a
  1 block
  00000000: c771 2a00 31cc a481 e803 e803 0100 0000  .q*.1...........
  00000010: 025d ef8c 0b00 0000 0400 5452 4149 4c45  .]........TRAILE
  00000020: 5221 2121 0000 666f 6f0a c771 0000 0000  R!!!..foo..q....
  00000030: 0000 0000 0000 0100 0000 0000 0000 0b00  ................
  00000040: 0000 0000 5452 4149 4c45 5221 2121 0000  ....TRAILER!!!..
  00000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................
  *
  000001f0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
  $ echo 'TRAILER!!!' | cpio -o | cpio -t
  1 block
  1 block
  $ echo barfile | cpio -o | cpio -t
  1 block
  barfile
  1 block
  $ echo barfile | cpio -o | cpio -i --to-stdout barfile 
  1 block
  bar
  1 block
  $ echo 'TRAILER!!!' | cpio -o | cpio -i --to-stdout 'TRAILER!!!'
  1 block
  1 block


tar has two blocks of zeros at the end.

GNU tar uses entries where other tar implementations will overwrite previous files on extraction, AIX tar uses special four character names for binary blobs (plus xattrs as names, both after the affected entry), Solaris cpio uses another mode bit for sparse files, ACLs, and xattrs (I actually really like this, it extracts as a simple to parse text file[0] on other implementations), and most pax commands on Linux can't read/write PAX archive files.

FWIW I make use of TRAILER!!! to let me know in a pipeline that everything worked (imagine a command earlier in the pipe fails early and not every entry is processed but ends on a boundary), but here the two pages of zeros that tar uses makes more sense (about the only thing tar does better than cpio).

0: https://www.mail-archive.com/opensolaris-arc@mail.opensolari...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: