libarchive-formats.5 17 KB

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