1 <!-- Creator : groff version 1.22.3 -->
2 <!-- CreationDate: Sun Feb 19 09:11:16 2017 -->
3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
4 "http://www.w3.org/TR/html4/loose.dtd">
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 }
23 <p>ARCHIVE_READ_DISK(3) BSD Library Functions Manual
24 ARCHIVE_READ_DISK(3)</p>
26 <p style="margin-top: 1em"><b>NAME</b></p>
28 <p style="margin-left:6%;"><b>archive_read_disk_new</b>,
29 <b>archive_read_disk_set_symlink_logical</b>,
30 <b>archive_read_disk_set_symlink_physical</b>,
31 <b>archive_read_disk_set_symlink_hybrid</b>,
32 <b>archive_read_disk_entry_from_file</b>,
33 <b>archive_read_disk_gname</b>,
34 <b>archive_read_disk_uname</b>,
35 <b>archive_read_disk_set_uname_lookup</b>,
36 <b>archive_read_disk_set_gname_lookup</b>,
37 <b>archive_read_disk_set_standard_lookup</b>,
38 <b>archive_read_close</b>, <b>archive_read_finish</b>,
39 <b>archive_read_free</b> — functions for reading
42 <p style="margin-top: 1em"><b>LIBRARY</b></p>
44 <p style="margin-left:6%;">Streaming Archive Library
45 (libarchive, -larchive)</p>
47 <p style="margin-top: 1em"><b>SYNOPSIS</b></p>
49 <p style="margin-left:6%;"><b>#include
50 <archive.h></b></p>
52 <p style="margin-left:6%; margin-top: 1em"><i>struct
56 <p style="margin-left:12%;"><b>archive_read_disk_new</b>(<i>void</i>);</p>
58 <p style="margin-left:6%; margin-top: 1em"><i>int</i></p>
61 <p style="margin-left:12%;"><b>archive_read_disk_set_symlink_logical</b>(<i>struct archive *</i>);</p>
63 <p style="margin-left:6%; margin-top: 1em"><i>int</i></p>
66 <p style="margin-left:12%;"><b>archive_read_disk_set_symlink_physical</b>(<i>struct archive *</i>);</p>
68 <p style="margin-left:6%; margin-top: 1em"><i>int</i></p>
71 <p style="margin-left:12%;"><b>archive_read_disk_set_symlink_hybrid</b>(<i>struct archive *</i>);</p>
73 <p style="margin-left:6%; margin-top: 1em"><i>const char
77 <p style="margin-left:12%;"><b>archive_read_disk_gname</b>(<i>struct archive *</i>,
80 <p style="margin-left:6%; margin-top: 1em"><i>const char
84 <p style="margin-left:12%;"><b>archive_read_disk_uname</b>(<i>struct archive *</i>,
87 <p style="margin-left:6%; margin-top: 1em"><i>int</i></p>
90 <p><b>archive_read_disk_set_gname_lookup</b>(<i>struct archive *</i>,
92 <i>const char *(*lookup)(void *, gid_t)</i>,
93 <i>void (*cleanup)(void *)</i>);</p>
95 <p style="margin-left:6%; margin-top: 1em"><i>int</i></p>
98 <p><b>archive_read_disk_set_uname_lookup</b>(<i>struct archive *</i>,
100 <i>const char *(*lookup)(void *, uid_t)</i>,
101 <i>void (*cleanup)(void *)</i>);</p>
103 <p style="margin-left:6%; margin-top: 1em"><i>int</i></p>
106 <p style="margin-left:12%;"><b>archive_read_disk_set_standard_lookup</b>(<i>struct archive *</i>);</p>
108 <p style="margin-left:6%; margin-top: 1em"><i>int</i></p>
111 <p><b>archive_read_disk_entry_from_file</b>(<i>struct archive *</i>,
112 <i>struct archive_entry *</i>, <i>int fd</i>,
113 <i>const struct stat *</i>);</p>
115 <p style="margin-left:6%; margin-top: 1em"><i>int</i></p>
118 <p style="margin-left:12%;"><b>archive_read_close</b>(<i>struct archive *</i>);</p>
120 <p style="margin-left:6%; margin-top: 1em"><i>int</i></p>
123 <p style="margin-left:12%;"><b>archive_read_finish</b>(<i>struct archive *</i>);</p>
125 <p style="margin-left:6%; margin-top: 1em"><i>int</i></p>
128 <p style="margin-left:12%;"><b>archive_read_free</b>(<i>struct archive *</i>);</p>
130 <p style="margin-top: 1em"><b>DESCRIPTION</b></p>
132 <p style="margin-left:6%;">These functions provide an API
133 for reading information about objects on disk. In
134 particular, they provide an interface for populating struct
135 archive_entry objects.</p>
138 <p style="margin-top: 1em"><b>archive_read_disk_new</b>()</p>
140 <p style="margin-left:17%;">Allocates and initializes a
141 struct archive object suitable for reading object
142 information from disk.</p>
145 <p style="margin-top: 1em"><b>archive_read_disk_set_symlink_logical</b>(),
146 <b>archive_read_disk_set_symlink_physical</b>(),
147 <b>archive_read_disk_set_symlink_hybrid</b>()</p>
149 <p style="margin-left:17%;">This sets the mode used for
150 handling symbolic links. The
151 ’’logical’’ mode follows all
152 symbolic links. The ’’physical’’
153 mode does not follow any symbolic links. The
154 ’’hybrid’’ mode currently behaves
155 identically to the ’’logical’’
159 <p style="margin-top: 1em"><b>archive_read_disk_gname</b>(),
160 <b>archive_read_disk_uname</b>()</p>
162 <p style="margin-left:17%;">Returns a user or group name
163 given a gid or uid value. By default, these always return a
167 <p style="margin-top: 1em"><b>archive_read_disk_set_gname_lookup</b>(),
168 <b>archive_read_disk_set_uname_lookup</b>()</p>
170 <p style="margin-left:17%;">These allow you to override the
171 functions used for user and group name lookups. You may also
172 provide a void * pointer to a private data structure and a
173 cleanup function for that data. The cleanup function will be
174 invoked when the struct archive object is destroyed or when
175 new lookup functions are registered.</p>
178 <p style="margin-top: 1em"><b>archive_read_disk_set_standard_lookup</b>()</p>
180 <p style="margin-left:17%;">This convenience function
181 installs a standard set of user and group name lookup
182 functions. These functions use getpwuid(3) and getgrgid(3)
183 to convert ids to names, defaulting to NULL if the names
184 cannot be looked up. These functions also implement a simple
185 memory cache to reduce the number of calls to getpwuid(3)
189 <p style="margin-top: 1em"><b>archive_read_disk_entry_from_file</b>()</p>
191 <p style="margin-left:17%;">Populates a struct
192 archive_entry object with information about a particular
193 file. The archive_entry object must have already been
194 created with archive_entry_new(3) and at least one of the
195 source path or path fields must already be set. (If both are
196 set, the source path will be used.)</p>
198 <p style="margin-left:17%; margin-top: 1em">Information is
199 read from disk using the path name from the struct
200 archive_entry object. If a file descriptor is provided, some
201 information will be obtained using that file descriptor, on
202 platforms that support the appropriate system calls.</p>
204 <p style="margin-left:17%; margin-top: 1em">If a pointer to
205 a struct stat is provided, information from that structure
206 will be used instead of reading from the disk where
207 appropriate. This can provide performance benefits in
208 scenarios where struct stat information has already been
209 read from the disk as a side effect of some other operation.
210 (For example, directory traversal libraries often provide
211 this information.)</p>
213 <p style="margin-left:17%; margin-top: 1em">Where
214 necessary, user and group ids are converted to user and
215 group names using the currently registered lookup functions
216 above. This affects the file ownership fields and ACL values
217 in the struct archive_entry object.</p>
219 <p style="margin-top: 1em"><b>archive_read_close</b>()</p>
221 <p style="margin-left:17%;">Does nothing for
222 archive_read_disk handles.</p>
225 <p style="margin-top: 1em"><b>archive_read_finish</b>()</p>
227 <p style="margin-left:17%;">This is a deprecated synonym
228 for <b>archive_read_free</b>().</p>
230 <p style="margin-top: 1em"><b>archive_read_free</b>()</p>
232 <p style="margin-left:17%;">Invokes
233 <b>archive_read_close</b>() if it was not invoked manually,
234 then releases all resources.</p>
236 <p style="margin-left:6%;">More information about the
237 <i>struct archive</i> object and the overall design of the
238 library can be found in the libarchive(3) overview.</p>
240 <p style="margin-top: 1em"><b>EXAMPLE</b></p>
242 <p style="margin-left:6%;">The following illustrates basic
243 usage of the library by showing how to use it to copy an
244 item on disk into an archive.</p>
246 <p style="margin-left:14%; margin-top: 1em">void <br>
247 file_to_archive(struct archive *a, const char *name) <br>
249 char buff[8192]; <br>
250 size_t bytes_read; <br>
251 struct archive *ard; <br>
252 struct archive_entry *entry; <br>
255 <p style="margin-left:14%; margin-top: 1em">ard =
256 archive_read_disk_new(); <br>
257 archive_read_disk_set_standard_lookup(ard); <br>
258 entry = archive_entry_new(); <br>
259 fd = open(name, O_RDONLY); <br>
262 archive_entry_copy_pathname(entry, name); <br>
263 archive_read_disk_entry_from_file(ard, entry, fd, NULL);
265 archive_write_header(a, entry); <br>
266 while ((bytes_read = read(fd, buff, sizeof(buff))) > 0)
268 archive_write_data(a, buff, bytes_read); <br>
269 archive_write_finish_entry(a); <br>
270 archive_read_free(ard); <br>
271 archive_entry_free(entry); <br>
274 <p style="margin-top: 1em"><b>RETURN VALUES</b></p>
276 <p style="margin-left:6%;">Most functions return
277 <b>ARCHIVE_OK</b> (zero) on success, or one of several
278 negative error codes for errors. Specific error codes
279 include: <b>ARCHIVE_RETRY</b> for operations that might
280 succeed if retried, <b>ARCHIVE_WARN</b> for unusual
281 conditions that do not prevent further operations, and
282 <b>ARCHIVE_FATAL</b> for serious errors that make remaining
283 operations impossible.</p>
286 <p style="margin-left:6%; margin-top: 1em"><b>archive_read_disk_new</b>()
287 returns a pointer to a newly-allocated struct archive object
288 or NULL if the allocation failed for any reason.</p>
291 <p style="margin-left:6%; margin-top: 1em"><b>archive_read_disk_gname</b>()
292 and <b>archive_read_disk_uname</b>() return const char *
293 pointers to the textual name or NULL if the lookup failed
294 for any reason. The returned pointer points to internal
295 storage that may be reused on the next call to either of
296 these functions; callers should copy the string if they need
297 to continue accessing it.</p>
299 <p style="margin-top: 1em"><b>ERRORS</b></p>
301 <p style="margin-left:6%;">Detailed error codes and textual
302 descriptions are available from the <b>archive_errno</b>()
303 and <b>archive_error_string</b>() functions.</p>
305 <p style="margin-top: 1em"><b>SEE ALSO</b></p>
307 <p style="margin-left:6%;">archive_read(3),
308 archive_util(3), archive_write(3), archive_write_disk(3),
309 tar(1), libarchive(3)</p>
311 <p style="margin-top: 1em"><b>HISTORY</b></p>
313 <p style="margin-left:6%;">The <b>libarchive</b> library
314 first appeared in FreeBSD 5.3. The
315 <b>archive_read_disk</b> interface was added to
316 <b>libarchive 2.6</b> and first appeared in
317 FreeBSD 8.0.</p>
319 <p style="margin-top: 1em"><b>AUTHORS</b></p>
321 <p style="margin-left:6%;">The <b>libarchive</b> library
322 was written by Tim Kientzle
323 <kientzle@FreeBSD.org>.</p>
325 <p style="margin-top: 1em"><b>BUGS</b></p>
327 <p style="margin-left:6%;">The
328 ’’standard’’ user name and group
329 name lookup functions are not the defaults because
330 getgrgid(3) and getpwuid(3) are sometimes too large for
331 particular applications. The current design allows the
332 application author to use a more compact implementation when
335 <p style="margin-left:6%; margin-top: 1em">The full list of
336 metadata read from disk by
337 <b>archive_read_disk_entry_from_file</b>() is necessarily
338 system-dependent.</p>
340 <p style="margin-left:6%; margin-top: 1em">The
341 <b>archive_read_disk_entry_from_file</b>() function reads as
342 much information as it can from disk. Some method should be
343 provided to limit this so that clients who do not need ACLs,
344 for instance, can avoid the extra work needed to look up
345 such information.</p>
347 <p style="margin-left:6%; margin-top: 1em">This API should
348 provide a set of methods for walking a directory tree. That
349 would make it a direct parallel of the archive_read(3) API.
350 When such methods are implemented, the
351 ’’hybrid’’ symbolic link mode will
354 <p style="margin-left:6%; margin-top: 1em">BSD
355 December 30, 2016 BSD</p>