ARCHIVE_WRITE_OPTIONS(3)

🌸 NAME 🌸

archive_write_set_filter_option, archive_write_set_format_option, archive_write_set_option, archive_write_set_options β€” functions controlling options for writing archives. This is ARCHIVE_WRITE_OPTIONS(3) from the Library Functions Manual, bestie. πŸŽ€

🫢 LIBRARY 🫢

Streaming Archive Library (libarchive, -larchive). Iconic behavior only.

✨ SYNOPSIS ✨

int
archive_write_set_filter_option(struct archive *, const char *module,
    const char *option, const char *value);

int
archive_write_set_format_option(struct archive *, const char *module,
    const char *option, const char *value);

int
archive_write_set_option(struct archive *, const char *module,
    const char *option, const char *value);

int
archive_write_set_options(struct archive *, const char *options);

πŸ’… DESCRIPTION πŸ’…

These functions provide a way for libarchive clients to configure specific write modules. It’s giving β€œgroup chat, but for write modules,” iykyk.

  • archive_write_set_filter_option(), archive_write_set_format_option() β€” specifies an option that will be passed to the currently-registered filters (including decompression filters) or format readers.
    • If option and value are both NULL, these functions will do nothing and ARCHIVE_OK will be returned.
    • If option is NULL but value is not, these functions will do nothing and ARCHIVE_FAILED will be returned. πŸ™ˆ
    • If module is not NULL, option and value will be provided to the filter or reader named module. The return value will be either ARCHIVE_OK if the option was successfully handled or ARCHIVE_WARN if the option was unrecognized by the module or could otherwise not be handled. If there is no such module, ARCHIVE_FAILED will be returned.
    • If module is NULL, option and value will be provided to every registered module. If any module returns ARCHIVE_FATAL, this value will be returned immediately. Otherwise, ARCHIVE_OK will be returned if any module accepts the option, and ARCHIVE_FAILED in all other cases. πŸ’€
  • archive_write_set_option() β€” calls archive_write_set_format_option(), then archive_write_set_filter_option(). If either function returns ARCHIVE_FATAL, ARCHIVE_FATAL will be returned immediately. Otherwise, the greater of the two values will be returned. πŸ”₯
  • archive_write_set_options() β€” options is a comma-separated list of options. If options is NULL or empty, ARCHIVE_OK will be returned immediately.

Individual options have one of the following forms:

  • option=value β€” the option/value pair will be provided to every module. Modules that do not accept an option with this name will ignore it. πŸ¦‹
  • option β€” the option will be provided to every module with a value of 1.
  • !option β€” the option will be provided to every module with a NULL value.
  • module:option=value, module:option, module:!option β€” as above, but the corresponding option and value will be provided only to modules whose name matches module. ✨

✨ OPTIONS ✨

Okay bestie, this is the big one β€” all the options, filters and format knobs, and we are keeping every single one. The vibe is cute, the facts are not moving. πŸ’…

🧼 Filter b64encode

  • mode β€” the value is read as octal digits specifying the file mode.
  • name β€” the value specifies the file name.

🧼 Filter bzip2

  • compression-level β€” the value is read as a decimal integer specifying the bzip2 compression level. Supported values are from 1 to 9.

🧼 Filter gzip

  • compression-level β€” the value is read as a decimal integer specifying the gzip compression level. Supported values are from 0 to 9.
  • timestamp β€” store timestamp. This is enabled by default.

🧼 Filter lrzip

  • compression=type β€” use type as the compression method. Supported values are β€œbzip2”, β€œgzipi”, β€œlzo” (ultra fast), and β€œzpaq” (best, extremely slow).
  • compression-level β€” the value is read as a decimal integer specifying the lrzip compression level. Supported values are from 1 to 9.

🧼 Filter lz4

  • compression-level β€” the value is read as a decimal integer specifying the lz4 compression level. Supported values are from 0 to 9.
  • stream-checksum β€” enable stream checksum. This is enabled by default.
  • block-checksum β€” enable block checksum. This is disabled by default.
  • block-size β€” the value is read as a decimal integer specifying the lz4 compression block size. Supported values are from 4 to 7 (default).
  • block-dependence β€” use the previous block of the block being compressed for a compression dictionary to improve compression ratio. This is disabled by default.

