|
|
struct {
short h_magic; /* cpio archive magic number: 070707 */
short h_dev; /* see stat(S) */
ushort h_ino;
ushort h_mode,
h_uid,
h_gid;
short h_nlink;
short h_rdev;
ushort h_mtime[2];
short h_namesize; /* length of h_name + null */
ushort h_filesize[2]; /* length of file */
char h_name[h_namesize rounded to short]; /* pathname of file */
} oldHdr;
h_name.
When one of the -c, -Hcrc, or -Hodc options is used, the header information is written in ASCII form for portability.
An ASCII header is truncated at the end of the null-terminated pathname. The size of the header (without pathname) is 76 bytes for the -Hodc option, and 110 bytes for the -c and -Hcrc options.
The -Hodc option is equivalent to the -c option in older SCO OpenServer versions of cpio. It is only suitable for backing up filesystems that implement 16-bit inode numbers.
The following C code shows an example of reading header information written using the -Hodc option:
scanf("%6o%6o%6o%6o%6o%6o%6o%6o%11lo%6o%11lo%s",
&oldHdr.h_magic, &oldHdr.h_dev, &oldHdr.h_ino, &oldHdr.h_mode,
&oldHdr.h_uid, &oldHdr.h_gid, &oldHdr.h_nlink, &oldHdr.h_rdev,
&Longtime, &oldHdr.h_namesize, &Longfile, oldHdr.h_name);
The variables ulong Longtime and ulong Longfile are used
to read the arrays oldHdr.h_mtime and oldHdr.h_filesize.
The length of the null-terminated pathname
h_name is (h_namesize + 1).
The structure members h_dev through h_mtime
are explained in
stat(S).
The -c and -Hcrc options use the SVR4 extended ASCII format suitable for backing up both 16 and 32-bit inode number filesystems. The new format supports checksums; these are written if the -Hcrc option is used.
There are some differences in the way that the SVR4 version of cpio archives hard links. See ``Limitations'' on the cpio(C) manual page for details.
The following code shows an example of reading header information written using the -c or -Hcrc options:
scanf("%6o%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%s",
&newHdr.h_magic, &newHdr.h_ino, &newHdr.h_mode,
&newHdr.h_uid, &newHdr.h_gid, &newHdr.h_nlink,
&newHdr.h_mtime, &newHdr.h_filesize, &newHdr.h_dev_maj,
&newHdr.h_dev_min, &newHdr.h_rdev_maj, &newHdr.h_rdev_min,
&newHdr.h_namesize, &newHdr.h_chksum, newHdr.h_name);
The magic number in the member h_magic determines whether
the header is in old or new format and whether it contains a checksum.
The length of the null-terminated pathname
h_name is (h_namesize + 1) rounded up to long.
The last record of the archive always contains the string TRAILER!!!.
Special files, directories, and the trailer
are recorded with h_filesize equal to zero.