diff --git a/lib/libarchive/Makefile b/lib/libarchive/Makefile index bd6162f8b29e..bdd4a9882732 100644 --- a/lib/libarchive/Makefile +++ b/lib/libarchive/Makefile @@ -140,6 +140,7 @@ MLINKS+= archive_read.3 archive_read_support_compression_gzip.3 MLINKS+= archive_read.3 archive_read_support_compression_none.3 MLINKS+= archive_read.3 archive_read_support_format_all.3 MLINKS+= archive_read.3 archive_read_support_format_cpio.3 +MLINKS+= archive_read.3 archive_read_support_format_iso9660.3 MLINKS+= archive_read.3 archive_read_support_format_tar.3 MLINKS+= archive_util.3 archive_compression.3 MLINKS+= archive_util.3 archive_compression_name.3 diff --git a/lib/libarchive/archive_read.3 b/lib/libarchive/archive_read.3 index c492bf9e6a9b..61c12eed8313 100644 --- a/lib/libarchive/archive_read.3 +++ b/lib/libarchive/archive_read.3 @@ -1,4 +1,4 @@ -.\" Copyright (c) 2003-2004 Tim Kientzle +.\" Copyright (c) 2003-2005 Tim Kientzle .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 1, 2003 +.Dd January 8, 2005 .Dt archive_read 3 .Os .Sh NAME @@ -35,9 +35,10 @@ .Nm archive_read_support_compression_compress , .Nm archive_read_support_compression_gzip , .Nm archive_read_support_compression_none , -.Nm archive_read_support_format_tar , -.Nm archive_read_support_format_cpio , .Nm archive_read_support_format_all , +.Nm archive_read_support_format_cpio , +.Nm archive_read_support_format_iso9660 , +.Nm archive_read_support_format_tar , .Nm archive_read_open , .Nm archive_read_open_fd , .Nm archive_read_open_file , @@ -69,11 +70,13 @@ .Ft int .Fn archive_read_support_compression_none "struct archive *" .Ft int -.Fn archive_read_support_format_tar "struct archive *" +.Fn archive_read_support_format_all "struct archive *" .Ft int .Fn archive_read_support_format_cpio "struct archive *" .Ft int -.Fn archive_read_support_format_all "struct archive *" +.Fn archive_read_support_format_iso9660 "struct archive *" +.Ft int +.Fn archive_read_support_format_tar "struct archive *" .Ft int .Fn archive_read_open "struct archive *" "void *client_data" "archive_open_archive_callback *" "archive_read_archive_callback *" "archive_close_archive_callback *" .Ft int @@ -119,7 +122,7 @@ Sets the block size used for reading the archive data. This controls the size that will be used when invoking the read callback function. The default is 20 records or 10240 bytes for tar formats. -.It Fn archive_read_support_compression_XXX +.It Fn archive_read_support_comression_all , Fn archive_read_support_compression_bzip2 , Fn archive_read_support_compression_compress , Fn archive_read_support_compression_gzip , Fn archive_read_support_compression_none Enables auto-detection code and decompression support for the specified compression. Note that @@ -128,10 +131,10 @@ is always enabled by default. For convenience, .Fn archive_read_support_compression_all enables all available decompression code. -.It Fn archive_read_support_format_XXX +.It Fn archive_read_support_format_all , Fn archive_read_support_format_cpio , Fn archive_read_support_format_iso9660 , Fn archive_read_support_format_tar Enables support---including auto-detection code---for the specified archive format. -In particular, +For example, .Fn archive_read_support_format_tar enables support for a variety of standard tar formats, old-style tar, ustar, pax interchange format, and many common variants. @@ -251,6 +254,13 @@ or compression and transparently performs the appropriate decompression. It also automatically detects the archive format. .Pp +A complete description of the +.Tn struct archive +and +.Tn struct archive_entry +objects can be found in the overview manual page for +.Xr libarchive 3 . +.Sh CLIENT CALLBACKS The callback functions must match the following prototypes: .Bl -item -offset indent .It @@ -263,17 +273,46 @@ The callback functions must match the following prototypes: .Ft typedef int .Fn archive_close_callback "struct archive *" "void *client_data" .El -These callback functions are called whenever the library requires -raw bytes from the archive. -Note that it is the client's responsibility to correctly -block the input. .Pp -A complete description of the -.Tn struct archive -and -.Tn struct archive_entry -objects can be found in the overview manual page for -.Xr libarchive 3 . +The open callback is invoked by +.Fn archive_open . +It should return +.Cm ARCHIVE_OK +if the underlying file or data source is successfully +opened. +If the open fails, it should call +.Fn archive_set_error +to register an error code and message and return +.Cm ARCHIVE_FATAL . +.Pp +The read callback is invoked whenever the library +requires raw bytes from the archive. +The read callback should read data into a buffer, +set the +.Li const void **buffer +argument to point to the available data, and +return a count of the number of bytes available. +The library will invoke the read callback again +only after it has consumed this data. +The library imposes no constraints on the size +of the data blocks returned. +On end-of-file, the read callback should +return zero. +On error, the read callback should invoke +.Fn archive_set_error +to register an error code and message and +return -1. +.Pp +The close callback is invoked by archive_close when +the archive processing is complete. +The callback should return +.Cm ARCHIVE_OK +on success. +On failure, the callback should invoke +.Fn archive_set_error +to register an error code and message and +regurn +.Cm ARCHIVE_FATAL. .Sh EXAMPLE The following illustrates basic usage of the library. In this example, @@ -389,6 +428,7 @@ to be returned.) .Sh SEE ALSO .Xr tar 1 , .Xr archive 3 , +.Xr archive_util 3 , .Xr tar 5 .Sh HISTORY The diff --git a/lib/libarchive/archive_util.3 b/lib/libarchive/archive_util.3 index 4b3788962bb8..84589b8832a5 100644 --- a/lib/libarchive/archive_util.3 +++ b/lib/libarchive/archive_util.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 1, 2003 +.Dd January 8, 2005 .Dt archive_util 3 .Os .Sh NAME @@ -94,12 +94,34 @@ by .Fn archive_errno and .Fn archive_error_string . -This function is sometimes useful within I/O callbacks. +This function should be used within I/O callbacks to set system-specific +error codes and error descriptions. +This function accepts a printf-like format string and arguments. +However, you should be careful to use only the following printf +format specifiers: +.Dq %c , +.Dq %d , +.Dq %jd , +.Dq %jo , +.Dq %ju , +.Dq %jx , +.Dq %ld , +.Dq %lo , +.Dq %lu , +.Dq %lx , +.Dq %o , +.Dq %u , +.Dq %s , +.Dq %x , +.Dq %% . +Field-width specifiers and other printf features are +not uniformly supported and should not be used. .El .Sh SEE ALSO .Xr archive_read 3 , .Xr archive_write 3 , -.Xr libarchive 3 +.Xr libarchive 3 , +.Xr printf 3 .Sh HISTORY The .Nm libarchive diff --git a/lib/libarchive/archive_write.3 b/lib/libarchive/archive_write.3 index 337919b694dd..033e8a557583 100644 --- a/lib/libarchive/archive_write.3 +++ b/lib/libarchive/archive_write.3 @@ -1,4 +1,4 @@ -.\" Copyright (c) 2003-2004 Tim Kientzle +.\" Copyright (c) 2003-2005 Tim Kientzle .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 1, 2003 +.Dd January 8, 2005 .Dt archive_write 3 .Os .Sh NAME @@ -198,30 +198,6 @@ Invokes .Fn archive_write_close if it wasn't invoked manually, then release all resources. .El -.Pp -The callback functions are defined as follows: -.Bl -item -offset indent -.It -.Ft typedef ssize_t -.Fn archive_write_archive_callback "struct archive *" "void *client_data" "void *buffer" "size_t length" -.It -.Ft typedef int -.Fn archive_open_archive_callback "struct archive *" "void *client_data" -.It -.Ft typedef int -.Fn archive_close_archive_callback "struct archive *" "void *client_data" -.El -For correct blocking, each call to the write callback function -should translate into a single -.Xr write 2 -system call. -This is especially critical when writing tar archives to tape drives. -.Pp -More information about tar archive formats and blocking can be found -in the -.Xr tar 5 -manual page. -.Pp More information about the .Va struct archive object and the overall design of the library can be found in the @@ -230,6 +206,62 @@ overview. .Sh IMPLEMENTATION Compression support is built-in to libarchive, which uses zlib and bzlib to handle gzip and bzip2 compression, respectively. +.Sh CLIENT CALLBACKS +To use this library, you will need to define and register +callback functions that will be invoked to write data to the +resulting archive. +These functions are registered by calling +.Fn archive_write_open : +.Bl -item -offset indent +.It +.Ft typedef int +.Fn archive_open_archive_callback "struct archive *" "void *client_data" +.El +.Pp +The open callback is invoked by +.Fn archive_write_open . +It should return +.Cm ARCHIVE_OK +if the underlying file or data source is successfully +opened. +If the open fails, it should call +.Fn archive_set_error +to register an error code and message and return +.Cm ARCHIVE_FATAL . +.Bl -item -offset indent +.It +.Ft typedef ssize_t +.Fn archive_write_archive_callback "struct archive *" "void *client_data" "void *buffer" "size_t length" +.El +.Pp +The write callback is invoked whenever the library +needs to write raw bytes to the archive. +For correct blocking, each call to the write callback function +should translate into a single +.Xr write 2 +system call. +This is especially critical when writing archives to tape drives. +On success, the write callback should return the +number of bytes actually written. +On error, the callback should invoke +.Fn archive_set_error +to register an error code and message and return -1. +.Bl -item -offset indent +.It +.Ft typedef int +.Fn archive_close_archive_callback "struct archive *" "void *client_data" +.El +.Pp +The close callback is invoked by archive_close when +the archive processing is complete. +The callback should return +.Cm ARCHIVE_OK +on success. +On failure, the callback should invoke +.Fn archive_set_error +to register an error code and message and +regurn +.Cm ARCHIVE_FATAL. .Sh EXAMPLE The following sketch illustrates basic usage of the library. In this example, diff --git a/lib/libarchive/libarchive.3 b/lib/libarchive/libarchive.3 index ce99eaeb3bcc..0c04a70110e0 100644 --- a/lib/libarchive/libarchive.3 +++ b/lib/libarchive/libarchive.3 @@ -1,4 +1,4 @@ -.\" Copyright (c) 2003-2004 Tim Kientzle +.\" Copyright (c) 2003-2005 Tim Kientzle .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 1, 2003 +.Dd January 8, 2005 .Dt LIBARCHIVE 3 .Os .Sh NAME @@ -305,8 +305,8 @@ library was written by Some archive formats support information that is not supported by .Tn struct archive_entry . Such information cannot be fully archived or restored using this library. -This includes, for example, comments, character sets, sparse -file information, or the arbitrary key/value pairs that can appear in +This includes, for example, comments, character sets, +or the arbitrary key/value pairs that can appear in pax interchange format archives. .Pp Conversely, of course, not all of the information that can be @@ -315,6 +315,4 @@ stored in an is supported by all formats. For example, cpio formats do not support nanosecond timestamps; old tar formats do not support large device numbers. -.Pp -The library cannot write pre-POSIX tar archives. -The support for GNU tar format is incomplete. +