1.\" Copyright (c) 2003-2010 Tim Kientzle
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd January 31, 2020
28.Dt ARCHIVE_WRITE_OPTIONS 3
29.Os
30.Sh NAME
31.Nm archive_write_set_filter_option ,
32.Nm archive_write_set_format_option ,
33.Nm archive_write_set_option ,
34.Nm archive_write_set_options
35.Nd functions controlling options for writing archives
36.Sh LIBRARY
37Streaming Archive Library (libarchive, -larchive)
38.Sh SYNOPSIS
39.In archive.h
40.Ft int
41.Fo archive_write_set_filter_option
42.Fa "struct archive *"
43.Fa "const char *module"
44.Fa "const char *option"
45.Fa "const char *value"
46.Fc
47.Ft int
48.Fo archive_write_set_format_option
49.Fa "struct archive *"
50.Fa "const char *module"
51.Fa "const char *option"
52.Fa "const char *value"
53.Fc
54.Ft int
55.Fo archive_write_set_option
56.Fa "struct archive *"
57.Fa "const char *module"
58.Fa "const char *option"
59.Fa "const char *value"
60.Fc
61.Ft int
62.Fo archive_write_set_options
63.Fa "struct archive *"
64.Fa "const char *options"
65.Fc
66.Sh DESCRIPTION
67These functions provide a way for libarchive clients to configure
68specific write modules.
69.Bl -tag -width indent
70.It Xo
71.Fn archive_write_set_filter_option ,
72.Fn archive_write_set_format_option
73.Xc
74Specifies an option that will be passed to the currently-registered
75filters (including decompression filters) or format readers.
76.Pp
77If
78.Ar option
79and
80.Ar value
81are both
82.Dv NULL ,
83these functions will do nothing and
84.Cm ARCHIVE_OK
85will be returned.
86If
87.Ar option
88is
89.Dv NULL
90but
91.Ar value
92is not, these functions will do nothing and
93.Cm ARCHIVE_FAILED
94will be returned.
95.Pp
96If
97.Ar module
98is not
99.Dv NULL ,
100.Ar option
101and
102.Ar value
103will be provided to the filter or reader named
104.Ar module .
105The return value will be either
106.Cm ARCHIVE_OK
107if the option was successfully handled or
108.Cm ARCHIVE_WARN
109if the option was unrecognized by the module or could otherwise
110not be handled.
111If there is no such module,
112.Cm ARCHIVE_FAILED
113will be returned.
114.Pp
115If
116.Ar module
117is
118.Dv NULL ,
119.Ar option
120and
121.Ar value
122will be provided to every registered module.
123If any module returns
124.Cm ARCHIVE_FATAL ,
125this value will be returned immediately.
126Otherwise,
127.Cm ARCHIVE_OK
128will be returned if any module accepts the option, and
129.Cm ARCHIVE_FAILED
130in all other cases.
131.\"
132.It Fn archive_write_set_option
133Calls
134.Fn archive_write_set_format_option ,
135then
136.Fn archive_write_set_filter_option .
137If either function returns
138.Cm ARCHIVE_FATAL ,
139.Cm ARCHIVE_FATAL
140will be returned
141immediately.
142Otherwise, the greater of the two values will be returned.
143.\"
144.It Fn archive_write_set_options
145.Ar options
146is a comma-separated list of options.
147If
148.Ar options
149is
150.Dv NULL
151or empty,
152.Cm ARCHIVE_OK
153will be returned immediately.
154.Pp
155Individual options have one of the following forms:
156.Bl -tag -compact -width indent
157.It Ar option=value
158The option/value pair will be provided to every module.
159Modules that do not accept an option with this name will ignore it.
160.It Ar option
161The option will be provided to every module with a value of
162.Dq 1 .
163.It Ar !option
164The option will be provided to every module with a NULL value.
165.It Ar module:option=value , Ar module:option , Ar module:!option
166As above, but the corresponding option and value will be provided
167only to modules whose name matches
168.Ar module .
169.El
170.El
171.\"
172.Sh OPTIONS
173.Bl -tag -compact -width indent
174.It Filter b64encode
175.Bl -tag -compact -width indent
176.It Cm mode
177The value is interpreted as octal digits specifying the file mode.
178.It Cm name
179The value specifies the file name.
180.El
181.It Filter bzip2
182.Bl -tag -compact -width indent
183.It Cm compression-level
184The value is interpreted as a decimal integer specifying the
185bzip2 compression level. Supported values are from 1 to 9.
186.El
187.It Filter gzip
188.Bl -tag -compact -width indent
189.It Cm compression-level
190The value is interpreted as a decimal integer specifying the
191gzip compression level. Supported values are from 0 to 9.
192.It Cm timestamp
193Store timestamp. This is enabled by default.
194.El
195.It Filter lrzip
196.Bl -tag -compact -width indent
197.It Cm compression Ns = Ns Ar type
198Use
199.Ar type
200as compression method.
201Supported values are
202.Dq bzip2 ,
203.Dq gzipi ,
204.Dq lzo
205.Pq ultra fast ,
206and
207.Dq zpaq
208.Pq best, extremely slow .
209.It Cm compression-level
210The value is interpreted as a decimal integer specifying the
211lrzip compression level. Supported values are from 1 to 9.
212.El
213.It Filter lz4
214.Bl -tag -compact -width indent
215.It Cm compression-level
216The value is interpreted as a decimal integer specifying the
217lz4 compression level. Supported values are from 0 to 9.
218.It Cm stream-checksum
219Enable stream checksum. This is enabled by default.
220.It Cm block-checksum
221Enable block checksum. This is disabled by default.
222.It Cm block-size
223The value is interpreted as a decimal integer specifying the
224lz4 compression block size. Supported values are from 4 to 7
225.Pq default .
226.It Cm block-dependence
227Use the previous block of the block being compressed for
228a compression dictionary to improve compression ratio.
229This is disabled by default.
230.El
231.It Filter lzop
232.Bl -tag -compact -width indent
233.It Cm compression-level
234The value is interpreted as a decimal integer specifying the
235lzop compression level. Supported values are from 1 to 9.
236.El
237.It Filter uuencode
238.Bl -tag -compact -width indent
239.It Cm mode
240The value is interpreted as octal digits specifying the file mode.
241.It Cm name
242The value specifies the file name.
243.El
244.It Filter xz
245.Bl -tag -compact -width indent
246.It Cm compression-level
247The value is interpreted as a decimal integer specifying the
248compression level. Supported values are from 0 to 9.
249.It Cm threads
250The value is interpreted as a decimal integer specifying the
251number of threads for multi-threaded lzma compression.
252If supported, the default value is read from
253.Fn lzma_cputhreads .
254.El
255.It Filter zstd
256.Bl -tag -compact -width indent
257.It Cm compression-level
258The value is interpreted as a decimal integer specifying the
259compression level. Supported values depend on the library version,
260common values are from 1 to 22.
261.El
262.It Format 7zip
263.Bl -tag -compact -width indent
264.It Cm compression
265The value is one of
266.Dq store ,
267.Dq deflate ,
268.Dq bzip2 ,
269.Dq lzma1 ,
270.Dq lzma2
271or
272.Dq ppmd
273to indicate how the following entries should be compressed.
274Note that this setting is ignored for directories, symbolic links,
275and other special entries.
276.It Cm compression-level
277The value is interpreted as a decimal integer specifying the
278compression level.
279Values between 0 and 9 are supported.
280The interpretation of the compression level depends on the chosen
281compression method.
282.El
283.It Format bin
284.Bl -tag -compact -width indent
285.It Cm hdrcharset
286The value is used as a character set name that will be
287used when translating file names.
288.El
289.It Format gnutar
290.Bl -tag -compact -width indent
291.It Cm hdrcharset
292The value is used as a character set name that will be
293used when translating file, group and user names.
294.El
295.It Format iso9660 - volume metadata
296These options are used to set standard ISO9660 metadata.
297.Bl -tag -compact -width indent
298.It Cm abstract-file Ns = Ns Ar filename
299The file with the specified name will be identified in the ISO9660 metadata
300as holding the abstract for this volume.
301Default: none.
302.It Cm application-id Ns = Ns Ar filename
303The file with the specified name will be identified in the ISO9660 metadata
304as holding the application identifier for this volume.
305Default: none.
306.It Cm biblio-file Ns = Ns Ar filename
307The file with the specified name will be identified in the ISO9660 metadata
308as holding the bibliography for this volume.
309Default: none.
310.It Cm copyright-file Ns = Ns Ar filename
311The file with the specified name will be identified in the ISO9660 metadata
312as holding the copyright for this volume.
313Default: none.
314.It Cm publisher Ns = Ns Ar filename
315The file with the specified name will be identified in the ISO9660 metadata
316as holding the publisher information for this volume.
317Default: none.
318.It Cm volume-id Ns = Ns Ar string
319The specified string will be used as the Volume Identifier in the ISO9660 metadata.
320It is limited to 32 bytes.
321Default: none.
322.El
323.It Format iso9660 - boot support
324These options are used to make an ISO9660 image that can be directly
325booted on various systems.
326.Bl -tag -compact -width indent
327.It Cm boot Ns = Ns Ar filename
328The file matching this name will be used as the El Torito boot image file.
329.It Cm boot-catalog Ns = Ns Ar name
330The name that will be used for the El Torito boot catalog.
331Default:
332.Ar boot.catalog
333.It Cm boot-info-table
334The boot image file provided by the
335.Cm boot Ns = Ns Ar filename
336option will be edited with appropriate boot information in bytes 8 through 64.
337Default: disabled
338.It Cm boot-load-seg Ns = Ns Ar hexadecimal-number
339The load segment for a no-emulation boot image.
340.It Cm boot-load-size Ns = Ns Ar decimal-number
341The number of "virtual" 512-byte sectors to be loaded from a no-emulation boot image.
342Some very old BIOSes can only load very small images, setting this
343value to 4 will often allow such BIOSes to load the first part of
344the boot image (which will then need to be intelligent enough to
345load the rest of itself).
346This should not be needed unless you are trying to support systems with very old BIOSes.
347This defaults to the full size of the image.
348.It Cm boot-type Ns = Ns Ar value
349Specifies the boot semantics used by the El Torito boot image:
350If the
351.Ar value
352is
353.Cm fd ,
354then the boot image is assumed to be a bootable floppy image.
355If the
356.Ar value
357is
358.Cm hd ,
359then the boot image is assumed to be a bootable hard disk image.
360If the
361.Ar value
362is
363.Cm no-emulation ,
364the boot image is used without floppy or hard disk emulation.
365If the boot image is exactly 1.2MB, 1.44MB, or 2.88MB, then
366the default is
367.Cm fd ,
368otherwise the default is
369.Cm no-emulation .
370.El
371.It Format iso9660 - filename and size extensions
372Various extensions to the base ISO9660 format.
373.Bl -tag -compact -width indent
374.It Cm allow-ldots
375If enabled, allows filenames to begin with a leading period.
376If disabled, filenames that begin with a leading period will have
377that period replaced by an underscore character in the standard ISO9660
378namespace.
379This does not impact names stored in the Rockridge or Joliet extension area.
380Default: disabled.
381.It Cm allow-lowercase
382If enabled, allows filenames to contain lowercase characters.
383If disabled, filenames will be forced to uppercase.
384This does not impact names stored in the Rockridge or Joliet extension area.
385Default: disabled.
386.It Cm allow-multidot
387If enabled, allows filenames to contain multiple period characters, in violation of the ISO9660 specification.
388If disabled, additional periods will be converted to underscore characters.
389This does not impact names stored in the Rockridge or Joliet extension area.
390Default: disabled.
391.It Cm allow-period
392If enabled, allows filenames to contain trailing period characters, in violation of the ISO9660 specification.
393If disabled, trailing periods will be converted to underscore characters.
394This does not impact names stored in the Rockridge or Joliet extension area.
395Default: disabled.
396.It Cm allow-pvd-lowercase
397If enabled, the Primary Volume Descriptor may contain lowercase ASCII characters, in violation of the ISO9660 specification.
398If disabled, characters will be converted to uppercase ASCII.
399Default: disabled.
400.It Cm allow-sharp-tilde
401If enabled, sharp and tilde characters will be permitted in filenames, in violation if the ISO9660 specification.
402If disabled, such characters will be converted to underscore characters.
403Default: disabled.
404.It Cm allow-vernum
405If enabled, version numbers will be included with files.
406If disabled, version numbers will be suppressed, in violation of the ISO9660 standard.
407This does not impact names stored in the Rockridge or Joliet extension area.
408Default: enabled.
409.It Cm iso-level
410This enables support for file size and file name extensions in the
411core ISO9660 area.
412The name extensions specified here do not affect the names stored in the Rockridge or Joliet extension areas.
413.Bl -tag -compact -width indent
414.It Cm iso-level=1
415The most compliant form of ISO9660 image.
416Filenames are limited to 8.3 uppercase format,
417directory names are limited to 8 uppercase characters,
418files are limited to 4 GiB,
419the complete ISO9660 image cannot exceed 4 GiB.
420.It Cm iso-level=2
421Filenames are limited to 30 uppercase characters with a 30-character extension,
422directory names are limited to 30 characters,
423files are limited to 4 GiB.
424.It Cm iso-level=3
425As with
426.Cm iso-level=2 ,
427except that files may exceed 4 GiB.
428.It Cm iso-level=4
429As with
430.Cm iso-level=3 ,
431except that filenames may be up to 193 characters
432and may include arbitrary 8-bit characters.
433.El
434.It Cm joliet
435Microsoft's Joliet extensions store a completely separate set of directory information about each file.
436In particular, this information includes Unicode filenames of up to 255 characters.
437Default: enabled.
438.It Cm limit-depth
439If enabled, libarchive will use directory relocation records to ensure that
440no pathname exceeds the ISO9660 limit of 8 directory levels.
441If disabled, no relocation will occur.
442Default: enabled.
443.It Cm limit-dirs
444If enabled, libarchive will cause an error if there are more than
44565536 directories.
446If disabled, there is no limit on the number of directories.
447Default: enabled
448.It Cm pad
449If enabled, 300 kiB of zero bytes will be appended to the end of the archive.
450Default: enabled
451.It Cm relaxed-filenames
452If enabled, all 7-bit ASCII characters are permitted in filenames
453(except lowercase characters unless
454.Cm allow-lowercase
455is also specified).
456This violates ISO9660 standards.
457This does not impact names stored in the Rockridge or Joliet extension area.
458Default: disabled.
459.It Cm rockridge
460The Rockridge extensions store an additional set of POSIX-style file
461information with each file, including mtime, atime, ctime, permissions,
462and long filenames with arbitrary 8-bit characters.
463These extensions also support symbolic links and other POSIX file types.
464Default: enabled.
465.El
466.It Format iso9660 - zisofs support
467The zisofs extensions permit each file to be independently compressed
468using a gzip-compatible compression.
469This can provide significant size savings, but requires the reading
470system to have support for these extensions.
471These extensions are disabled by default.
472.Bl -tag -compact -width indent
473.It Cm compression-level Ns = Ns number
474The compression level used by the deflate compressor.
475Ranges from 0 (least effort) to 9 (most effort).
476Default: 6
477.It Cm zisofs
478Synonym for
479.Cm zisofs=direct .
480.It Cm zisofs=direct
481Compress each file in the archive.
482Unlike
483.Cm zisofs=indirect ,
484this is handled entirely within libarchive and does not require a
485separate utility.
486For best results, libarchive tests each file and will store
487the file uncompressed if the compression does not actually save any space.
488In particular, files under 2k will never be compressed.
489Note that boot image files are never compressed.
490.It Cm zisofs=indirect
491Recognizes files that have already been compressed with the
492.Cm mkzftree
493utility and sets up the necessary file metadata so that
494readers will correctly identify these as zisofs-compressed files.
495.It Cm zisofs-exclude Ns = Ns Ar filename
496Specifies a filename that should not be compressed when using
497.Cm zisofs=direct .
498This option can be provided multiple times to suppress compression
499on many files.
500.El
501.It Format mtree
502.Bl -tag -compact -width indent
503.It Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent , Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 , Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname
504Enable a particular keyword in the mtree output.
505Prefix with an exclamation mark to disable the corresponding keyword.
506The default is equivalent to
507.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname .
508.It Cm all
509Enables all of the above keywords.
510.It Cm use-set
511Enables generation of
512.Cm /set
513lines that specify default values for the following files and/or directories.
514.It Cm indent
515XXX needs explanation XXX
516.El
517.It Format newc
518.Bl -tag -compact -width indent
519.It Cm hdrcharset
520The value is used as a character set name that will be
521used when translating file names.
522.El
523.It Format odc
524.Bl -tag -compact -width indent
525.It Cm hdrcharset
526The value is used as a character set name that will be
527used when translating file names.
528.El
529.It Format pwb
530.Bl -tag -compact -width indent
531.It Cm hdrcharset
532The value is used as a character set name that will be
533used when translating file names.
534.El
535.It Format pax
536.Bl -tag -compact -width indent
537.It Cm hdrcharset
538The value is used as a character set name that will be
539used when translating file, group and user names.
540The value is one of
541.Dq BINARY
542or
543.Dq UTF-8 .
544With
545.Dq BINARY
546there is no character conversion, with
547.Dq UTF-8
548names are converted to UTF-8.
549.It Cm xattrheader
550When storing extended attributes, this option configures which
551headers should be written. The value is one of
552.Dq all ,
553.Dq LIBARCHIVE ,
554or
555.Dq SCHILY .
556By default, both
557.Dq LIBARCHIVE.xattr
558and
559.Dq SCHILY.xattr
560headers are written.
561.El
562.It Format ustar
563.Bl -tag -compact -width indent
564.It Cm hdrcharset
565The value is used as a character set name that will be
566used when translating file, group and user names.
567.El
568.It Format v7tar
569.Bl -tag -compact -width indent
570.It Cm hdrcharset
571The value is used as a character set name that will be
572used when translating file, group and user names.
573.El
574.It Format warc
575.Bl -tag -compact -width indent
576.It Cm omit-warcinfo
577Set to
578.Dq true
579to disable output of the warcinfo record.
580.El
581.It Format xar
582.Bl -tag -compact -width indent
583.It Cm checksum Ns = Ns Ar type
584Use
585.Ar type
586as file checksum method.
587Supported values are
588.Dq none ,
589.Dq md5 ,
590and
591.Dq sha1
592.Pq default .
593.It Cm compression Ns = Ns Ar type
594Use
595.Ar type
596as compression method.
597Supported values are
598.Dq none ,
599.Dq bzip2 ,
600.Dq gzip
601.Pq default ,
602.Dq lzma
603and
604.Dq xz .
605.It Cm compression_level
606The value is a decimal integer from 1 to 9 specifying the compression level.
607.It Cm toc-checksum Ns = Ns Ar type
608Use
609.Ar type
610as table of contents checksum method.
611Supported values are
612.Dq none ,
613.Dq md5
614and
615.Dq sha1
616.Pq default .
617.El
618.It Format zip
619.Bl -tag -compact -width indent
620.It Cm compression
621The value is either
622.Dq store
623or
624.Dq deflate
625to indicate how the following entries should be compressed.
626Note that this setting is ignored for directories, symbolic links,
627and other special entries.
628.It Cm compression-level
629The value is interpreted as a decimal integer specifying the
630compression level.
631Values between 0 and 9 are supported.
632A compression level of 0 switches the compression method to
633.Dq store ,
634other values will enable
635.Dq deflate
636compression with the given level.
637.It Cm encryption
638Enable encryption using traditional zip encryption.
639.It Cm encryption Ns = Ns Ar type
640Use
641.Ar type
642as encryption type.
643Supported values are
644.Dq zipcrypt
645.Pq traditional zip encryption ,
646.Dq aes128
647.Pq WinZip AES-128 encryption
648and
649.Dq aes256
650.Pq WinZip AES-256 encryption .
651.It Cm experimental
652This boolean option enables or disables experimental Zip features
653that may not be compatible with other Zip implementations.
654.It Cm fakecrc32
655This boolean option disables CRC calculations.
656All CRC fields are set to zero.
657It should not be used except for testing purposes.
658.It Cm hdrcharset
659The value is used as a character set name that will be
660used when translating file names.
661.It Cm zip64
662Zip64 extensions provide additional file size information
663for entries larger than 4 GiB.
664They also provide extended file offset and archive size information
665when archives exceed 4 GiB.
666By default, the Zip writer selectively enables these extensions only as needed.
667In particular, if the file size is unknown, the Zip writer will
668include Zip64 extensions to guard against the possibility that the
669file might be larger than 4 GiB.
670.Pp
671Setting this boolean option will force the writer to use Zip64 extensions
672even for small files that would not otherwise require them.
673This is primarily useful for testing.
674.Pp
675Disabling this option with
676.Cm !zip64
677will force the Zip writer to avoid Zip64 extensions:
678It will reject files with size greater than 4 GiB,
679it will reject any new entries once the total archive size reaches 4 GiB,
680and it will not use Zip64 extensions for files with unknown size.
681In particular, this can improve compatibility when generating archives
682where the entry sizes are not known in advance.
683.El
684.El
685.Sh EXAMPLES
686The following example creates an archive write handle to
687create a gzip-compressed ISO9660 format image.
688The two options here specify that the ISO9660 archive will use
689.Ar kernel.img
690as the boot image for El Torito booting, and that the gzip
691compressor should use the maximum compression level.
692.Bd -literal -offset indent
693a = archive_write_new();
694archive_write_add_filter_gzip(a);
695archive_write_set_format_iso9660(a);
696archive_write_set_options(a, "boot=kernel.img,compression=9");
697archive_write_open_filename(a, filename, blocksize);
698.Ed
699.\"
700.Sh ERRORS
701More detailed error codes and textual descriptions are available from the
702.Fn archive_errno
703and
704.Fn archive_error_string
705functions.
706.\"
707.Sh SEE ALSO
708.Xr tar 1 ,
709.Xr archive_read_set_options 3 ,
710.Xr archive_write 3 ,
711.Xr libarchive 3
712.Sh HISTORY
713The
714.Nm libarchive
715library first appeared in
716.Fx 5.3 .
717.Sh AUTHORS
718.An -nosplit
719The options support for libarchive was originally implemented by
720.An Michihiro NAKAJIMA .
721.Sh BUGS
722