libarchive.3.html 10 KB

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