The old binary format is limited to 16 bits for user id, group id, device, and inode numbers. It is limited to 4 gigabyte file sizes. The old ASCII format is limited to 18 bits for the user id, group id, device, and inode numbers. It is limited to 8 gigabyte file sizes. The new ASCII format is limited to 4 gigabyte file sizes. CPIO 2.5 knows also about tar, but it is not recognized here.
Each file has a 76 (ascii) / 26 (binary) byte header, a variable length, NUL terminated file name, and variable length file data. A header for a file name "TRAILER!!!" indicates the end of the archive.
All the fields in the header are ISO 646 (approximately ASCII) strings of octal numbers, left padded, not NUL terminated.
FIELDNAME NOTES
c_magic The integer value octal 070707. This value can be used to deter-
mine whether this archive is written with little-endian or big-
endian integers.
c_dev Device that contains a directory entry for this file
c_ino I-node number that identifies the input file to the file system
c_mode The mode specifies both the regular permissions and the file type.
c_uid Numeric User ID of the owner of the input file
c_gid Numeric Group ID of the owner of the input file
c_nlink Number of links that are connected to the input file
c_rdev For block special and character special entries, this field
contains the associated device number. For all other entry types,
it should be set to zero by writers and ignored by readers.
c_mtime[2] Modification time of the file, indicated as the number of seconds
since the start of the epoch, 00:00:00 UTC January 1, 1970. The
four-byte integer is stored with the most-significant 16 bits
first followed by the least-significant 16 bits. Each of the two
16 bit values are stored in machine-native byte order.
c_namesize Length of the path name, including the terminating null byte
c_filesize[2] Length of the file in bytes. This is the length of the data
section that follows the header structure. Must be 0 for
FIFOs and directories
All fields are unsigned short fields with 16-bit integer values
apart from c_mtime and c_filesize which are 32-bit integer values
If necessary, the file name and file data are padded with a NUL byte to an even length
Special files, directories, and the trailer are recorded with the h_filesize field equal to 0.
In the ASCII version of this format, the 16-bit entries are represented as 6-byte octal numbers, and the 32-bit entries are represented as 11-byte octal numbers. No padding is added.
Each file has a 110 byte header, a variable length, NUL terminated file name, and variable length file data. A header for a file name "TRAILER!!!" indicates the end of the archive. All the fields in the header are ISO 646 (approximately ASCII) strings of hexadecimal numbers, left padded, not NUL terminated.
FIELDNAME NOTES
c_magic[6] The string 070701 for new ASCII, the string 070702 for new ASCII with CRC
c_ino[8]
c_mode[8]
c_uid[8]
c_gid[8]
c_nlink[8]
c_mtim[8]
c_filesize[8] must be 0 for FIFOs and directories
c_maj[8]
c_min[8]
c_rmaj[8] only valid for chr and blk special files
c_rmin[8] only valid for chr and blk special files
c_namesize[8] count includes terminating NUL in path name
c_check[8] 0 for "new" portable format; for CRC format
the sum of all the bytes in the file
New ASCII Format The "new" ASCII format uses 8-byte hexadecimal fields for all numbers and separates device numbers into separate fields for major and minor numbers.
The path name is followed by NUL bytes so that the total size of the fixed header plus path name is a multiple of four. Likewise, the file data is padded to a multiple of four bytes.
This class uses mutable fields and is not considered to be threadsafe.
Based on code from the jRPM project (https://jrpm.sourceforge.net).
The MAGIC numbers and other constants are defined in CpioConstants
N.B. does not handle the cpio "tar" format
| Modifier and Type | Field and Description |
|---|---|
| private final int | alignmentBoundary
The boundary to which the header and data elements are aligned: 0, 2 or 4 bytes |
| private long | |
| private final short | fileFormat
See |
| private long | filesize
Number of bytes in the file |
| private long | |
| private final int | headerSize
The number of bytes in each header record; depends on the file format |
| private long | |
| private long | |
| private long | |
| private long | |
| private long | |
| private String | |
| private long | |
| private long | |
| private long | |
| private long |
| Access | Constructor and Description |
|---|---|
| public | CpioArchiveEntry(final File
The file to gather information from. inputFile, final String The name of this entry. entryName)Creates a CpioArchiveEntry with a specified name for a specified file. |
| public | CpioArchiveEntry(final Path
The file to gather information from. inputPath, final String The name of this entry. entryName, final LinkOption... options indicating how symbolic links are handled. options)Creates a CpioArchiveEntry with a specified name for a specified file. |
| public | CpioArchiveEntry(final short
The cpio format for this entry.
format)Possible format values are:
CpioConstants.FORMAT_NEW
CpioConstants.FORMAT_NEW_CRC
CpioConstants.FORMAT_OLD_BINARY
CpioConstants.FORMAT_OLD_ASCII
Creates a CpioArchiveEntry with a specified format. |
| public | CpioArchiveEntry(final short
The cpio format for this entry. format, final File The file to gather information from. inputFile, final String The name of this entry.
entryName)Possible format values are:
CpioConstants.FORMAT_NEW
CpioConstants.FORMAT_NEW_CRC
CpioConstants.FORMAT_OLD_BINARY
CpioConstants.FORMAT_OLD_ASCII
Creates a CpioArchiveEntry with a specified name for a specified file. |
| public | CpioArchiveEntry(final short
The cpio format for this entry. format, final Path The file to gather information from. inputPath, final String The name of this entry.
entryName, final LinkOption... Possible format values are:
CpioConstants.FORMAT_NEW
CpioConstants.FORMAT_NEW_CRC
CpioConstants.FORMAT_OLD_BINARY
CpioConstants.FORMAT_OLD_ASCII
options indicating how symbolic links are handled. options)Creates a CpioArchiveEntry with a specified name for a specified path. |
| public | CpioArchiveEntry(final short
The cpio format for this entry. format, final String The name of this entry.
name)Possible format values are:
CpioConstants.FORMAT_NEW
CpioConstants.FORMAT_NEW_CRC
CpioConstants.FORMAT_OLD_BINARY
CpioConstants.FORMAT_OLD_ASCII
Creates a CpioArchiveEntry with a specified name. |
| public | CpioArchiveEntry(final short
The cpio format for this entry. format, final String The name of this entry. name, final long The size of this entry
size)Possible format values are:
CpioConstants.FORMAT_NEW
CpioConstants.FORMAT_NEW_CRC
CpioConstants.FORMAT_OLD_BINARY
CpioConstants.FORMAT_OLD_ASCII
Creates a CpioArchiveEntry with a specified name. |
| public | CpioArchiveEntry(final String
The name of this entry. name)Creates a CpioArchiveEntry with a specified name. |
| public | CpioArchiveEntry(final String
The name of this entry. name, final long The size of this entry size)Creates a CpioArchiveEntry with a specified name. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | |
| public boolean | equals(final Object
the reference object with which to compare. obj)Overrides java. |
| public int | Returns: the alignment boundary (0, 2, 4) in bytesGets the alignment boundary for this CPIO format |
| public long | |
| public int | Returns: the number of bytes needed to pad the data (0,1,2,3)Gets the number of bytes needed to pad the data to the alignment boundary. |
| public long | |
| public long | |
| public long | |
| public short | |
| public long | |
| public int | Returns: the number of bytes needed to pad the header (0,1,2,3)
Deprecated
This method doesn't properly work for multi-byte encodings.
Gets the number of bytes needed to pad the header to the alignment boundary.
|
| public int | Returns: the number of bytes needed to pad the header (0,1,2,3)The character set used to encode the entry name in the stream. charset)Gets the number of bytes needed to pad the header to the alignment boundary. |
| public int | Returns: the number of bytes needed to pad the header (0,1,2,3)The length of the name in bytes, as read in the stream. Without the trailing zero byte. nameSize)Gets the number of bytes needed to pad the header to the alignment boundary. |
| public int | |
| public long | |
| public Date | getLastModifiedDate()
Implements org. |
| public long | |
| public String | Returns: the name.Implements org. |
| public long | |
| public long | |
| public long | |
| public long | |
| public long | Returns: the filesize.Implements org. |
| public long | |
| public long | |
| public int | |
| public boolean | Returns: TRUE if this entry is a block device.Checks if this entry represents a block device. |
| public boolean | Returns: TRUE if this entry is a character device.Checks if this entry represents a character device. |
| public boolean | Returns: TRUE if this entry is a directory.Implements org. |
| public boolean | Returns: TRUE if this entry is a network device.Checks if this entry represents a network device. |
| public boolean | |
| public boolean | Returns: TRUE if this entry is a regular file.Checks if this entry represents a regular file. |
| public boolean | |
| public boolean | Returns: TRUE if this entry is a symbolic link.Checks if this entry represents a symbolic link. |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | setRemoteDeviceMaj(final long
The remote major device id to set. rmaj)Sets the remote major device id. |
| public void | setRemoteDeviceMin(final long
The remote minor device id to set. rmin)Sets the remote minor device id. |
| public void | |
| public void | |
| public void | |
| public void |
| alignmentBoundary | back to summary |
|---|---|
| private final int alignmentBoundary The boundary to which the header and data elements are aligned: 0, 2 or 4 bytes | |
| chksum | back to summary |
|---|---|
| private long chksum | |
| fileFormat | back to summary |
|---|---|
| private final short fileFormat See | |
| filesize | back to summary |
|---|---|
| private long filesize Number of bytes in the file | |
| gid | back to summary |
|---|---|
| private long gid | |
| headerSize | back to summary |
|---|---|
| private final int headerSize The number of bytes in each header record; depends on the file format | |
| inode | back to summary |
|---|---|
| private long inode | |
| maj | back to summary |
|---|---|
| private long maj | |
| min | back to summary |
|---|---|
| private long min | |
| mode | back to summary |
|---|---|
| private long mode | |
| mtime | back to summary |
|---|---|
| private long mtime | |
| name | back to summary |
|---|---|
| private String name | |
| nlink | back to summary |
|---|---|
| private long nlink | |
| rmaj | back to summary |
|---|---|
| private long rmaj | |
| rmin | back to summary |
|---|---|
| private long rmin | |
| uid | back to summary |
|---|---|
| private long uid | |
| CpioArchiveEntry | back to summary |
|---|---|
| public CpioArchiveEntry(final File inputFile, final String entryName) Creates a CpioArchiveEntry with a specified name for a specified file. The format of this entry will be the new format. | |
| CpioArchiveEntry | back to summary |
|---|---|
| public CpioArchiveEntry(final Path inputPath, final String entryName, final LinkOption... options) throws IOException Creates a CpioArchiveEntry with a specified name for a specified file. The format of this entry will be the new format.
| |
| CpioArchiveEntry | back to summary |
|---|---|
| public CpioArchiveEntry(final short format) Creates a CpioArchiveEntry with a specified format.
| |
| CpioArchiveEntry | back to summary |
|---|---|
| public CpioArchiveEntry(final short format, final File inputFile, final String entryName) Creates a CpioArchiveEntry with a specified name for a specified file.
| |
| CpioArchiveEntry | back to summary |
|---|---|
| public CpioArchiveEntry(final short format, final Path inputPath, final String entryName, final LinkOption... options) throws IOException Creates a CpioArchiveEntry with a specified name for a specified path.
| |
| CpioArchiveEntry | back to summary |
|---|---|
| public CpioArchiveEntry(final short format, final String name) Creates a CpioArchiveEntry with a specified name.
| |
| CpioArchiveEntry | back to summary |
|---|---|
| public CpioArchiveEntry(final short format, final String name, final long size) Creates a CpioArchiveEntry with a specified name.
| |
| CpioArchiveEntry | back to summary |
|---|---|
| public CpioArchiveEntry(final String name) Creates a CpioArchiveEntry with a specified name. The format of this entry will be the new format.
| |
| CpioArchiveEntry | back to summary |
|---|---|
| public CpioArchiveEntry(final String name, final long size) Creates a CpioArchiveEntry with a specified name. The format of this entry will be the new format.
| |
| checkNewFormat | back to summary |
|---|---|
| private void checkNewFormat() Checks if the method is allowed for the defined format. | |
| checkOldFormat | back to summary |
|---|---|
| private void checkOldFormat() Checks if the method is allowed for the defined format. | |
| equals | back to summary |
|---|---|
| public boolean equals(final Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getAlignmentBoundary | back to summary |
|---|---|
| public int getAlignmentBoundary() Gets the alignment boundary for this CPIO format
| |
| getChksum | back to summary |
|---|---|
| public long getChksum() Gets the checksum. Only supported for the new formats.
| |
| getDataPadCount | back to summary |
|---|---|
| public int getDataPadCount() Gets the number of bytes needed to pad the data to the alignment boundary.
| |
| getDevice | back to summary |
|---|---|
| public long getDevice() Gets the device id.
| |
| getDeviceMaj | back to summary |
|---|---|
| public long getDeviceMaj() Gets the major device id.
| |
| getDeviceMin | back to summary |
|---|---|
| public long getDeviceMin() Gets the minor device id
| |
| getFormat | back to summary |
|---|---|
| public short getFormat() Gets the format for this entry.
| |
| getGID | back to summary |
|---|---|
| public long getGID() Gets the group id.
| |
| getHeaderPadCount | back to summary |
|---|---|
| public int getHeaderPadCount()
Deprecated This method doesn't properly work for multi-byte encodings. And creates corrupt archives. Use Gets the number of bytes needed to pad the header to the alignment boundary.
| |
| getHeaderPadCount | back to summary |
|---|---|
| public int getHeaderPadCount(final Charset charset) Gets the number of bytes needed to pad the header to the alignment boundary.
| |
| getHeaderPadCount | back to summary |
|---|---|
| public int getHeaderPadCount(final long nameSize) Gets the number of bytes needed to pad the header to the alignment boundary.
| |
| getHeaderSize | back to summary |
|---|---|
| public int getHeaderSize() Gets the header size for this CPIO format
| |
| getInode | back to summary |
|---|---|
| public long getInode() Sets the inode.
| |
| getLastModifiedDate | back to summary |
|---|---|
| public Date getLastModifiedDate() Implements org. Doc from org. Gets the last modified date of this entry. | |
| getMode | back to summary |
|---|---|
| public long getMode() Gets the mode of this entry (e.g. directory, regular file).
| |
| getName | back to summary |
|---|---|
| public String getName() Implements org. Gets the name. This method returns the raw name as it is stored inside of the archive. | |
| getNumberOfLinks | back to summary |
|---|---|
| public long getNumberOfLinks() Gets the number of links.
| |
| getRemoteDevice | back to summary |
|---|---|
| public long getRemoteDevice() Gets the remote device id.
| |
| getRemoteDeviceMaj | back to summary |
|---|---|
| public long getRemoteDeviceMaj() Gets the remote major device id.
| |
| getRemoteDeviceMin | back to summary |
|---|---|
| public long getRemoteDeviceMin() Gets the remote minor device id.
| |
| getSize | back to summary |
|---|---|
| public long getSize() Implements org. Gets the filesize.
| |
| getTime | back to summary |
|---|---|
| public long getTime() Gets the time in seconds.
| |
| getUID | back to summary |
|---|---|
| public long getUID() Gets the user id.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| isBlockDevice | back to summary |
|---|---|
| public boolean isBlockDevice() Checks if this entry represents a block device.
| |
| isCharacterDevice | back to summary |
|---|---|
| public boolean isCharacterDevice() Checks if this entry represents a character device.
| |
| isDirectory | back to summary |
|---|---|
| public boolean isDirectory() Implements org. Checks if this entry represents a directory.
| |
| isNetwork | back to summary |
|---|---|
| public boolean isNetwork() Checks if this entry represents a network device.
| |
| isPipe | back to summary |
|---|---|
| public boolean isPipe() Checks if this entry represents a pipe.
| |
| isRegularFile | back to summary |
|---|---|
| public boolean isRegularFile() Checks if this entry represents a regular file.
| |
| isSocket | back to summary |
|---|---|
| public boolean isSocket() Checks if this entry represents a socket.
| |
| isSymbolicLink | back to summary |
|---|---|
| public boolean isSymbolicLink() Checks if this entry represents a symbolic link.
| |
| setChksum | back to summary |
|---|---|
| public void setChksum(final long chksum) Sets the checksum. The checksum is calculated by adding all bytes of a file to transfer (crc += buf[pos] & 0xFF).
| |
| setDevice | back to summary |
|---|---|
| public void setDevice(final long device) Sets the device id.
| |
| setDeviceMaj | back to summary |
|---|---|
| public void setDeviceMaj(final long maj) Sets major device id.
| |
| setDeviceMin | back to summary |
|---|---|
| public void setDeviceMin(final long min) Sets the minor device id
| |
| setGID | back to summary |
|---|---|
| public void setGID(final long gid) Sets the group id.
| |
| setInode | back to summary |
|---|---|
| public void setInode(final long inode) Sets the inode.
| |
| setMode | back to summary |
|---|---|
| public void setMode(final long mode) Sets the mode of this entry (e.g. directory, regular file).
| |
| setName | back to summary |
|---|---|
| public void setName(final String name) Sets the name.
| |
| setNumberOfLinks | back to summary |
|---|---|
| public void setNumberOfLinks(final long nlink) Sets the number of links.
| |
| setRemoteDevice | back to summary |
|---|---|
| public void setRemoteDevice(final long device) Sets the remote device id.
| |
| setRemoteDeviceMaj | back to summary |
|---|---|
| public void setRemoteDeviceMaj(final long rmaj) Sets the remote major device id.
| |
| setRemoteDeviceMin | back to summary |
|---|---|
| public void setRemoteDeviceMin(final long rmin) Sets the remote minor device id.
| |
| setSize | back to summary |
|---|---|
| public void setSize(final long size) Sets the filesize.
| |
| setTime | back to summary |
|---|---|
| public void setTime(final FileTime time) Sets the time.
| |
| setTime | back to summary |
|---|---|
| public void setTime(final long time) Sets the time in seconds.
| |
| setUID | back to summary |
|---|---|
| public void setUID(final long uid) Sets the user id.
| |