cpio
Purpose
Describes copy in and out (cpio) archive file.
Description
When the -c flag of the cpio command is not used, the
header structure is:
struct {
short
h_magic,
h_dev;
unsigned short
h_ino,
h_mode,
h_uid,
h_gid;
short
h_nlink,
h_rdev,
h_mtime[2],
h_namesize,
h_filesize[2];
char
h_name[n]; /* described below */
} Hdr;
When the cpio command is used with the -c flag, the
header for the cpio structure may be read as:
sscanf(Chdr,"%6ho%6ho%6ho%6ho%6ho%6ho%6ho%6ho%11lo%6ho%11lo%s",
&Hdr.h_magic, &Hdr.h_dev, &Hdr.h_ino, &Hdr.h_mode,
&Hdr.h_uid, &Hdr.h_gid, &Hdr.h_nlink, &Hdr.h_rdev,
&Longtime, &Hdr.h_namesize, &Longfile, &Hdr.h_name);
Longtime and Longfile are equivalent to Hdr.h_mtime and
Hdr.h_filesize, respectively. The contents of each file
together with other items describing the file are
recorded in an element of the array of varying length
structures. The member h_magic contains the constant
octal 070707 (or 0x71c7). The stat system call explains
the meaning of structure members h_dev through h_mtime.
The length of the null-terminated path name, h_name,
including the null byte is indicated by n, where n =
(h_namesize % 2) + h_namesize. In other words, n is
equal to h_namesize if h_namesize is even. If h_namesize
is odd, n is equal to h_namesize + 1.
The last record of the archive always contains the name
"TRAILER!!!" Special files, directories, and the trailer
are recorded with h_filesize equal to 0.
Related Information
In this book: "scanf, fscanf, sscanf, NLscanf, NLfscanf,
NLsscanf" and "stat, fstat."
The cpio and find commands in AIX Operating System Com-
mands Reference.