ManPageLibarchiveFormats5.wiki 19 KB

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