🧼 Filter lzop

  • compression-level β€” the value is read as a decimal integer specifying the lzop compression level. Supported values are from 1 to 9.

🧼 Filter uuencode

  • mode β€” the value is read as octal digits specifying the file mode.
  • name β€” the value specifies the file name.

🧼 Filter xz

  • compression-level β€” the value is read as a decimal integer specifying the compression level. Supported values are from 0 to 9.
  • threads β€” the value is read as a decimal integer specifying the number of threads for multi-threaded lzma compression. If supported, the default value is read from lzma_cputhreads().

🧼 Filter zstd

  • compression-level β€” the value is read as a decimal integer specifying the compression level. Supported values depend on the library version, common values are from 1 to 22.
  • long β€” enables long distance matching. The value is read as a decimal integer specifying log2 window size in bytes. Values from 10 to 30 for 32 bit, or 31 for 64 bit, are supported.
  • threads β€” the value is read as a decimal integer specifying the number of threads for multi-threaded zstd compression. If set to 0, zstd will attempt to detect and use the number of active physical CPU cores.

πŸŽ€ Format 7zip

  • compression β€” the value is one of β€œstore”, β€œcopy”, β€œdeflate”, β€œbzip2”, β€œlzma1”, β€œlzma2”, β€œppmd”, or β€œzstd” to indicate how the following entries should be compressed. The values β€œstore” and β€œcopy” are synonyms. Note that this setting is ignored for directories, symbolic links, and other special entries.
  • compression-level β€” the value is read as a decimal integer specifying the compression level. Values between 0 and 9 are supported, with the exception of bzip2 which only supports values between 1 and 9, and zstd which may support negative values depending on the library version and commonly used values 1 through 22. The interpretation of the compression level depends on the chosen compression method.
  • threads β€” the value is read as a decimal integer specifying the number of threads for multi-threaded compression (for compressors like zstd that support it). If set to 0, an attempt will be made to discover the number of CPU cores.

πŸŽ€ Format bin

  • hdrcharset β€” the value is used as a character set name that will be used when translating file names.

πŸŽ€ Format gnutar

  • hdrcharset β€” the value is used as a character set name that will be used when translating file, group and user names.

πŸŽ€ Format iso9660 - volume metadata

These options are used to set standard ISO9660 metadata.

  • abstract-file=filename β€” the file with the specified name will be identified in the ISO9660 metadata as holding the abstract for this volume. Default: none.
  • application-id=filename β€” the file with the specified name will be identified in the ISO9660 metadata as holding the application identifier for this volume. Default: none.
  • biblio-file=filename β€” the file with the specified name will be identified in the ISO9660 metadata as holding the bibliography for this volume. Default: none.
  • copyright-file=filename β€” the file with the specified name will be identified in the ISO9660 metadata as holding the copyright for this volume. Default: none.
  • publisher=filename β€” the file with the specified name will be identified in the ISO9660 metadata as holding the publisher information for this volume. Default: none.
  • volume-id=string β€” the specified string will be used as the Volume Identifier in the ISO9660 metadata. It is limited to 32 bytes. Default: none.

πŸŽ€ Format iso9660 - boot support

These options are used to make an ISO9660 image that can be directly booted on various systems.

  • boot=filename β€” the file matching this name will be used as the El Torito boot image file.
  • boot-catalog=name β€” the name that will be used for the El Torito boot catalog. Default: boot.catalog
  • boot-info-table β€” the boot image file provided by the boot=filename option will be edited with appropriate boot information in bytes 8 through 64. Default: disabled
  • boot-load-seg=hexadecimal-number β€” the load segment for a no-emulation boot image.
  • boot-load-size=decimal-number β€” the number of "virtual" 512-byte sectors to be loaded from a no-emulation boot image. Some very old BIOSes can only load very small images, setting this value to 4 will often allow such BIOSes to load the first part of the boot image (which will then need to be intelligent enough to load the rest of itself). This should not be needed unless you are trying to support systems with very old BIOSes. This defaults to the full size of the image.
  • boot-type=value β€” specifies the boot semantics used by the El Torito boot image: If the value is fd, then the boot image is assumed to be a bootable floppy image. If the value is hd, then the boot image is assumed to be a bootable hard disk image. If the value is no-emulation, the boot image is used without floppy or hard disk emulation. If the boot image is exactly 1.2MB, 1.44MB, or 2.88MB, then the default is fd, otherwise the default is no-emulation.

