Commit | Line | Data |
---|---|---|
d883e586 KB |
1 | .\" Copyright (c) 1990 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" %sccs.include.redist.man% | |
5 | .\" | |
6 | .\" @(#)ar.5.5 6.2 (Berkeley) %G% | |
6e5bb952 | 7 | .\" |
6592a7dc | 8 | .TH AR 5 "" |
6e5bb952 KM |
9 | .AT 3 |
10 | .SH NAME | |
11 | ar \- archive (library) file format | |
12 | .SH SYNOPSIS | |
13 | .B #include <ar.h> | |
14 | .SH DESCRIPTION | |
6e5bb952 KM |
15 | .PP |
16 | The archive command | |
d883e586 | 17 | .IR ar |
f4258d08 | 18 | combines several files into one. |
d883e586 KB |
19 | Archives are mainly used as libraries of object files intended to be |
20 | loaded using the link-editor | |
21 | .IR ld (1). | |
6e5bb952 | 22 | .PP |
d883e586 | 23 | A file created with |
6e5bb952 | 24 | .I ar |
d883e586 KB |
25 | begins with the ``magic'' string "!<arch>\en". |
26 | The rest of the archive is made up of objects, each of which is composed | |
27 | of a header for a file, a possible file name, and the file contents. | |
28 | The header is portable between machine architectures, and, if the file | |
29 | contents are printable, the archive is itself printable. | |
30 | .PP | |
31 | The header is made up of six variable length ASCII fields, followed by a | |
32 | two character trailer. | |
33 | The fields are the object name (16 characters), the file last modification | |
34 | time (12 characters), the user and group id's (each 6 characters), the file | |
35 | mode (8 characters) and the file size (10 characters). | |
36 | All numeric fields are in decimal, except for the file mode which is in | |
37 | octal. | |
38 | .PP | |
39 | The modification time is the file st_mtime field, i.e., CUT seconds since | |
40 | the epoch. | |
41 | The user and group id's are the file st_uid and st_gid fields. | |
42 | The file mode is the file st_mode field. | |
43 | The file size is the file st_size field. | |
44 | The two-byte trailer is the string "\`\en". | |
45 | .PP | |
46 | Only the name field has any provision for overflow. | |
47 | If any file name is more than 16 characters in length or contains an | |
48 | embedded space, the string "#1/" followed by the ASCII length of the | |
49 | name is written in the name field. | |
50 | The file size (stored in the archive header) is incremented by the length | |
51 | of the name. | |
52 | The name is then written immediately following the archive header. | |
53 | .PP | |
54 | Any unused characters in any of these fields are written as space | |
55 | characters. | |
56 | If any fields are their particular maximum number of characters in | |
57 | length, there will be no separation between the fields. | |
58 | .PP | |
59 | Objects in the archive are always an even number of bytes long; files | |
60 | which are an odd number of bytes long are padded with a newline (``\en'') | |
61 | character, although the size in the header does not reflect this. | |
6e5bb952 | 62 | .SH "SEE ALSO" |
d883e586 KB |
63 | ar(1), stat(2) |
64 | .SH HISTORY | |
65 | There have been at least four | |
66 | .I ar | |
67 | formats. | |
68 | The first was denoted by the leading ``magic'' number 0177555 (stored as | |
69 | type int). | |
70 | These archives were almost certainly created on a 16-bit machine, and | |
71 | contain headers made up of five fields. | |
72 | The fields are the object name (8 characters), the file last modification | |
73 | time (type long), the user id (type char), the file mode (type char) and | |
74 | the file size (type unsigned int). | |
75 | Files were padded to an even number of bytes. | |
76 | .PP | |
77 | The second was denoted by the leading ``magic'' number 0177545 (stored as | |
78 | type int). | |
79 | These archives may have been created on either 16 or 32-bit machines, and | |
80 | contain headers made up of six fields. | |
81 | The fields are the object name (14 characters), the file last modification | |
82 | time (type long), the user and group id's (each type char), the file mode | |
83 | (type int) and the file size (type long). | |
84 | Files were padded to an even number of bytes. | |
85 | For more information on converting from this format see | |
86 | .IR arcv (8). | |
87 | .PP | |
88 | The current archive format (without support for long character names and | |
89 | names with embedded spaces) was introduced in 4.0BSD. | |
90 | The headers were the same as the current format, with the exception that | |
91 | names longer than 16 characters were truncated, and names with embedded | |
92 | spaces (and often trailing spaces) were not supported. | |
93 | It was extended for these reasons in 4.4BSD, as described above. | |
94 | .SH COMPATIBILITY | |
95 | No archive format is currently specified by any standard. | |
96 | System V has historically distributed archives in a different format from | |
97 | all of the above. |