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