πŸŽ€ Format iso9660 - filename and size extensions

Various extensions to the base ISO9660 format.

  • allow-ldots β€” if enabled, allows filenames to begin with a leading period. If disabled, filenames that begin with a leading period will have that period replaced by an underscore character in the standard ISO9660 namespace. This does not impact names stored in the Rockridge or Joliet extension area. Default: disabled.
  • allow-lowercase β€” if enabled, allows filenames to contain lowercase characters. If disabled, filenames will be forced to uppercase. This does not impact names stored in the Rockridge or Joliet extension area. Default: disabled.
  • allow-multidot β€” if enabled, allows filenames to contain multiple period characters, in violation of the ISO9660 specification. If disabled, additional periods will be converted to underscore characters. This does not impact names stored in the Rockridge or Joliet extension area. Default: disabled.
  • allow-period β€” if enabled, allows filenames to contain trailing period characters, in violation of the ISO9660 specification. If disabled, trailing periods will be converted to underscore characters. This does not impact names stored in the Rockridge or Joliet extension area. Default: disabled.
  • allow-pvd-lowercase β€” if enabled, the Primary Volume Descriptor may contain lowercase ASCII characters, in violation of the ISO9660 specification. If disabled, characters will be converted to uppercase ASCII. Default: disabled.
  • allow-sharp-tilde β€” if enabled, sharp and tilde characters will be permitted

…in filenames, in violation of the ISO9660 specification. If disabled, such characters will be converted to underscore characters. Default: disabled.

  • allow-vernum β€” turn this on and version numbers get included with files πŸ’– turn it off and version numbers get suppressed, which is literally in violation of the ISO9660 standard. Real ones know it doesn't touch names stored in the Rockridge or Joliet extension area though. Default: enabled.
  • iso-level β€” this is the one that enables support for file size and file name extensions in the core ISO9660 area ✨ heads up: the name extensions you specify here do not affect the names stored in the Rockridge or Joliet extension areas, ok?
    • iso-level=1 β€” the most compliant form of ISO9660 image, the goody-two-shoes of levels πŸŽ€ filenames are limited to 8.3 uppercase format, directory names are limited to 8 uppercase characters, files are limited to 4 GiB, and the complete ISO9660 image cannot exceed 4 GiB.
    • iso-level=2 β€” glow-up time: filenames are limited to 30 uppercase characters with a 30-character extension, directory names are limited to 30 characters, files are limited to 4 GiB.
    • iso-level=3 β€” literally same as iso-level=2, except that files may exceed 4 GiB.
    • iso-level=4 β€” as with iso-level=3, except that filenames may be up to 193 characters and may include arbitrary 8-bit characters πŸ”₯
  • joliet β€” Microsoft's Joliet extensions store a completely separate set of directory information about each file πŸ¦‹ and in particular, this information includes Unicode filenames of up to 255 characters. Default: enabled.
  • limit-depth β€” if enabled, libarchive will use directory relocation records to ensure that no pathname exceeds the ISO9660 limit of 8 directory levels 🌸 if disabled, no relocation will occur. Default: enabled.
  • limit-dirs β€” if enabled, libarchive will cause an error if there are more than 65536 directories πŸ’€ if disabled, there is no limit on the number of directories. Default: enabled
  • pad β€” if enabled, 300 kiB of zero bytes will be appended to the end of the archive πŸŽ€ Default: enabled
  • relaxed-filenames β€” if enabled, all 7-bit ASCII characters are permitted in filenames (except lowercase characters unless allow-lowercase is also specified) ⚠️ this violates ISO9660 standards, no cap. This does not impact names stored in the Rockridge or Joliet extension area. Default: disabled.
  • rockridge β€” the Rockridge extensions store an additional set of POSIX-style file information with each file πŸ‘‘ including mtime, atime, ctime, permissions, and long filenames with arbitrary 8-bit characters. These extensions also support symbolic links and other POSIX file types. Default: enabled.

🌈 Format iso9660 - zisofs support 🌈

