libarchive.3 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. .TH LIBARCHIVE 3 "March 18, 2012" ""
  2. .SH NAME
  3. .ad l
  4. \fB\%libarchive\fP
  5. \- functions for reading and writing streaming archives
  6. .SH OVERVIEW
  7. .ad l
  8. The
  9. \fB\%libarchive\fP
  10. library provides a flexible interface for reading and writing
  11. archives in various formats such as tar and cpio.
  12. \fB\%libarchive\fP
  13. also supports reading and writing archives compressed using
  14. various compression filters such as gzip and bzip2.
  15. The library is inherently stream-oriented; readers serially iterate through
  16. the archive, writers serially add things to the archive.
  17. In particular, note that there is currently no built-in support for
  18. random access nor for in-place modification.
  19. .PP
  20. When reading an archive, the library automatically detects the
  21. format and the compression.
  22. The library currently has read support for:
  23. .RS 5
  24. .IP \(bu
  25. old-style tar archives,
  26. .IP \(bu
  27. most variants of the POSIX
  28. ``ustar''
  29. format,
  30. .IP \(bu
  31. the POSIX
  32. ``pax interchange''
  33. format,
  34. .IP \(bu
  35. GNU-format tar archives,
  36. .IP \(bu
  37. most common cpio archive formats,
  38. .IP \(bu
  39. 7-Zip archives,
  40. .IP \(bu
  41. ar archives (including GNU/SysV and BSD extensions),
  42. .IP \(bu
  43. Microsoft CAB archives,
  44. .IP \(bu
  45. ISO9660 CD images (including RockRidge and Joliet extensions),
  46. .IP \(bu
  47. LHA archives,
  48. .IP \(bu
  49. mtree file tree descriptions,
  50. .IP \(bu
  51. RAR and most RAR5 archives,
  52. .IP \(bu
  53. WARC archives,
  54. .IP \(bu
  55. XAR archives,
  56. .IP \(bu
  57. Zip archives.
  58. .RE
  59. The library automatically detects archives compressed with
  60. \fBcompress\fP(1),
  61. \fBbzip2\fP(1),
  62. \fBgrzip\fP(1),
  63. \fBgzip\fP(1),
  64. \fBlrzip\fP(1),
  65. \fBlz4\fP(1),
  66. \fBlzip\fP(1),
  67. \fBlzop\fP(1),
  68. \fBxz\fP(1),
  69. or
  70. \fBzstd\fP(1)
  71. and decompresses them transparently. Decompression of some formats
  72. requires external decompressor utilities.
  73. It can similarly detect and decode archives processed with
  74. \fBuuencode\fP(1)
  75. or which have an
  76. \fBrpm\fP(1)
  77. header.
  78. .PP
  79. When writing an archive, you can specify the compression
  80. to be used and the format to use.
  81. The library can write
  82. .RS 5
  83. .IP \(bu
  84. POSIX-standard
  85. ``ustar''
  86. archives,
  87. .IP \(bu
  88. POSIX
  89. ``pax interchange format''
  90. archives,
  91. .IP \(bu
  92. cpio archives,
  93. .IP \(bu
  94. 7-Zip archives,
  95. .IP \(bu
  96. ar archives,
  97. .IP \(bu
  98. two different variants of shar archives,
  99. .IP \(bu
  100. ISO9660 CD images,
  101. .IP \(bu
  102. mtree file tree descriptions,
  103. .IP \(bu
  104. XAR archives,
  105. .IP \(bu
  106. Zip archive.
  107. .RE
  108. Pax interchange format is an extension of the tar archive format that
  109. eliminates essentially all of the limitations of historic tar formats
  110. in a standard fashion that is supported
  111. by POSIX-compliant
  112. \fBpax\fP(1)
  113. implementations on many systems as well as several newer implementations of
  114. \fBtar\fP(1).
  115. Note that the default write format will suppress the pax extended
  116. attributes for most entries; explicitly requesting pax format will
  117. enable those attributes for all entries.
  118. .PP
  119. The read and write APIs are accessed through the
  120. \fB\%archive_read_XXX\fP()
  121. functions and the
  122. \fB\%archive_write_XXX\fP()
  123. functions, respectively, and either can be used independently
  124. of the other.
  125. .PP
  126. The rest of this manual page provides an overview of the library
  127. operation.
  128. More detailed information can be found in the individual manual
  129. pages for each API or utility function.
  130. .SH READING AN ARCHIVE
  131. .ad l
  132. See
  133. \fBarchive_read\fP(3).
  134. .SH WRITING AN ARCHIVE
  135. .ad l
  136. See
  137. \fBarchive_write\fP(3).
  138. .SH WRITING ENTRIES TO DISK
  139. .ad l
  140. The
  141. \fBarchive_write_disk\fP(3)
  142. API allows you to write
  143. \fBarchive_entry\fP(3)
  144. objects to disk using the same API used by
  145. \fBarchive_write\fP(3).
  146. The
  147. \fBarchive_write_disk\fP(3)
  148. API is used internally by
  149. \fB\%archive_read_extract\fP(\fI\%;\fP)
  150. using it directly can provide greater control over how entries
  151. get written to disk.
  152. This API also makes it possible to share code between
  153. archive-to-archive copy and archive-to-disk extraction
  154. operations.
  155. .SH READING ENTRIES FROM DISK
  156. .ad l
  157. The
  158. \fBarchive_read_disk\fP(3)
  159. supports for populating
  160. \fBarchive_entry\fP(3)
  161. objects from information in the filesystem.
  162. This includes the information accessible from the
  163. \fBstat\fP(2)
  164. system call as well as ACLs, extended attributes,
  165. and other metadata.
  166. The
  167. \fBarchive_read_disk\fP(3)
  168. API also supports iterating over directory trees,
  169. which allows directories of files to be read using
  170. an API compatible with
  171. the
  172. \fBarchive_read\fP(3)
  173. API.
  174. .SH DESCRIPTION
  175. .ad l
  176. Detailed descriptions of each function are provided by the
  177. corresponding manual pages.
  178. .PP
  179. All of the functions utilize an opaque
  180. Tn struct archive
  181. datatype that provides access to the archive contents.
  182. .PP
  183. The
  184. Tn struct archive_entry
  185. structure contains a complete description of a single archive
  186. entry.
  187. It uses an opaque interface that is fully documented in
  188. \fBarchive_entry\fP(3).
  189. .PP
  190. Users familiar with historic formats should be aware that the newer
  191. variants have eliminated most restrictions on the length of textual fields.
  192. Clients should not assume that filenames, link names, user names, or
  193. group names are limited in length.
  194. In particular, pax interchange format can easily accommodate pathnames
  195. in arbitrary character sets that exceed
  196. \fIPATH_MAX\fP.
  197. .SH RETURN VALUES
  198. .ad l
  199. Most functions return
  200. \fBARCHIVE_OK\fP
  201. (zero) on success, non-zero on error.
  202. The return value indicates the general severity of the error, ranging
  203. from
  204. \fBARCHIVE_WARN\fP,
  205. which indicates a minor problem that should probably be reported
  206. to the user, to
  207. \fBARCHIVE_FATAL\fP,
  208. which indicates a serious problem that will prevent any further
  209. operations on this archive.
  210. On error, the
  211. \fB\%archive_errno\fP()
  212. function can be used to retrieve a numeric error code (see
  213. \fBerrno\fP(2)).
  214. The
  215. \fB\%archive_error_string\fP()
  216. returns a textual error message suitable for display.
  217. .PP
  218. \fB\%archive_read_new\fP()
  219. and
  220. \fB\%archive_write_new\fP()
  221. return pointers to an allocated and initialized
  222. Tn struct archive
  223. object.
  224. .PP
  225. \fB\%archive_read_data\fP()
  226. and
  227. \fB\%archive_write_data\fP()
  228. return a count of the number of bytes actually read or written.
  229. A value of zero indicates the end of the data for this entry.
  230. A negative value indicates an error, in which case the
  231. \fB\%archive_errno\fP()
  232. and
  233. \fB\%archive_error_string\fP()
  234. functions can be used to obtain more information.
  235. .SH ENVIRONMENT
  236. .ad l
  237. There are character set conversions within the
  238. \fBarchive_entry\fP(3)
  239. functions that are impacted by the currently-selected locale.
  240. .SH SEE ALSO
  241. .ad l
  242. \fBtar\fP(1),
  243. \fBarchive_entry\fP(3),
  244. \fBarchive_read\fP(3),
  245. \fBarchive_util\fP(3),
  246. \fBarchive_write\fP(3),
  247. \fBtar\fP(5)
  248. .SH HISTORY
  249. .ad l
  250. The
  251. \fB\%libarchive\fP
  252. library first appeared in
  253. FreeBSD 5.3.
  254. .SH AUTHORS
  255. .ad l
  256. -nosplit
  257. The
  258. \fB\%libarchive\fP
  259. library was originally written by
  260. Tim Kientzle \%<[email protected].>
  261. .SH BUGS
  262. .ad l
  263. Some archive formats support information that is not supported by
  264. Tn struct archive_entry.
  265. Such information cannot be fully archived or restored using this library.
  266. This includes, for example, comments, character sets,
  267. or the arbitrary key/value pairs that can appear in
  268. pax interchange format archives.
  269. .PP
  270. Conversely, of course, not all of the information that can be
  271. stored in an
  272. Tn struct archive_entry
  273. is supported by all formats.
  274. For example, cpio formats do not support nanosecond timestamps;
  275. old tar formats do not support large device numbers.
  276. .PP
  277. The ISO9660 reader cannot yet read all ISO9660 images;
  278. it should learn how to seek.
  279. .PP
  280. The AR writer requires the client program to use
  281. two passes, unlike all other libarchive writers.