xref: /original-bsd/old/cpio/cpioformat.5 (revision e59fb703)
1.\" Copyright 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.roff%
5.\"
6.\"     @(#)cpioformat.5	5.3 (Berkeley) 05/10/91
7.\"
8.Dd
9.Dt CPIO 5
10.Os
11.Sh NAME
12.Nm cpio
13.Nd format of cpio archive
14.Sh DESCRIPTION
15The header structure, when the
16.Fl c
17option of
18.Xr cpio 1
19is not used, is:
20.Bd -literal -offset indent
21struct {
22	short	h_magic,
23		h_dev;
24	ushort	h_ino,
25		h_mode,
26		h_uid,
27		h_gid;
28	short	h_nlink,
29		h_rdev,
30		h_mtime[2],
31		h_namesize,
32		h_filesize[2];
33	char	h_name[h_namesize rounded to word];
34} Hdr;
35.Ed
36.Pp
37When the
38.Fl c
39option is used, the header information is described by:
40.Bd -literal -offset indent
41sscanf(Chdr,"%6o%6o%6o%6o%6o%6o%6o%6o%11lo%6o%11lo%s",
42&Hdr.h_magic, &Hdr.h_dev, &Hdr.h_ino, &Hdr.h_mode,
43&Hdr.h_uid, &Hdr.h_gid, &Hdr.h_nlink, &Hdr.h_rdev,
44&Longtime, &Hdr.h_namesize,&Longfile,Hdr.h_name);
45.Ed
46.Pp
47.Fa Longtime
48and
49.Fa Longfile
50are equivalent to
51.Fa Hdr.h_mtime
52and
53.Fa Hdr.h_filesize ,
54respectively.
55The contents of each file are
56recorded in an element of the array of varying lenght
57structures, archive, together with other items describing
58the file.
59Every instance of
60.Fa h_magic
61contains the constant
62070707 (octal).
63The itimes
64.Fa h_dev
65through
66.Fa h_mtime
67have
68meanings explained in
69.Xr stat 2 .
70The length of the null-terminated path name
71.Fa H_name ,
72icluding the null byte, is
73given by
74.Fa h_namesize .
75.Pp
76The last record of the archive always contains the name
77TRAILER!!!.  Special files, directories, and the trailer are
78recorded with
79.Fa H_filesize
80equal to zero.
81.Sh SEE ALSO
82.Xr cpio 1 ,
83.Xr find 1 ,
84.Xr stat 2
85.Sh HISTORY
86A
87.Xr cpio 1
88command appeared in
89.At V .
90This file format is derived from the
91.At V
92sources which were contributed to the public domain by AT&T.
93