The zisofs extensions permit each file to be independently compressed using a gzip-compatible compression 🫢 this can provide significant size savings, but it requires the reading system to have support for these extensions. These extensions are disabled by default, bestie β€” you gotta ask for them.

  • compression-level=number β€” the compression level used by the deflate compressor πŸ’… ranges from 0 (least effort) to 9 (most effort). Default: 6
  • zisofs β€” synonym for zisofs=direct. Simple as that ✨
  • zisofs=direct β€” compress each file in the archive 🌸 unlike zisofs=indirect, this is handled entirely within libarchive and does not require a separate utility. For best results, libarchive tests each file and will store the file uncompressed if the compression does not actually save any space πŸ‘ in particular, files under 2k will never be compressed. Note that boot image files are never compressed β€” not them, they're exempt.
  • zisofs=indirect β€” recognizes files that have already been compressed with the mkzftree utility and sets up the necessary file metadata so that readers will correctly identify these as zisofs-compressed files πŸŽ€
  • zisofs-exclude=filename β€” specifies a filename that should not be compressed when using zisofs=direct πŸ™ˆ this option can be provided multiple times to suppress compression on many files.

πŸ¦‹ Format mtree πŸ¦‹

  • cksum, device, flags, gid, gname, indent, link, md5, mode, nlink, rmd160, sha1, sha256, sha384, sha512, size, time, uid, uname β€” enable a particular keyword in the mtree output πŸ’– prefix with an exclamation mark to disable the corresponding keyword. The default is equivalent to β€œdevice, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname”.
  • all β€” enables all of the above keywords. All of them. Iconic behaviour πŸ‘‘
  • use-set β€” enables generation of /set lines that specify default values for the following files and/or directories.
  • indent β€” XXX needs explanation XXX 🫠 (that's literally what the page says, bestie, I'm not making it up)

πŸ’œ Format newc πŸ’œ

  • hdrcharset β€” the value is used as a character set name that will be used when translating file names.

πŸ’œ Format odc πŸ’œ

  • hdrcharset β€” the value is used as a character set name that will be used when translating file names.

πŸ’œ Format pwb πŸ’œ

  • hdrcharset β€” the value is used as a character set name that will be used when translating file names.

(yes, it's the same option three times, they're all just like that 😭)


🌸 Format pax 🌸

  • hdrcharset β€” the value is used as a character set name that will be used when translating file, group and user names 🌈 the value is one of β€œBINARY” or β€œUTF-8”. With β€œBINARY” there is no character conversion, with β€œUTF-8” names are converted to UTF-8.
  • xattrheader β€” when storing extended attributes, this option configures which headers should be written πŸ’… the value is one of β€œall”, β€œLIBARCHIVE”, or β€œSCHILY”. By default, both β€œLIBARCHIVE.xattr” and β€œSCHILY.xattr” headers are written.

⭐ Format ustar ⭐

  • hdrcharset β€” the value is used as a character set name that will be used when translating file, group and user names.

⭐ Format v7tar ⭐

  • hdrcharset β€” the value is used as a character set name that will be used when translating file, group and user names.

πŸŽ€ Format warc πŸŽ€

  • omit-warcinfo β€” set to β€œtrue” to disable output of the warcinfo record πŸ™ˆ

🧚 Format xar 🧚

  • checksum=type β€” use type as file checksum method πŸ’– supported values are β€œnone”, β€œmd5”, and β€œsha1” (default).
  • compression=type β€” use type as compression method 🌈 supported values are β€œnone”, β€œbzip2”, β€œgzip” (default), β€œlzma” and β€œxz”.
  • compression_level β€” the value is a decimal integer from 1 to 9 specifying the compression level ✨
  • toc-checksum=type β€” use type as table of contents checksum method πŸŽ€ supported values are β€œnone”, β€œmd5” and β€œsha1” (default).

