Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.bin / ar / ar.5
1 .\" Copyright (c) 1990, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)ar.5.5      8.1 (Berkeley) 6/9/93
33 .\" $FreeBSD: src/usr.bin/ar/ar.5,v 1.5.2.2 2001/12/14 15:53:29 ru Exp $
34 .\"
35 .Dd June 9, 1993
36 .Dt AR 5
37 .Os
38 .Sh NAME
39 .Nm ar
40 .Nd archive (library) file format
41 .Sh SYNOPSIS
42 .In ar.h
43 .Sh DESCRIPTION
44 The archive command
45 .Nm
46 combines several files into one.
47 Archives are mainly used as libraries of object files intended to be
48 loaded using the link-editor
49 .Xr ld 1 .
50 .Pp
51 A file created with
52 .Nm
53 begins with the ``magic'' string "!<arch>\en".
54 The rest of the archive is made up of objects, each of which is composed
55 of a header for a file, a possible file name, and the file contents.
56 The header is portable between machine architectures, and, if the file
57 contents are printable, the archive is itself printable.
58 .Pp
59 The header is made up of six variable length
60 .Tn ASCII
61 fields, followed by a
62 two character trailer.
63 The fields are the object name (16 characters), the file last modification
64 time (12 characters), the user and group id's (each 6 characters), the file
65 mode (8 characters) and the file size (10 characters).
66 All numeric fields are in decimal, except for the file mode which is in
67 octal.
68 .Pp
69 The modification time is the file
70 .Fa st_mtime
71 field, i.e.,
72 .Dv CUT
73 seconds since
74 the epoch.
75 The user and group id's are the file
76 .Fa st_uid
77 and
78 .Fa st_gid
79 fields.
80 The file mode is the file
81 .Fa st_mode
82 field.
83 The file size is the file
84 .Fa st_size
85 field.
86 The two-byte trailer is the string "\`\en".
87 .Pp
88 Only the name field has any provision for overflow.
89 If any file name is more than 16 characters in length or contains an
90 embedded space, the string "#1/" followed by the
91 .Tn ASCII
92 length of the
93 name is written in the name field.
94 The file size (stored in the archive header) is incremented by the length
95 of the name.
96 The name is then written immediately following the archive header.
97 .Pp
98 Any unused characters in any of these fields are written as space
99 characters.
100 If any fields are their particular maximum number of characters in
101 length, there will be no separation between the fields.
102 .Pp
103 Objects in the archive are always an even number of bytes long; files
104 which are an odd number of bytes long are padded with a newline (``\en'')
105 character, although the size in the header does not reflect this.
106 .Sh SEE ALSO
107 .Xr ar 1 ,
108 .Xr stat 2
109 .Sh HISTORY
110 There have been at least four
111 .Nm
112 formats.
113 The first was denoted by the leading ``magic'' number 0177555 (stored as
114 type int).
115 These archives were almost certainly created on a 16-bit machine, and
116 contain headers made up of five fields.
117 The fields are the object name (8 characters), the file last modification
118 time (type long), the user id (type char), the file mode (type char) and
119 the file size (type unsigned int).
120 Files were padded to an even number of bytes.
121 .Pp
122 The second was denoted by the leading ``magic'' number 0177545 (stored as
123 type int).
124 These archives may have been created on either 16 or 32-bit machines, and
125 contain headers made up of six fields.
126 The fields are the object name (14 characters), the file last modification
127 time (type long), the user and group id's (each type char), the file mode
128 (type int) and the file size (type long).
129 Files were padded to an even number of bytes.
130 .\" For more information on converting from this format see
131 .\" .Xr arcv 8 .
132 .Pp
133 The current archive format (without support for long character names and
134 names with embedded spaces) was introduced in
135 .Bx 4.0 .
136 The headers were the same as the current format, with the exception that
137 names longer than 16 characters were truncated, and names with embedded
138 spaces (and often trailing spaces) were not supported.
139 It has been extended for these reasons,
140 as described above.
141 This format first appeared in
142 .Bx 4.4 .
143 .Sh COMPATIBILITY
144 No archive format is currently specified by any standard.
145 .At V
146 has historically distributed archives in a different format from
147 all of the above.