libarchive-formats.5.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <!-- Creator : groff version 1.22.4 -->
  2. <!-- CreationDate: Tue Jul 18 07:11:06 2023 -->
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  4. "http://www.w3.org/TR/html4/loose.dtd">
  5. <html>
  6. <head>
  7. <meta name="generator" content="groff -Thtml, see www.gnu.org">
  8. <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
  9. <meta name="Content-Style" content="text/css">
  10. <style type="text/css">
  11. p { margin-top: 0; margin-bottom: 0; vertical-align: top }
  12. pre { margin-top: 0; margin-bottom: 0; vertical-align: top }
  13. table { margin-top: 0; margin-bottom: 0; vertical-align: top }
  14. h1 { text-align: center }
  15. </style>
  16. <title></title>
  17. </head>
  18. <body>
  19. <hr>
  20. <p>LIBARCHIVE-FORMATS(5) BSD File Formats Manual
  21. LIBARCHIVE-FORMATS(5)</p>
  22. <p style="margin-top: 1em"><b>NAME</b></p>
  23. <p style="margin-left:6%;"><b>libarchive-formats</b>
  24. &mdash; archive formats supported by the libarchive
  25. library</p>
  26. <p style="margin-top: 1em"><b>DESCRIPTION</b></p>
  27. <p style="margin-left:6%;">The libarchive(3) library reads
  28. and writes a variety of streaming archive formats. Generally
  29. speaking, all of these archive formats consist of a series
  30. of &ldquo;entries&rdquo;. Each entry stores a single file
  31. system object, such as a file, directory, or symbolic
  32. link.</p>
  33. <p style="margin-left:6%; margin-top: 1em">The following
  34. provides a brief description of each format supported by
  35. libarchive, with some information about recognized
  36. extensions or limitations of the current library support.
  37. Note that just because a format is supported by libarchive
  38. does not imply that a program that uses libarchive will
  39. support that format. Applications that use libarchive
  40. specify which formats they wish to support, though many
  41. programs do use libarchive convenience functions to enable
  42. all supported formats.</p>
  43. <p style="margin-left:6%; margin-top: 1em"><b>Tar
  44. Formats</b> <br>
  45. The libarchive(3) library can read most tar archives. It can
  46. write POSIX-standard &ldquo;ustar&rdquo; and &ldquo;pax
  47. interchange&rdquo; formats as well as v7 tar format and a
  48. subset of the legacy GNU tar format.</p>
  49. <p style="margin-left:6%; margin-top: 1em">All tar formats
  50. store each entry in one or more 512-byte records. The first
  51. record is used for file metadata, including filename,
  52. timestamp, and mode information, and the file data is stored
  53. in subsequent records. Later variants have extended this by
  54. either appropriating undefined areas of the header record,
  55. extending the header to multiple records, or by storing
  56. special entries that modify the interpretation of subsequent
  57. entries.</p>
  58. <p style="margin-top: 1em"><b>gnutar</b></p>
  59. <p style="margin-left:17%; margin-top: 1em">The
  60. libarchive(3) library can read most GNU-format tar archives.
  61. It currently supports the most popular GNU extensions,
  62. including modern long filename and linkname support, as well
  63. as atime and ctime data. The libarchive library does not
  64. support multi-volume archives, nor the old GNU long filename
  65. format. It can read GNU sparse file entries, including the
  66. new POSIX-based formats.</p>
  67. <p style="margin-left:17%; margin-top: 1em">The
  68. libarchive(3) library can write GNU tar format, including
  69. long filename and linkname support, as well as atime and
  70. ctime data.</p>
  71. <p style="margin-top: 1em"><b>pax</b></p>
  72. <p style="margin-left:17%; margin-top: 1em">The
  73. libarchive(3) library can read and write POSIX-compliant pax
  74. interchange format archives. Pax interchange format archives
  75. are an extension of the older ustar format that adds a
  76. separate entry with additional attributes stored as
  77. key/value pairs immediately before each regular entry. The
  78. presence of these additional entries is the only difference
  79. between pax interchange format and the older ustar format.
  80. The extended attributes are of unlimited length and are
  81. stored as UTF-8 Unicode strings. Keywords defined in the
  82. standard are in all lowercase; vendors are allowed to define
  83. custom keys by preceding them with the vendor name in all
  84. uppercase. When writing pax archives, libarchive uses many
  85. of the SCHILY keys defined by Joerg Schilling&rsquo;s
  86. &ldquo;star&rdquo; archiver and a few LIBARCHIVE keys. The
  87. libarchive library can read most of the SCHILY keys and most
  88. of the GNU keys introduced by GNU tar. It silently ignores
  89. any keywords that it does not understand.</p>
  90. <p style="margin-left:17%; margin-top: 1em">The pax
  91. interchange format converts filenames to Unicode and stores
  92. them using the UTF-8 encoding. Prior to libarchive 3.0,
  93. libarchive erroneously assumed that the system
  94. wide-character routines natively supported Unicode. This
  95. caused it to mis-handle non-ASCII filenames on systems that
  96. did not satisfy this assumption.</p>
  97. <p style="margin-top: 1em"><b>restricted pax</b></p>
  98. <p style="margin-left:17%;">The libarchive library can also
  99. write pax archives in which it attempts to suppress the
  100. extended attributes entry whenever possible. The result will
  101. be identical to a ustar archive unless the extended
  102. attributes entry is required to store a long file name, long
  103. linkname, extended ACL, file flags, or if any of the
  104. standard ustar data (user name, group name, UID, GID, etc)
  105. cannot be fully represented in the ustar header. In all
  106. cases, the result can be dearchived by any program that can
  107. read POSIX-compliant pax interchange format archives.
  108. Programs that correctly read ustar format (see below) will
  109. also be able to read this format; any extended attributes
  110. will be extracted as separate files stored in
  111. <i>PaxHeader</i> directories.</p>
  112. <p style="margin-top: 1em"><b>ustar</b></p>
  113. <p style="margin-left:17%; margin-top: 1em">The libarchive
  114. library can both read and write this format. This format has
  115. the following limitations:</p>
  116. <p><b>&bull;</b></p>
  117. <p style="margin-left:22%;">Device major and minor numbers
  118. are limited to 21 bits. Nodes with larger numbers will not
  119. be added to the archive.</p>
  120. <p><b>&bull;</b></p>
  121. <p style="margin-left:22%;">Path names in the archive are
  122. limited to 255 bytes. (Shorter if there is no / character in
  123. exactly the right place.)</p>
  124. <p><b>&bull;</b></p>
  125. <p style="margin-left:22%;">Symbolic links and hard links
  126. are stored in the archive with the name of the referenced
  127. file. This name is limited to 100 bytes.</p>
  128. <p><b>&bull;</b></p>
  129. <p style="margin-left:22%;">Extended attributes, file
  130. flags, and other extended security information cannot be
  131. stored.</p>
  132. <p><b>&bull;</b></p>
  133. <p style="margin-left:22%;">Archive entries are limited to
  134. 8 gigabytes in size.</p>
  135. <p style="margin-left:17%;">Note that the pax interchange
  136. format has none of these restrictions. The ustar format is
  137. old and widely supported. It is recommended when
  138. compatibility is the primary concern.</p>
  139. <p style="margin-top: 1em"><b>v7</b></p>
  140. <p style="margin-left:17%; margin-top: 1em">The libarchive
  141. library can read and write the legacy v7 tar format. This
  142. format has the following limitations:</p>
  143. <p><b>&bull;</b></p>
  144. <p style="margin-left:22%;">Only regular files,
  145. directories, and symbolic links can be archived. Block and
  146. character device nodes, FIFOs, and sockets cannot be
  147. archived.</p>
  148. <p><b>&bull;</b></p>
  149. <p style="margin-left:22%;">Path names in the archive are
  150. limited to 100 bytes.</p>
  151. <p><b>&bull;</b></p>
  152. <p style="margin-left:22%;">Symbolic links and hard links
  153. are stored in the archive with the name of the referenced
  154. file. This name is limited to 100 bytes.</p>
  155. <p><b>&bull;</b></p>
  156. <p style="margin-left:22%;">User and group information are
  157. stored as numeric IDs; there is no provision for storing
  158. user or group names.</p>
  159. <p><b>&bull;</b></p>
  160. <p style="margin-left:22%;">Extended attributes, file
  161. flags, and other extended security information cannot be
  162. stored.</p>
  163. <p><b>&bull;</b></p>
  164. <p style="margin-left:22%;">Archive entries are limited to
  165. 8 gigabytes in size.</p>
  166. <p style="margin-left:17%;">Generally, users should prefer
  167. the ustar format for portability as the v7 tar format is
  168. both less useful and less portable.</p>
  169. <p style="margin-left:6%; margin-top: 1em">The libarchive
  170. library also reads a variety of commonly-used extensions to
  171. the basic tar format. These extensions are recognized
  172. automatically whenever they appear.</p>
  173. <p style="margin-top: 1em">Numeric extensions.</p>
  174. <p style="margin-left:17%;">The POSIX standards require
  175. fixed-length numeric fields to be written with some
  176. character position reserved for terminators. Libarchive
  177. allows these fields to be written without terminator
  178. characters. This extends the allowable range; in particular,
  179. ustar archives with this extension can support entries up to
  180. 64 gigabytes in size. Libarchive also recognizes base-256
  181. values in most numeric fields. This essentially removes all
  182. limitations on file size, modification time, and device
  183. numbers.</p>
  184. <p style="margin-top: 1em">Solaris extensions</p>
  185. <p style="margin-left:17%;">Libarchive recognizes ACL and
  186. extended attribute records written by Solaris tar.</p>
  187. <p style="margin-left:6%; margin-top: 1em">The first tar
  188. program appeared in Seventh Edition Unix in 1979. The first
  189. official standard for the tar file format was the
  190. &ldquo;ustar&rdquo; (Unix Standard Tar) format defined by
  191. POSIX in 1988. POSIX.1-2001 extended the ustar format to
  192. create the &ldquo;pax interchange&rdquo; format.</p>
  193. <p style="margin-left:6%; margin-top: 1em"><b>Cpio
  194. Formats</b> <br>
  195. The libarchive library can read and write a number of common
  196. cpio variants. A cpio archive stores each entry as a
  197. fixed-size header followed by a variable-length filename and
  198. variable-length data. Unlike the tar format, the cpio format
  199. does only minimal padding of the header or file data. There
  200. are several cpio variants, which differ primarily in how
  201. they store the initial header: some store the values as
  202. octal or hexadecimal numbers in ASCII, others as binary
  203. values of varying byte order and length.</p>
  204. <p style="margin-top: 1em"><b>binary</b></p>
  205. <p style="margin-left:17%; margin-top: 1em">The libarchive
  206. library transparently reads both big-endian and
  207. little-endian variants of the the two binary cpio formats;
  208. the original one from PWB/UNIX, and the later, more widely
  209. used, variant. This format used 32-bit binary values for
  210. file size and mtime, and 16-bit binary values for the other
  211. fields. The formats support only the file types present in
  212. UNIX at the time of their creation. File sizes are limited
  213. to 24 bits in the PWB format, because of the limits of the
  214. file system, and to 31 bits in the newer binary format,
  215. where signed 32 bit longs were used.</p>
  216. <p style="margin-top: 1em"><b>odc</b></p>
  217. <p style="margin-left:17%; margin-top: 1em">This is the
  218. POSIX standardized format, which is officially known as the
  219. &ldquo;cpio interchange format&rdquo; or the
  220. &ldquo;octet-oriented cpio archive format&rdquo; and
  221. sometimes unofficially referred to as the &ldquo;old
  222. character format&rdquo;. This format stores the header
  223. contents as octal values in ASCII. It is standard, portable,
  224. and immune from byte-order confusion. File sizes and mtime
  225. are limited to 33 bits (8GB file size), other fields are
  226. limited to 18 bits.</p>
  227. <p style="margin-top: 1em"><b>SVR4/newc</b></p>
  228. <p style="margin-left:17%;">The libarchive library can read
  229. both CRC and non-CRC variants of this format. The SVR4
  230. format uses eight-digit hexadecimal values for all header
  231. fields. This limits file size to 4GB, and also limits the
  232. mtime and other fields to 32 bits. The SVR4 format can
  233. optionally include a CRC of the file contents, although
  234. libarchive does not currently verify this CRC.</p>
  235. <p style="margin-left:6%; margin-top: 1em">Cpio first
  236. appeared in PWB/UNIX 1.0, which was released within AT&amp;T
  237. in 1977. PWB/UNIX 1.0 formed the basis of System III Unix,
  238. released outside of AT&amp;T in 1981. This makes cpio older
  239. than tar, although cpio was not included in Version 7
  240. AT&amp;T Unix. As a result, the tar command became much
  241. better known in universities and research groups that used
  242. Version 7. The combination of the <b>find</b> and
  243. <b>cpio</b> utilities provided very precise control over
  244. file selection. Unfortunately, the format has many
  245. limitations that make it unsuitable for widespread use. Only
  246. the POSIX format permits files over 4GB, and its 18-bit
  247. limit for most other fields makes it unsuitable for modern
  248. systems. In addition, cpio formats only store numeric
  249. UID/GID values (not usernames and group names), which can
  250. make it very difficult to correctly transfer archives across
  251. systems with dissimilar user numbering.</p>
  252. <p style="margin-left:6%; margin-top: 1em"><b>Shar
  253. Formats</b> <br>
  254. A &ldquo;shell archive&rdquo; is a shell script that, when
  255. executed on a POSIX-compliant system, will recreate a
  256. collection of file system objects. The libarchive library
  257. can write two different kinds of shar archives:</p>
  258. <p style="margin-top: 1em"><b>shar</b></p>
  259. <p style="margin-left:17%; margin-top: 1em">The traditional
  260. shar format uses a limited set of POSIX commands, including
  261. echo(1), mkdir(1), and sed(1). It is suitable for portably
  262. archiving small collections of plain text files. However, it
  263. is not generally well-suited for large archives (many
  264. implementations of sh(1) have limits on the size of a
  265. script) nor should it be used with non-text files.</p>
  266. <p style="margin-top: 1em"><b>shardump</b></p>
  267. <p style="margin-left:17%;">This format is similar to shar
  268. but encodes files using uuencode(1) so that the result will
  269. be a plain text file regardless of the file contents. It
  270. also includes additional shell commands that attempt to
  271. reproduce as many file attributes as possible, including
  272. owner, mode, and flags. The additional commands used to
  273. restore file attributes make shardump archives less portable
  274. than plain shar archives.</p>
  275. <p style="margin-left:6%; margin-top: 1em"><b>ISO9660
  276. format</b> <br>
  277. Libarchive can read and extract from files containing
  278. ISO9660-compliant CDROM images. In many cases, this can
  279. remove the need to burn a physical CDROM just in order to
  280. read the files contained in an ISO9660 image. It also avoids
  281. security and complexity issues that come with virtual mounts
  282. and loopback devices. Libarchive supports the most common
  283. Rockridge extensions and has partial support for Joliet
  284. extensions. If both extensions are present, the Joliet
  285. extensions will be used and the Rockridge extensions will be
  286. ignored. In particular, this can create problems with
  287. hardlinks and symlinks, which are supported by Rockridge but
  288. not by Joliet.</p>
  289. <p style="margin-left:6%; margin-top: 1em">Libarchive reads
  290. ISO9660 images using a streaming strategy. This allows it to
  291. read compressed images directly (decompressing on the fly)
  292. and allows it to read images directly from network sockets,
  293. pipes, and other non-seekable data sources. This strategy
  294. works well for optimized ISO9660 images created by many
  295. popular programs. Such programs collect all directory
  296. information at the beginning of the ISO9660 image so it can
  297. be read from a physical disk with a minimum of seeking.
  298. However, not all ISO9660 images can be read in this
  299. fashion.</p>
  300. <p style="margin-left:6%; margin-top: 1em">Libarchive can
  301. also write ISO9660 images. Such images are fully optimized
  302. with the directory information preceding all file data. This
  303. is done by storing all file data to a temporary file while
  304. collecting directory information in memory. When the image
  305. is finished, libarchive writes out the directory structure
  306. followed by the file data. The location used for the
  307. temporary file can be changed by the usual environment
  308. variables.</p>
  309. <p style="margin-left:6%; margin-top: 1em"><b>Zip
  310. format</b> <br>
  311. Libarchive can read and write zip format archives that have
  312. uncompressed entries and entries compressed with the
  313. &ldquo;deflate&rdquo; algorithm. Other zip compression
  314. algorithms are not supported. It can extract jar archives,
  315. archives that use Zip64 extensions and self-extracting zip
  316. archives. Libarchive can use either of two different
  317. strategies for reading Zip archives: a streaming strategy
  318. which is fast and can handle extremely large archives, and a
  319. seeking strategy which can correctly process self-extracting
  320. Zip archives and archives with deleted members or other
  321. in-place modifications.</p>
  322. <p style="margin-left:6%; margin-top: 1em">The streaming
  323. reader processes Zip archives as they are read. It can read
  324. archives of arbitrary size from tape or network sockets, and
  325. can decode Zip archives that have been separately compressed
  326. or encoded. However, self-extracting Zip archives and
  327. archives with certain types of modifications cannot be
  328. correctly handled. Such archives require that the reader
  329. first process the Central Directory, which is ordinarily
  330. located at the end of a Zip archive and is thus inaccessible
  331. to the streaming reader. If the program using libarchive has
  332. enabled seek support, then libarchive will use this to
  333. processes the central directory first.</p>
  334. <p style="margin-left:6%; margin-top: 1em">In particular,
  335. the seeking reader must be used to correctly handle
  336. self-extracting archives. Such archives consist of a program
  337. followed by a regular Zip archive. The streaming reader
  338. cannot parse the initial program portion, but the seeking
  339. reader starts by reading the Central Directory from the end
  340. of the archive. Similarly, Zip archives that have been
  341. modified in-place can have deleted entries or other garbage
  342. data that can only be accurately detected by first reading
  343. the Central Directory.</p>
  344. <p style="margin-left:6%; margin-top: 1em"><b>Archive
  345. (library) file format</b> <br>
  346. The Unix archive format (commonly created by the ar(1)
  347. archiver) is a general-purpose format which is used almost
  348. exclusively for object files to be read by the link editor
  349. ld(1). The ar format has never been standardised. There are
  350. two common variants: the GNU format derived from SVR4, and
  351. the BSD format, which first appeared in 4.4BSD. The two
  352. differ primarily in their handling of filenames longer than
  353. 15 characters: the GNU/SVR4 variant writes a filename table
  354. at the beginning of the archive; the BSD format stores each
  355. long filename in an extension area adjacent to the entry.
  356. Libarchive can read both extensions, including archives that
  357. may include both types of long filenames. Programs using
  358. libarchive can write GNU/SVR4 format if they provide an
  359. entry called <i>//</i> containing a filename table to be
  360. written into the archive before any of the entries. Any
  361. entries whose names are not in the filename table will be
  362. written using BSD-style long filenames. This can cause
  363. problems for programs such as GNU ld that do not support the
  364. BSD-style long filenames.</p>
  365. <p style="margin-left:6%; margin-top: 1em"><b>mtree</b>
  366. <br>
  367. Libarchive can read and write files in mtree(5) format. This
  368. format is not a true archive format, but rather a textual
  369. description of a file hierarchy in which each line specifies
  370. the name of a file and provides specific metadata about that
  371. file. Libarchive can read all of the keywords supported by
  372. both the NetBSD and FreeBSD versions of mtree(8), although
  373. many of the keywords cannot currently be stored in an
  374. archive_entry object. When writing, libarchive supports use
  375. of the archive_write_set_options(3) interface to specify
  376. which keywords should be included in the output. If
  377. libarchive was compiled with access to suitable
  378. cryptographic libraries (such as the OpenSSL libraries), it
  379. can compute hash entries such as <b>sha512</b> or <b>md5</b>
  380. from file data being written to the mtree writer.</p>
  381. <p style="margin-left:6%; margin-top: 1em">When reading an
  382. mtree file, libarchive will locate the corresponding files
  383. on disk using the <b>contents</b> keyword if present or the
  384. regular filename. If it can locate and open the file on
  385. disk, it will use that to fill in any metadata that is
  386. missing from the mtree file and will read the file contents
  387. and return those to the program using libarchive. If it
  388. cannot locate and open the file on disk, libarchive will
  389. return an error for any attempt to read the entry body.</p>
  390. <p style="margin-left:6%; margin-top: 1em"><b>7-Zip</b>
  391. <br>
  392. Libarchive can read and write 7-Zip format archives. TODO:
  393. Need more information</p>
  394. <p style="margin-left:6%; margin-top: 1em"><b>CAB</b> <br>
  395. Libarchive can read Microsoft Cabinet ( &ldquo;CAB&rdquo;)
  396. format archives. TODO: Need more information.</p>
  397. <p style="margin-left:6%; margin-top: 1em"><b>LHA</b> <br>
  398. TODO: Information about libarchive&rsquo;s LHA support</p>
  399. <p style="margin-left:6%; margin-top: 1em"><b>RAR</b> <br>
  400. Libarchive has limited support for reading RAR format
  401. archives. Currently, libarchive can read RARv3 format
  402. archives which have been either created uncompressed, or
  403. compressed using any of the compression methods supported by
  404. the RARv3 format. Libarchive can also read self-extracting
  405. RAR archives.</p>
  406. <p style="margin-left:6%; margin-top: 1em"><b>Warc</b> <br>
  407. Libarchive can read and write &ldquo;web archives&rdquo;.
  408. TODO: Need more information</p>
  409. <p style="margin-left:6%; margin-top: 1em"><b>XAR</b> <br>
  410. Libarchive can read and write the XAR format used by many
  411. Apple tools. TODO: Need more information</p>
  412. <p style="margin-top: 1em"><b>SEE ALSO</b></p>
  413. <p style="margin-left:6%;">ar(1), cpio(1), mkisofs(1),
  414. shar(1), tar(1), zip(1), zlib(3), cpio(5), mtree(5),
  415. tar(5)</p>
  416. <p style="margin-left:6%; margin-top: 1em">BSD
  417. December&nbsp;27, 2016 BSD</p>
  418. <hr>
  419. </body>
  420. </html>