πŸ”₯ Format zip πŸ”₯

  • compression β€” the value is either β€œstore”, β€œdeflate”, β€œbzip2”, β€œlzma”, β€œxz”, or β€œzstd” to indicate how the following entries should be compressed πŸ’… note that this setting is ignored for directories, symbolic links, and other special entries β€” they're not like the other entries.
  • compression-level β€” the value is interpreted as a decimal integer specifying the compression level 🌸 values between 0 and 9 are supported. A compression level of 0 switches the compression method to β€œstore”, other values will enable β€œdeflate”, β€œbzip2”, β€œlzma”, or β€œzstd” compression (in order of priority, depending on what libraries are linked) with the given level.
  • threads β€” the value is interpreted as a decimal integer specifying the number of threads to use for compression πŸ‘‘ it is supported only for β€œxz” or β€œzstd” compression and ignored for any other. A threads value of 0 is a special one requesting to detect and use as many threads as the number of active physical CPU cores β€” main character scheduling fr fr.
  • encryption β€” enable encryption using traditional zip encryption πŸ”’
  • encryption=type β€” use type as encryption type πŸ’– supported values are β€œzipcrypt” (traditional zip encryption), β€œaes128” (WinZip AES-128 encryption) and β€œaes256” (WinZip AES-256 encryption).
  • experimental β€” this boolean option enables or disables experimental Zip features that may not be compatible with other Zip implementations ⚠️ you've been warned, bestie.
  • fakecrc32 β€” this boolean option disables CRC calculations, and all CRC fields are set to zero πŸ’€ it should not be used except for testing purposes. Like, only for testing. Periodt.
  • hdrcharset β€” the value is used as a character set name that will be used when translating file names.
  • zip64 β€” Zip64 extensions provide additional file size information for entries larger than 4 GiB ⭐ they also provide extended file offset and archive size information when archives exceed 4 GiB. By default, the

So the Zip writer is lowkey picky about these extensions β€” it only turns them on when it actually needs them πŸ’…. Specifically: if the file size is unknown, the Zip writer will include Zip64 extensions to guard against the possibility that the file might be larger than 4 GiB. Like, it's just being cautious, bestie, no cap. πŸ›‘οΈ

Setting this boolean option will force the writer to use Zip64 extensions even for small files that would not otherwise require them. And what's the point of that? Testing, mostly β€” that's literally its main use. πŸ”¬

Disabling this option with !zip64 will force the Zip writer to avoid Zip64 extensions, and she is strict about it:

  • It will reject files with size greater than 4 GiB 🚫
  • It will reject any new entries once the total archive size reaches 4 GiB 🚫
  • It will not use Zip64 extensions for files with unknown size 🚫

In particular, this can improve compatibility when generating archives where the entry sizes are not known in advance. So it's giving "trade-off queen" β€” less flexible, but more compatible. ✨


🌸 EXAMPLES 🌸

Okay so this next one is a whole snack πŸ“ β€” the following example creates an archive write handle to create a gzip-compressed ISO9660 format image. The two options here specify that the ISO9660 archive will use kernel.img as the boot image for El Torito booting, and that the gzip compressor should use the maximum compression level.

a = archive_write_new();
archive_write_add_filter_gzip(a);
archive_write_set_format_iso9660(a);
archive_write_set_options(a, "boot=kernel.img,compression=9");
archive_write_open_filename(a, filename, blocksize);

Look at that flow 😭 new handle β†’ gzip filter β†’ ISO9660 format β†’ options β†’ open. It's literally a glow-up routine for your archive. πŸ’…


πŸ’€ ERRORS πŸ’€

Need the deets on what went wrong? More detailed error codes and textual descriptions are available from the archive_errno() and archive_error_string() functions. Those two are your besties when something's sus β€” they'll tell you exactly what happened. 🫢


πŸ‘€ SEE ALSO πŸ‘€

Go read those, iykyk πŸ“šβœ¨


πŸ•°οΈ HISTORY πŸ•°οΈ

The libarchive library first appeared in FreeBSD 5.3. Vintage! Iconic! Old enough to have main character energy in its own right. πŸ‘‘


πŸŽ€ AUTHORS πŸŽ€

The options support for libarchive was originally implemented by Michihiro NAKAJIMA. Respect the OG, fr fr. 🫑


πŸ™ˆ BUGS πŸ™ˆ

Genuinely nothing here β€” the BUGS section is a whole empty vibe. Not a single bug listed, which is either iconic or deeply suspicious and I'm choosing to believe it's iconic. πŸ’€βœ¨


Okay bestie, that's the whole page β€” you ate that. Now go make some archives and slay. πŸ”₯πŸ¦‹

Signing off with all the deets: this was the ARCHIVE_WRITE_OPTIONS(3) page, dated January 31, 2020, from the Debian fam. Mwah! πŸ’–

πŸ“¦ where this page comes from