2

How do I detect the format used in a cpio archive? I know when we exact contents from a cpio archive, it automatically detects the format. However, I need to know what format is used.

For example, I have a file A.cpio, and I want to extract it, modify something, and then create a new A.cpio. I need this new A.cpio to have the same format as the old one, since the functioning program using A.cpio may only understand some or one of the formats.

3

you are looking for file command

file x y
x: ASCII cpio archive (SVR4 with no CRC)
y: ASCII cpio archive (pre-SVR4 or odc)

as per man file

file — determine file type

gnu cpio use following format ( see https://www.gnu.org/software/cpio/manual/cpio.html#format ), to be used with -H format

  • ‘bin’ The obsolete binary format. (2147483647 bytes)
  • ‘odc’ The old (POSIX.1) portable format. (8589934591 bytes)
  • ‘newc’ The new (SVR4) portable format, which supports file systems having more than 65536 i-nodes. (4294967295 bytes)
  • ‘crc’ The new (SVR4) portable format with a checksum added.
  • ‘tar’ The old tar format. (8589934591 bytes)
  • ‘ustar’ The POSIX.1 tar format. Also recognizes GNU tar archives, which are similar but not identical. (8589934591 bytes)
  • ‘hpbin’ The obsolete binary format used by HPUX’s cpio (which stores device files differently).
  • ‘hpodc’ The portable format used by HPUX’s cpio (which stores device files differently).
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.