Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. |
2 | .\" 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 6.3 (Berkeley) 5/10/91 | |
33 | .\" | |
34 | .Dd May 10, 1991 | |
35 | .Dt AR 5 | |
36 | .Os | |
37 | .Sh NAME | |
38 | .Nm ar | |
39 | .Nd archive (library) file format | |
40 | .Sh SYNOPSIS | |
41 | .Fd #include <ar.h> | |
42 | .Sh DESCRIPTION | |
43 | The archive command | |
44 | .Nm ar | |
45 | combines several files into one. | |
46 | Archives are mainly used as libraries of object files intended to be | |
47 | loaded using the link-editor | |
48 | .Xr ld 1 . | |
49 | .Pp | |
50 | A file created with | |
51 | .Nm ar | |
52 | begins with the ``magic'' string "!<arch>\en". | |
53 | The rest of the archive is made up of objects, each of which is composed | |
54 | of a header for a file, a possible file name, and the file contents. | |
55 | The header is portable between machine architectures, and, if the file | |
56 | contents are printable, the archive is itself printable. | |
57 | .Pp | |
58 | The header is made up of six variable length | |
59 | .Tn ASCII | |
60 | fields, followed by a | |
61 | two character trailer. | |
62 | The fields are the object name (16 characters), the file last modification | |
63 | time (12 characters), the user and group id's (each 6 characters), the file | |
64 | mode (8 characters) and the file size (10 characters). | |
65 | All numeric fields are in decimal, except for the file mode which is in | |
66 | octal. | |
67 | .Pp | |
68 | The modification time is the file | |
69 | .Fa st_mtime | |
70 | field, i.e., | |
71 | .Dv CUT | |
72 | seconds since | |
73 | the epoch. | |
74 | The user and group id's are the file | |
75 | .Fa st_uid | |
76 | and | |
77 | .Fa st_gid | |
78 | fields. | |
79 | The file mode is the file | |
80 | .Fa st_mode | |
81 | field. | |
82 | The file size is the file | |
83 | .Fa st_size | |
84 | field. | |
85 | The two-byte trailer is the string "\`\en". | |
86 | .Pp | |
87 | Only the name field has any provision for overflow. | |
88 | If any file name is more than 16 characters in length or contains an | |
89 | embedded space, the string "#1/" followed by the | |
90 | .Tn ASCII | |
91 | length of the | |
92 | name is written in the name field. | |
93 | The file size (stored in the archive header) is incremented by the length | |
94 | of the name. | |
95 | The name is then written immediately following the archive header. | |
96 | .Pp | |
97 | Any unused characters in any of these fields are written as space | |
98 | characters. | |
99 | If any fields are their particular maximum number of characters in | |
100 | length, there will be no separation between the fields. | |
101 | .Pp | |
102 | Objects in the archive are always an even number of bytes long; files | |
103 | which are an odd number of bytes long are padded with a newline (``\en'') | |
104 | character, although the size in the header does not reflect this. | |
105 | .Sh SEE ALSO | |
106 | .Xr ar 1 , | |
107 | .Xr stat 2 | |
108 | .Sh HISTORY | |
109 | There have been at least four | |
110 | .Nm ar | |
111 | formats. | |
112 | The first was denoted by the leading ``magic'' number 0177555 (stored as | |
113 | type int). | |
114 | These archives were almost certainly created on a 16-bit machine, and | |
115 | contain headers made up of five fields. | |
116 | The fields are the object name (8 characters), the file last modification | |
117 | time (type long), the user id (type char), the file mode (type char) and | |
118 | the file size (type unsigned int). | |
119 | Files were padded to an even number of bytes. | |
120 | .Pp | |
121 | The second was denoted by the leading ``magic'' number 0177545 (stored as | |
122 | type int). | |
123 | These archives may have been created on either 16 or 32-bit machines, and | |
124 | contain headers made up of six fields. | |
125 | The fields are the object name (14 characters), the file last modification | |
126 | time (type long), the user and group id's (each type char), the file mode | |
127 | (type int) and the file size (type long). | |
128 | Files were padded to an even number of bytes. | |
129 | For more information on converting from this format see | |
130 | .Xr arcv 8 . | |
131 | .Pp | |
132 | The current archive format (without support for long character names and | |
133 | names with embedded spaces) was introduced in | |
134 | .Bx 4.0 . | |
135 | The headers were the same as the current format, with the exception that | |
136 | names longer than 16 characters were truncated, and names with embedded | |
137 | spaces (and often trailing spaces) were not supported. | |
138 | It has been extended for these reasons, | |
139 | as described above. | |
140 | This format is | |
141 | .Ud . | |
142 | .Sh COMPATIBILITY | |
143 | No archive format is currently specified by any standard. | |
144 | .At V | |
145 | has historically distributed archives in a different format from | |
146 | all of the above. |