4 * External header for wimlib.
8 * Copyright (C) 2012 Eric Biggers
10 * This file is part of wimlib, a library for working with WIM files.
12 * wimlib is free software; you can redistribute it and/or modify it under the
13 * terms of the GNU General Public License as published by the Free
14 * Software Foundation; either version 3 of the License, or (at your option)
17 * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY
18 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 * A PARTICULAR PURPOSE. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with wimlib; if not, see http://www.gnu.org/licenses/.
28 * \section intro Introduction
30 * wimlib is a C library to read, write, and mount archive files in the Windows
31 * Imaging Format (WIM files). These files are normally created using the @c
32 * imagex.exe utility on Windows, but this library provides a free
33 * implementetion of @c imagex for UNIX-based systems and an API to allow other
34 * programs to read, write, and mount WIM files. wimlib is comparable to
35 * Microsoft's WIMGAPI, but was designed independently and is not a clone of it.
37 * \section format WIM files
39 * A <b>Windows Imaging (WIM)</b> file is an archive. Like some other archive
40 * formats such as ZIP, files in WIM archives may be compressed. WIM archives
41 * support two Microsoft-specific compression formats: @b LZX and @b XPRESS.
42 * Both are based on LZ77 and Huffman encoding, and both are supported by
45 * Unlike ZIP files, WIM files can contain multiple independent toplevel
46 * directory trees known as @a images. While each image has its own metadata,
47 * files are not duplicated for each image; instead, each file is included only
48 * once in the entire WIM. Microsoft did this so that in one WIM file, they
49 * could do things like have 5 different versions of Windows that are almost
52 * Microsoft provides documentation for the WIM file format, XPRESS compression
53 * format, and LZX compression format. The XPRESS documentation is acceptable,
54 * but the LZX documentation is not entirely correct, and the WIM documentation
55 * itself is very incomplete and is of unacceptable quality.
57 * \section winpe Windows PE
59 * A major use for this library is to create customized images of Windows PE, the
60 * Windows Preinstallation Environment, without having to rely on Windows. Windows
61 * PE is a lightweight version of Windows that can run entirely from memory and can
62 * be used to install Windows from local media or a network drive or perform
63 * maintenance. Windows PE is the operating system that runs when you boot from
64 * the Windows installation media.
66 * You can find Windows PE on the installation DVD for Windows Vista, Windows 7,
67 * or Windows 8, in the file @c sources/boot.wim. Windows PE can also be found
68 * in the Windows Automated Installation Kit (WAIK), which is free to download
69 * from Microsoft, inside the @c WinPE.cab file, which you can extract if you
70 * install either the @c cabextract or @c p7zip programs.
72 * In addition, Windows installations and recovery partitions frequently contain a
73 * WIM containing an image of the Windows Recovery Environment, which is similar to
76 * \section ntfs NTFS support
78 * As of version 1.0.0, wimlib supports capturing and applying images directly
79 * to NTFS volumes. This was made possible with the help of libntfs-3g from the
80 * NTFS-3g project. This feature supports capturing and restoring NTFS-specific
81 * data such as security descriptors, alternate data streams, and reparse point
84 * The code for NTFS image capture and image application is complete enough that
85 * it is possible to apply an image from the "install.wim" contained in recent
86 * Windows installation media (Vista, Windows 7, or Windows 8) directly to a
87 * NTFS volume, and then boot Windows from it after preparing the Boot
88 * Configuration Data. In addition, a Windows installation can be captured (or
89 * backed up) into a WIM file, and then re-applied later.
91 * \section starting Getting Started
93 * wimlib uses the GNU autotools, so it should be easy to install with
94 * <code>configure && make && sudo make install</code>; however, please see the
95 * README for more information about installing it. To use wimlib in a program
96 * after installing it, include @c wimlib.h and link your program with @c -lwim.
98 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure.
100 * All functions in wimlib's public API are prefixed with @c wimlib. Most
101 * return an integer error code on failure. Use wimlib_get_error_string() to
102 * get a string that describes an error code. wimlib also can print error
103 * messages itself when an error happens, and these may be more informative than
104 * the error code; to enable this, call wimlib_set_print_errors().
106 * wimlib is thread-safe as long as different ::WIMStruct's are used, with the
107 * following exceptions: wimlib_set_print_errors() and
108 * wimlib_set_memory_allocator() apply globally, and wimlib_mount() can only be
109 * used by one ::WIMStruct at a time.
111 * To open an existing WIM, use wimlib_open_wim().
113 * To create a new WIM that initially contains no images, use
114 * wimlib_create_new_wim().
116 * To add an image to a WIM file from a directory tree on your filesystem, call
117 * wimlib_add_image(). This can be done with a ::WIMStruct gotten from
118 * wimlib_open_wim() or from wimlib_create_new_wim(). Alternatively, if you
119 * want to capture a WIM image directly from a NTFS volume while preserving
120 * NTFS-specific data such as security descriptors, call
121 * wimlib_add_image_from_ntfs_volume() instead.
123 * To extract an image from a WIM file, call wimlib_extract_image().
124 * Alternatively, if you want to apply a WIM image directly to a NTFS volume
125 * while setting NTFS-specific data such as security descriptors, call
126 * wimlib_apply_image_to_ntfs_volume().
128 * The NTFS functions will fail if wimlib was compiled with the
129 * <code>--without-ntfs-3g</code> flag.
131 * wimlib supports mounting WIM files either read-only or read-write. Mounting
132 * is done using wimlib_mount() and unmounting is done using wimlib_unmount().
133 * Mounting can be done without root privileges because it is implemented using
134 * FUSE (Filesystem in Userspace). If wimlib is compiled with the
135 * <code>--without-fuse</code> flag, these functions will be available but will
138 * After creating or modifying a WIM file, you can write it to a file using
139 * wimlib_write(). Alternatively, if the WIM was originally read from a file,
140 * you can use wimlib_overwrite() to overwrite the original file. In some
141 * cases, wimlib_overwrite_xml_and_header() can be used instead.
143 * After you are done with the WIM file, use wimlib_free() to free all memory
144 * associated with a ::WIMStruct and close all files associated with it.
146 * To see an example of how to use wimlib, see the file
147 * @c programs/imagex.c in wimlib's source tree.
149 * wimlib supports custom memory allocators; use wimlib_set_memory_allocator()
150 * for this. However, if wimlib calls into @c libntfs-3g, the custom memory
151 * allocator may not be used.
153 * \section imagex imagex
155 * wimlib comes with the <b>imagex</b> program, which is documented in man pages.
157 * \section mkwinpeimg mkwinpeimg
159 * wimlib comes with the <b>mkwinpeimg</b> script, which is documented in a man
162 * \section Limitations
164 * While wimlib supports the main features of WIM files, wimlib currently has
165 * the following limitations:
166 * - There is no way to directly extract or mount split WIMs.
167 * - Different versions of the WIM file format are unsupported. There is one
168 * different version of the format from development versions of Windows Vista,
169 * but I'm not planning to support it.
170 * - Compressed resource chunk sizes other than 32768 are unsupported (except for
171 * uncompressed WIMs, for which the chunk size field is ignored). As far as I
172 * can tell, other chunk sizes are not used in compressed WIMs. Let me know
173 * if you find a WIM file with a different chunk size.
174 * - wimlib does not provide a clone of the @b PEImg tool that allows you to
175 * make certain Windows-specific modifications to a Windows PE image, such as
176 * adding a driver or Windows component. Such a tool could conceivably be
177 * implemented on top of wimlib, although it likely would be hard to implement
178 * because it would have to do very Windows-specific things such as
179 * manipulating the driver store. wimlib does provide the @b mkwinpeimg
180 * script for a similar purpose, however. With regards to adding drivers to
181 * Windows PE, you have the option of putting them anywhere in the Windows PE
182 * image, then loading them after boot using @b drvload.exe.
183 * - There is not yet a way to extract specific files or directories from a WIM
184 * file without mounting it, or to add, remove, or modify files in a WIM
185 * without mounting it, other than by adding or removing an entire image. I
186 * can implement this if requested, but I intend the FUSE mount feature to be
187 * used for this purpose, as it is easy to do these things in whatever way you
188 * want after the image is mounted.
189 * - Currently, Microsoft's @a image.exe can create slightly smaller WIM files
190 * than wimlib when using maximum (LZX) compression because it knows how to
191 * split up LZX compressed blocks, which is not yet implemented in wimlib.
192 * - wimlib is experimental and likely contains bugs; use Microsoft's @a
193 * imagex.exe if you want to make sure your WIM files are made "correctly".
195 * \section legal License
197 * The wimlib library, as well as the programs and scripts distributed with it
198 * (@b imagex and @b mkwinpeimg), is licensed under the GNU General Public
199 * License version 3 or later.
209 #ifndef _WIMLIB_INTERNAL_H
211 * Opaque structure that represents a WIM file.
213 typedef struct WIMStruct WIMStruct;
217 * Specifies the compression type of a WIM file.
220 enum wim_compression_type {
221 /** An invalid compression type. */
222 WIM_COMPRESSION_TYPE_INVALID = -1,
224 /** The WIM does not include any compressed resources. */
225 WIM_COMPRESSION_TYPE_NONE = 0,
227 /** Compressed resources in the WIM use LZX compression. */
228 WIM_COMPRESSION_TYPE_LZX = 1,
230 /** Compressed resources in the WIM use XPRESS compression. */
231 WIM_COMPRESSION_TYPE_XPRESS = 2,
234 /** Mount the WIM read-write. */
235 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
237 /** For debugging only. (This passes the @c -d flag to @c fuse_main()).*/
238 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
240 /** Do not allow accessing alternate data streams. */
241 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000010
243 /** Access alternate data streams through extended file attributes. This is the
245 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000020
247 /** Access alternate data streams by specifying the file name, a colon, then the
248 * alternate file stream name. */
249 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000040
251 /** Include an integrity table in the new WIM being written during the unmount.
252 * Ignored for read-only mounts. */
253 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
255 /** Unless this flag is given, changes to a mounted WIM are discarded. Ignored
256 * for read-only mounts. */
257 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
259 /** Include an integrity table in the new WIM file. */
260 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
262 /** Print progress information when writing the integrity table. */
263 #define WIMLIB_WRITE_FLAG_SHOW_PROGRESS 0x00000002
265 /** Print file paths as we write then */
266 #define WIMLIB_WRITE_FLAG_VERBOSE 0x00000004
268 /** Mark the image being added as the bootable image of the WIM. */
269 #define WIMLIB_ADD_IMAGE_FLAG_BOOT 0x00000001
271 /** Print the name of each file or directory as it is scanned to be included in
273 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE 0x00000002
275 /** Follow symlinks; archive and dump the files they point to. */
276 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE 0x00000004
278 /** See documentation for wimlib_export_image(). */
279 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
281 /** Verify the integrity of the WIM if an integrity table is present. */
282 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
284 /** Print progress information when verifying integrity table. */
285 #define WIMLIB_OPEN_FLAG_SHOW_PROGRESS 0x00000002
287 /** If this flag is not given, an error is issued if the WIM is part of a split
289 #define WIMLIB_OPEN_FLAG_SPLIT_OK 0x00000004
292 /** When identical files are extracted from the WIM, always hard link them
294 #define WIMLIB_EXTRACT_FLAG_HARDLINK 0x00000001
296 /** When identical files are extracted from the WIM, always symlink them
298 #define WIMLIB_EXTRACT_FLAG_SYMLINK 0x00000002
300 /** Print the name of each file as it is extracted from the WIM image. */
301 #define WIMLIB_EXTRACT_FLAG_VERBOSE 0x00000008
304 * Possible values of the error code returned by many functions in wimlib.
306 * See the documentation for each wimlib function to see specifically what error
307 * codes can be returned by a given function, and what they mean.
309 enum wimlib_error_code {
310 WIMLIB_ERR_SUCCESS = 0,
311 WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE,
312 WIMLIB_ERR_DECOMPRESSION,
313 WIMLIB_ERR_DELETE_STAGING_DIR,
316 WIMLIB_ERR_FUSERMOUNT,
317 WIMLIB_ERR_IMAGE_COUNT,
318 WIMLIB_ERR_IMAGE_NAME_COLLISION,
319 WIMLIB_ERR_INTEGRITY,
320 WIMLIB_ERR_INVALID_CAPTURE_CONFIG,
321 WIMLIB_ERR_INVALID_CHUNK_SIZE,
322 WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
323 WIMLIB_ERR_INVALID_DENTRY,
324 WIMLIB_ERR_INVALID_HEADER_SIZE,
325 WIMLIB_ERR_INVALID_IMAGE,
326 WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
327 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY,
328 WIMLIB_ERR_INVALID_PARAM,
329 WIMLIB_ERR_INVALID_RESOURCE_HASH,
330 WIMLIB_ERR_INVALID_RESOURCE_SIZE,
331 WIMLIB_ERR_INVALID_SECURITY_DATA,
337 WIMLIB_ERR_NOT_A_WIM_FILE,
338 WIMLIB_ERR_NO_FILENAME,
345 WIMLIB_ERR_SPECIAL_FILE,
346 WIMLIB_ERR_SPLIT_INVALID,
347 WIMLIB_ERR_SPLIT_UNSUPPORTED,
350 WIMLIB_ERR_UNKNOWN_VERSION,
351 WIMLIB_ERR_UNSUPPORTED,
357 /** Used to indicate that no WIM image is currently selected. */
358 #define WIM_NO_IMAGE 0
360 /** Used to specify all images in the WIM. */
361 #define WIM_ALL_IMAGES (-1)
365 * Adds an image to a WIM file from a directory tree on disk.
367 * The directory tree is read immediately for the purpose of constructing a
368 * directory entry tree in-memory. Also, all files are read to calculate their
369 * SHA1 message digests. However, because the directory tree may contain a very
370 * large amount of data, the files themselves are not read into memory
371 * permanently, and instead references to their paths saved. The files are then
372 * read on-demand if wimlib_write() or wimlib_overwrite() is called.
375 * Pointer to the ::WIMStruct for a WIM file to which the image will be
378 * A path to a directory in the outside filesystem. It will become the
379 * root directory for the WIM image.
381 * The name to give the image. This must be non-@c NULL.
383 * Pointer to the contents of an image capture configuration file. If @c
384 * NULL, a default string is used. Please see the manual page for
385 * <b>imagex capture</b> for more information.
387 * Length of the string @a config in bytes.
390 * Bitwise OR of flags prefixed with WIMLIB_ADD_IMAGE_FLAG. If
391 * ::WIMLIB_ADD_IMAGE_FLAG_BOOT is specified, the image in @a wim that is
392 * marked as bootable is changed to the one being added. If
393 * ::WIMLIB_ADD_IMAGE_FLAG_VERBOSE is specified, the name of each file is
394 * printed as it is scanned or captured. If
395 * ::WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE is specified, the files or
396 * directories pointed to by symbolic links are archived rather than the
397 * symbolic links themselves.
399 * @return 0 on success; nonzero on error. On error, changes to @a wim are
400 * discarded so that it appears to be in the same state as when this function
403 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
404 * There is already an image named @a name in @a w.
405 * @retval ::WIMLIB_ERR_INVALID_PARAM
406 * @a dir was @c NULL, @a name was @c NULL, or @a name was the empty string.
407 * @retval ::WIMLIB_ERR_NOMEM
408 * Failed to allocate needed memory.
409 * @retval ::WIMLIB_ERR_NOTDIR
410 * @a dir is not a directory.
411 * @retval ::WIMLIB_ERR_OPEN
412 * Failed to open a file or directory in the directory tree rooted at @a
414 * @retval ::WIMLIB_ERR_READ
415 * Failed to read a file in the directory tree rooted at @a dir.
416 * @retval ::WIMLIB_ERR_STAT
417 * Failed obtain the metadata for a file or directory in the directory tree
420 extern int wimlib_add_image(WIMStruct *wim, const char *dir,
421 const char *name, const char *config,
422 size_t config_len, int flags);
425 * This function is similar to wimlib_add_image(), except instead of capturing
426 * the WIM image from a directory, it is captured from a NTFS volume specified
427 * by @a device. NTFS-3g errors are reported as ::WIMLIB_ERR_NTFS_3G.
428 * ::WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE may not be specified because we capture
429 * the reparse points exactly as they are.
431 extern int wimlib_add_image_from_ntfs_volume(WIMStruct *w, const char *device,
438 * This function is similar to wimlib_extract_image(), except that @a image may
439 * not be ::WIM_ALL_IMAGES, and @a device specifies the name of a file or block
440 * device containing a NTFS volume to apply the image to. NTFS-3g errors are
441 * reported as ::WIMLIB_ERR_NTFS_3G, and ::WIMLIB_EXTRACT_FLAG_HARDLINK or
442 * ::WIMLIB_EXTRACT_FLAG_SYMLINK may not be specified because in the NTFS
443 * apply mode we apply the reparse points and hard links exactly as they are in
446 extern int wimlib_apply_image_to_ntfs_volume(WIMStruct *w, int image,
447 const char *device, int flags);
450 * Creates a WIMStruct for a new WIM file.
453 * The type of compression to be used in the new WIM file. Must be
454 * ::WIM_COMPRESSION_TYPE_NONE, ::WIM_COMPRESSION_TYPE_LZX, or
455 * ::WIM_COMPRESSION_TYPE_XPRESS.
457 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
458 * written to the memory location pointed to by this paramater. The
459 * ::WIMStruct must be freed using using wimlib_free() when finished with
461 * @return 0 on success; nonzero on error.
462 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
463 * @a ctype was not ::WIM_COMPRESSION_TYPE_NONE,
464 * ::WIM_COMPRESSION_TYPE_LZX, or ::WIM_COMPRESSION_TYPE_XPRESS.
465 * @retval ::WIMLIB_ERR_NOMEM
466 * Failed to allocate needed memory.
468 extern int wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
471 * Deletes an image, or all images, from a WIM file.
473 * All file resources referenced by the image(s) being deleted are removed from
474 * the WIM if they are not referenced by any other images in the WIM.
477 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
480 * The number of the image to delete, or ::WIM_ALL_IMAGES to delete all
482 * @return 0 on success; nonzero on error. On error, @a wim is left in an
483 * indeterminate state and should be freed with wimlib_free().
484 * @retval ::WIMLIB_ERR_DECOMPRESSION
485 * Could not decompress the metadata resource for @a image.
486 * @retval ::WIMLIB_ERR_INVALID_DENTRY
487 * A directory entry in the metadata resource for @a image in the WIM is
489 * @retval ::WIMLIB_ERR_INVALID_IMAGE
490 * @a image does not exist in the WIM and is not ::WIM_ALL_IMAGES.
491 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
492 * The metadata resource for @a image in the WIM is invalid.
493 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
494 * The security data for @a image in the WIM is invalid.
495 * @retval ::WIMLIB_ERR_NOMEM Failed to allocate needed memory.
496 * @retval ::WIMLIB_ERR_READ
497 * Could not read the metadata resource for @a image from the WIM.
499 extern int wimlib_delete_image(WIMStruct *wim, int image);
502 * Copies an image, or all the images, from a WIM file, into another WIM file.
505 * Pointer to the ::WIMStruct for a WIM file that contains the image(s)
508 * The image to export from @a src_wim. Can be the number of an image, or
509 * ::WIM_ALL_IMAGES to export all images.
511 * Pointer to the ::WIMStruct for a WIM filethat will receive the images being
514 * The name to give the exported image in the new WIM file. If left @c NULL,
515 * the name from @a src_wim is used. This parameter must be left @c NULL
516 * if @a src_image is ::WIM_ALL_IMAGES and @a src_wim contains more than one
517 * image; in that case, the names are all taken from the @a src_wim.
518 * @param dest_description
519 * The description to give the exported image in the new WIM file. If left
520 * @c NULL, the description from the @a src_wim is used. This parameter must
521 * be left @c NULL if @a src_image is ::WIM_ALL_IMAGES and @a src_wim contains
522 * more than one image; in that case, the descriptions are all taken from
525 * ::WIMLIB_EXPORT_FLAG_BOOT if the image being exported is to be made
526 * bootable, or 0 if which image is marked as bootable in the destination
527 * WIM is to be left unchanged. If @a src_image is ::WIM_ALL_IMAGES and
528 * there are multiple images in @a src_wim, specifying
529 * ::WIMLIB_EXPORT_FLAG_BOOT is valid only if one of the exported images is
530 * currently marked as bootable in @a src_wim; if that is the case, then
531 * that image is marked as bootable in the destination WIM.
533 * @return 0 on success; nonzero on error. On error, @dest_wim is left in an
534 * indeterminate state and should be freed with wimlib_free().
535 * @retval ::WIMLIB_ERR_DECOMPRESSION
536 * Could not decompress the metadata resource for @a src_image
538 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
539 * One or more of the names being given to an exported image was already in
540 * use in the destination WIM.
541 * @retval ::WIMLIB_ERR_INVALID_DENTRY
542 * A directory entry in the metadata resource for @a src_image in @a
543 * src_wim is invalid.
544 * @retval ::WIMLIB_ERR_INVALID_IMAGE
545 * @a src_image does not exist in @a src_wim.
546 * @retval ::WIMLIB_ERR_INVALID_PARAM
547 * ::WIMLIB_EXPORT_FLAG_BOOT was specified in @a flags, @a src_image was
548 * ::WIM_ALL_IMAGES, @a src_wim contains multiple images, and no images in
549 * @a src_wim are marked as bootable; or @a dest_name and/or @a
550 * dest_description were non-<code>NULL</code>, @a src_image was
551 * ::WIM_ALL_IMAGES, and @a src_wim contains multiple images.
552 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
553 * The metadata resource for @a src_image in @a src_wim is invalid.
554 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
555 * The security data for @a src_image in @a src_wim is invalid.
556 * @retval ::WIMLIB_ERR_NOMEM
557 * Failed to allocate needed memory.
558 * @retval ::WIMLIB_ERR_READ
559 * Could not read the metadata resource for @a src_image from @a src_wim.
561 extern int wimlib_export_image(WIMStruct *src_wim, int src_image,
562 WIMStruct *dest_wim, const char *dest_name,
563 const char *dest_description, int flags);
566 * Extracts an image, or all images, from a WIM file.
568 * The output directory must have been previously set with
569 * wimlib_set_output_dir().
571 * The link type used for extracted files is that specified by a previous call
572 * to wimlib_set_link_type(), or ::WIM_LINK_TYPE_NONE by default.
575 * Pointer to the ::WIMStruct for a WIM file.
577 * The image to extract. Can be the number of an image, or ::WIM_ALL_IMAGES
578 * to specify that all images are to be extracted.
580 * @return 0 on success; nonzero on error.
581 * @retval ::WIMLIB_ERR_DECOMPRESSION
582 * Could not decompress a resource (file or metadata) for @a image in @a
584 * @retval ::WIMLIB_ERR_INVALID_DENTRY
585 * A directory entry in the metadata resource for @a image in @a wim is
587 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
588 * The SHA1 message digest of an extracted stream did not match the SHA1
589 * message digest given in the WIM file.
590 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
591 * A resource (file or metadata) for @a image in @a wim is invalid.
592 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
593 * The security data for @a image in @a wim is invalid.
594 * @retval ::WIMLIB_ERR_LINK
595 * Failed to create a symbolic link or a hard link.
596 * @retval ::WIMLIB_ERR_MKDIR
597 * Failed create a needed directory.
598 * @retval ::WIMLIB_ERR_NOMEM
599 * Failed to allocate needed memory.
600 * @retval ::WIMLIB_ERR_OPEN
601 * Could not open one of the files being extracted for writing.
602 * @retval ::WIMLIB_ERR_READ
603 * A unexpected end-of-file or read error occurred when trying to read data
604 * from the WIM file associated with @a wim.
605 * @retval ::WIMLIB_ERR_WRITE
606 * Failed to write a file being extracted.
608 extern int wimlib_extract_image(WIMStruct *wim, int image,
609 const char *output_dir, int flags);
612 * Extracts the XML data for a WIM file to a file stream. Every WIM file
613 * includes a string of XML that describes the images contained in the WIM.
616 * Pointer to the ::WIMStruct for a WIM file.
618 * @c stdout, or a FILE* opened for writing, to extract the data to.
620 * @return 0 on success; nonzero on error.
621 * @retval ::WIMLIB_ERR_WRITE
622 * Failed to completely write the XML data to @a fp.
624 extern int wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
627 * Frees all memory allocated for a WIMStruct and closes all files associated
631 * Pointer to the ::WIMStruct for a WIM file.
633 * @return This function has no return value.
635 extern void wimlib_free(WIMStruct *wim);
638 * Finds which image in a WIM is bootable.
641 * Pointer to the ::WIMStruct for a WIM file.
644 * 0 if no image is marked as bootable, or the number of the image marked
645 * as bootable (numbered starting at 1).
647 extern int wimlib_get_boot_idx(const WIMStruct *wim);
650 * Gets the compression type used in the WIM.
653 * Pointer to the ::WIMStruct for a WIM file
656 * ::WIM_COMPRESSION_TYPE_NONE, ::WIM_COMPRESSION_TYPE_LZX, or
657 * ::WIM_COMPRESSION_TYPE_XPRESS.
659 extern int wimlib_get_compression_type(const WIMStruct *wim);
662 * Converts a compression type enumeration value into a string.
665 * ::WIM_COMPRESSION_TYPE_NONE, ::WIM_COMPRESSION_TYPE_LZX,
666 * ::WIM_COMPRESSION_TYPE_XPRESS, or another value.
669 * A statically allocated string: "None", "LZX", "XPRESS", or "Invalid",
672 extern const char *wimlib_get_compression_type_string(int ctype);
675 * Converts an error code into a string describing it.
678 * The error code returned by one of wimlib's functions.
681 * Pointer to a statically allocated string describing the error code,
682 * or @c NULL if the error code is not valid.
684 extern const char *wimlib_get_error_string(enum wimlib_error_code code);
687 * Returns the description of the specified image.
690 * Pointer to the ::WIMStruct for a WIM file.
692 * The number of the image, numbered starting at 1.
695 * The description of the image, or @c NULL if there is no such image, or @c NULL
696 * if the specified image has no description.
698 extern const char *wimlib_get_image_description(const WIMStruct *wim, int image);
701 * Returns the name of the specified image.
704 * Pointer to the ::WIMStruct for a WIM file.
706 * The number of the image, numbered starting at 1.
709 * The name of the image, or @c NULL if there is no such image.
711 extern const char *wimlib_get_image_name(const WIMStruct *wim, int image);
715 * Gets the number of images contained in the WIM.
718 * Pointer to the ::WIMStruct for a WIM file.
721 * The number of images contained in the WIM file.
723 extern int wimlib_get_num_images(const WIMStruct *wim);
726 * Gets the part number of the wim (in a split WIM).
729 * Pointer to the ::WIMStruct for a WIM file.
730 * @param total_parts_ret
731 * If non-@c NULL, the total number of parts in the split WIM (1 for
732 * non-split WIMs) is written to this location.
735 * The part number of the WIM (1 for non-split WIMs)
737 extern int wimlib_get_part_number(const WIMStruct *wim, int *total_parts_ret);
740 * Returns true if the WIM has an integrity table.
743 * Pointer to the ::WIMStruct for a WIM file.
745 * @c true if the WIM has an integrity table; false otherwise.
747 extern bool wimlib_has_integrity_table(const WIMStruct *wim);
751 * Determines if an image name is already used by some image in the WIM.
754 * Pointer to the ::WIMStruct for a WIM file.
759 * @c true if there is already an image in @a wim named @a name; @c
760 * false if there is no image named @a name in @a wim.
762 extern bool wimlib_image_name_in_use(const WIMStruct *wim, const char *name);
765 * Joins a set of split WIMs into a one-part WIM.
768 * An array of strings that give the filenames of all parts of the split
771 * Number of filenames in @a swms.
773 * The path to write the one-part WIM to.
775 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY to check the split WIMs' integrity
776 * tables (if present) when opening them, and include an integrity table in
779 * @return 0 on success; nonzero on error. This function may return any value
780 * returned by wimlib_open_wim() except ::WIMLIB_ERR_SPLIT_UNSUPPORTED, as well
781 * as the following error codes:
783 * @retval ::WIMLIB_ERR_SPLIT_INVALID
784 * The split WIMs do not form a valid WIM because they do not include all
785 * the parts of the original WIM, there are duplicate parts, or not all the
786 * parts have the same GUID and compression type.
787 * @retval ::WIMLIB_ERR_WRITE
788 * An error occurred when trying to write data to the new WIM at @a output_path.
790 * Note that this function merely copies the resources, so it will not check to
791 * see if the resources, including the metadata resource, are valid or not.
793 extern int wimlib_join(const char **swms, int num_swms,
794 const char *output_path, int flags);
797 * Mounts an image in a WIM file on a directory read-only or read-write.
799 * A daemon will be forked to service the filesystem.
801 * If the mount is read-write, modifications to the WIM are staged in a staging
804 * wimlib_mount() currently cannot be used with multiple ::WIMStruct's without
805 * intervening wimlib_unmount()s. If there was a way to have libfuse pass a
806 * pointer to user data to each FUSE callback, then this would be possible, but
807 * there doesn't seem to be a way to do this currently.
810 * Pointer to the ::WIMStruct for the WIM file to be mounted.
812 * The number of the image to mount, numbered from 1. It must be an
813 * existing, single image.
815 * The path to an existing directory to mount the image on.
817 * Bitwise OR of the flags prefixed with WIMLIB_MOUNT_FLAG. If
818 * ::WIMLIB_MOUNT_FLAG_READWRITE is not given, the WIM is mounted
819 * read-only. The interface to the WIM named data streams is specified by
820 * exactly one of ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE,
821 * ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR, or
822 * ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS. The default interface is
823 * the XATTR interface.
825 * @return 0 on success; nonzero on error.
826 * @retval ::WIMLIB_ERR_DECOMPRESSION
827 * Could not decompress the metadata resource for @a image in @a wim.
828 * @retval ::WIMLIB_ERR_FUSE
829 * A non-zero status was returned by @c fuse_main().
830 * @retval ::WIMLIB_ERR_INVALID_DENTRY
831 * A directory entry in the metadata resource for @a image in @a wim is
833 * @retval ::WIMLIB_ERR_INVALID_IMAGE
834 * @a image does not specify an existing, single image in @a wim.
835 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
836 * The metadata resource for @a image in @a wim is invalid.
837 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
838 * The security data for @a image in @a wim is invalid.
839 * @retval ::WIMLIB_ERR_MKDIR
840 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @a flags, but the staging
841 * directory could not be created.
842 * @retval ::WIMLIB_ERR_NOMEM
843 * Failed to allocate needed memory.
844 * @retval ::WIMLIB_ERR_NOTDIR
845 * Could not determine the current working directory.
846 * @retval ::WIMLIB_ERR_READ
847 * An unexpected end-of-file or read error occurred when trying to read
848 * data from the WIM file associated with @a wim.
851 extern int wimlib_mount(WIMStruct *wim, int image, const char *dir, int flags);
854 * Opens a WIM file and creates a ::WIMStruct for it.
857 * The path to the WIM file to open.
859 * Bitwise OR of ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY and/or
860 * ::WIMLIB_OPEN_FLAG_SHOW_PROGRESS.
861 * If ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is given, the integrity table
862 * of the WIM, if it exists, is checked, and the function will fail with an
863 * ::WIMLIB_ERR_INTEGRITY status if any of the computed SHA1 message
864 * digests of the WIM do not exactly match the corresponding message
865 * digests given in the integrity table.
866 * If ::WIMLIB_OPEN_FLAG_SHOW_PROGRESS is given, progress information will
867 * be shown if the integrity of the WIM is checked.
868 * If ::WIMLIB_OPEN_FLAG_SPLIT_OK is given, no error will be issued if the
869 * WIM is part of a split WIM. However, wimlib does not fully support
870 * split WIMs, so not all functions will work correctly after opening a
871 * split WIM. For example, you cannot use wimlib_mount() or
872 * wimlib_extract_image() on a split WIM.
875 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
876 * is written to the memory location pointed to by this parameter. The
877 * ::WIMStruct must be freed using using wimlib_free() when finished with
880 * @return 0 on success; nonzero on error.
881 * @retval ::WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE
882 * The lookup table of @a wim_file is compressed. Support for this can be
883 * added to wimlib if needed, but it appears to be the case that the lookup
884 * table is never compressed.
885 * @retval ::WIMLIB_ERR_IMAGE_COUNT
886 * The WIM is not the non-first part of a split WIM, and the number of
887 * metadata resources found in the WIM did not match the image count given
888 * in the WIM header, or the number of <IMAGE> elements in the XML
889 * data for the WIM did not match the image count given in the WIM header.
890 * @retval ::WIMLIB_ERR_INTEGRITY
891 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a flags and @a
892 * wim_file contains an integrity table, but the SHA1 message digest for a
893 * chunk of the WIM does not match the corresponding message digest given
894 * in the integrity table.
895 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
896 * Resources in @a wim_file are compressed, but the chunk size is not 32768.
897 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
898 * The header of @a wim_file says that resources in the WIM are compressed,
899 * but the header flag indicating LZX or XPRESS compression is not set.
900 * @retval ::WIMLIB_ERR_INVALID_HEADER_SIZE
901 * The length field of the WIM header is not 208.
902 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
903 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a flags and @a
904 * wim_file contains an integrity table, but the integrity table is
906 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
907 * The lookup table for the WIM contained duplicate entries, or it
908 * contained an entry with a SHA1 message digest of all 0's.
909 * @retval ::WIMLIB_ERR_NOMEM
910 * Failed to allocated needed memory.
911 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
912 * @a wim_file does not begin with the expected magic characters.
913 * @retval ::WIMLIB_ERR_OPEN
914 * Failed to open the file @a wim_file for reading.
915 * @retval ::WIMLIB_ERR_READ
916 * An unexpected end-of-file or read error occurred when trying to read
917 * data from @a wim_file.
918 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
919 * @a wim_file is a split WIM, but ::WIMLIB_OPEN_FLAG_SPLIT_OK was not
921 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
922 * A number other than 0x10d00 is written in the version field of the WIM
923 * header of @a wim_file.
924 * @retval ::WIMLIB_ERR_XML
925 * The XML data for @a wim_file is invalid.
927 extern int wimlib_open_wim(const char *wim_file, int flags,
928 WIMStruct **wim_ret);
931 * Overwrites the file that the WIM was originally read from, with changes made.
933 * The new WIM is written to a temporary file and then renamed to the original
934 * file after it is has been completely written. The temporary file currently
935 * is made in the same directory as the original WIM file.
937 * Note that it is not possible for this function to delete the original file
938 * before having written the new file because it is very likely that file
939 * resources in the new WIM file need to be retrieved from the old WIM file.
941 * After this function returns, @a wim must be freed using wimlib_free(). Any
942 * further actions on @a wim before doing this are undefined.
945 * Pointer to the ::WIMStruct for the WIM file to write. There may have
946 * been in-memory changes made to it, which are then reflected in the
949 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY and/or
950 * ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS.
952 * @return 0 on success; nonzero on error. This function may return any value
953 * returned by wimlib_write() as well as the following error codes:
954 * @retval ::WIMLIB_ERR_NO_FILENAME
955 * @a wim corresponds to a WIM created with wimlib_create_new_wim() rather
956 * than a WIM read with wimlib_open_wim().
957 * @retval ::WIMLIB_ERR_RENAME
958 * The temporary file that the WIM was written to could not be renamed to
959 * the original filename of @a wim.
961 extern int wimlib_overwrite(WIMStruct *wim, int flags);
964 * Updates the header and XML data of the WIM file, without the need to write
965 * out the entire WIM to a temporary file as in wimlib_write().
967 * This function must only be used if no files, directories, or images have been
968 * added, removed, or changed in the WIM. It must be used when only the boot
969 * index or the name or description of image(s) has been changed.
971 * After this function returns, @a wim must be freed using wimlib_free(). Any
972 * further actions on @a wim before doing this are undefined.
975 * Pointer to the ::WIMStruct for the WIM file to overwrite.
977 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY and/or
978 * ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS.
980 * @return 0 on success; nonzero on error.
982 * @retval ::WIMLIB_ERR_NO_FILENAME
983 * @a wim corresponds to a WIM created with wimlib_create_new_wim() rather
984 * than a WIM read with wimlib_open_wim().
985 * @retval ::WIMLIB_ERR_NOMEM
986 * Failed to allocate needed memory.
987 * @retval ::WIMLIB_ERR_OPEN
988 * The WIM file associated with @a wim could not be re-opened read-write.
989 * @retval ::WIMLIB_ERR_READ
990 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY was specified in @a flags, but data
991 * from the WIM file associated with @a wim could not be read to compute
992 * the SHA1 message digests, or the old integrity table (if it existed)
994 * @retval ::WIMLIB_ERR_WRITE
995 * Failed to write the WIM header, the XML data, or the integrity table to
996 * the WIM file associated with @a wim.
998 extern int wimlib_overwrite_xml_and_header(WIMStruct *wim, int flags);
1001 * Prints information about one image, or all images, contained in a WIM.
1004 * Pointer to the ::WIMStruct for a WIM file.
1006 * The image about which to print information. Can be the number of an
1007 * image, or ::WIM_ALL_IMAGES to print information about all images in the
1010 * @return This function has no return value.
1012 extern void wimlib_print_available_images(const WIMStruct *wim, int image);
1015 * Prints the full paths to all files contained in an image, or all images, in a
1019 * Pointer to the ::WIMStruct for a WIM file.
1021 * Which image to print files for. Can be the number of an image, or
1022 * ::WIM_ALL_IMAGES to print the files contained in all images.
1024 * @return 0 on success; nonzero on error.
1025 * @retval ::WIMLIB_ERR_DECOMPRESSION
1026 * The metadata resource for one of the specified images could not be
1028 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1029 * A directory entry in the metadata resource for one of the specified
1030 * images is invaled.
1031 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1032 * @a image does not specify a valid image in @a wim, and is not
1034 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1035 * The metadata resource for one of the specified images is invalid.
1036 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1037 * The security data for one of the specified images is invalid.
1038 * @retval ::WIMLIB_ERR_NOMEM
1039 * Failed to allocate needed memory.
1040 * @retval ::WIMLIB_ERR_READ
1041 * An unexpected read error or end-of-file occurred when reading the
1042 * metadata resource for one of the specified images.
1044 extern int wimlib_print_files(WIMStruct *wim, int image);
1047 * Prints detailed information from the header of a WIM file.
1050 * Pointer to the ::WIMStruct for a WIM file.
1052 * @return This function has no return value.
1055 extern void wimlib_print_header(const WIMStruct *wim);
1058 * Prints the lookup table of a WIM file. The lookup table maps SHA1 message
1059 * digests, as found in the directory entry tree in the WIM file, to file
1060 * resources in the WIM file. This table includes one entry for each unique
1061 * file in the WIM, so it can be quite long. There is only one lookup table per
1065 * Pointer to the ::WIMStruct for a WIM file.
1067 * @return This function has no return value.
1069 extern void wimlib_print_lookup_table(WIMStruct *wim);
1072 * Prints the metadata of the specified image in a WIM file. The metadata
1073 * consists of the security data as well as the directory entry tree, and each
1074 * image has its own metadata.
1077 * Pointer to the ::WIMStruct for a WIM file.
1079 * Which image to print the metadata for. Can be the number of an image,
1080 * or ::WIM_ALL_IMAGES to print the metadata for all images in the WIM.
1082 * @return 0 on success; nonzero on error.
1083 * @retval ::WIMLIB_ERR_DECOMPRESSION
1084 * The metadata resource for one of the specified images could not be
1086 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1087 * A directory entry in the metadata resource for one of the specified
1088 * images is invaled.
1089 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1090 * @a image does not specify a valid image in @a wim, and is not
1092 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1093 * The metadata resource for one of the specified images is invalid.
1094 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1095 * The security data for one of the specified images is invalid.
1096 * @retval ::WIMLIB_ERR_NOMEM
1097 * Failed to allocate needed memory.
1098 * @retval ::WIMLIB_ERR_READ
1099 * An unexpected read error or end-of-file occurred when reading the
1100 * metadata resource for one of the specified images.
1102 extern int wimlib_print_metadata(WIMStruct *wim, int image);
1105 * Prints some basic information about a WIM file. All information printed by
1106 * this function is also printed by wimlib_print_header(), but
1107 * wimlib_print_wim_information() prints some of this information more concisely
1108 * and in a more readable form.
1111 * Pointer to the ::WIMStruct for a WIM file.
1113 * @return This function has no return value.
1115 extern void wimlib_print_wim_information(const WIMStruct *wim);
1118 * Translates a string specifying the name or number of an image in the WIM into
1119 * the number of the image. The images are numbered starting at 1.
1122 * Pointer to the ::WIMStruct for a WIM file.
1123 * @param image_name_or_num
1124 * A string specifying which image. If it begins with a number, it is
1125 * taken to be a string specifying the image number. Otherwise, it is
1126 * taken to be the name of an image, as specified in the XML data for the
1127 * WIM file. It also may be the keyword "all", which will resolve to
1131 * If the string resolved to a single existing image, the number of that
1132 * image, counting starting at 1, is returned. If the keyword "all" was
1133 * specified, ::WIM_ALL_IMAGES is returned. Otherwise, ::WIM_NO_IMAGE is
1136 extern int wimlib_resolve_image(WIMStruct *wim, const char *image_name_or_num);
1139 * Sets which image in the WIM is marked as bootable.
1142 * Pointer to the ::WIMStruct for a WIM file.
1144 * The number of the image to mark as bootable, or 0 to mark no image as
1146 * @return 0 on success; nonzero on error.
1147 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1148 * @a boot_idx does not specify an existing image in @a wim, and it was not
1151 extern int wimlib_set_boot_idx(WIMStruct *wim, int boot_idx);
1154 * Changes the description of an image in the WIM.
1157 * Pointer to the ::WIMStruct for a WIM file.
1159 * The number of the image for which to change the description.
1160 * @param description
1161 * The new description to give the image. It may be @c NULL, which
1162 * indicates that the image is to be given no description.
1164 * @return 0 on success; nonzero on error.
1165 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1166 * @a image does not specify a single existing image in @a wim.
1167 * @retval ::WIMLIB_ERR_NOMEM
1168 * Failed to allocate the memory needed to duplicate the @a description
1171 extern int wimlib_set_image_descripton(WIMStruct *wim, int image,
1172 const char *description);
1174 extern int wimlib_set_image_flags(WIMStruct *w, int image,
1178 * Changes the name of an image in the WIM.
1181 * Pointer to the ::WIMStruct for a WIM file.
1183 * The number of the image for which to change the name.
1185 * The new name to give the image. It must not be @c NULL.
1187 * @return 0 on success; nonzero on error.
1188 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1189 * There is already an image named @a name in @a wim.
1190 * @retval ::WIMLIB_ERR_INVALID_PARAM
1191 * @a name was @c NULL or the empty string.
1192 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1193 * @a image does not specify a single existing image in @a wim.
1194 * @retval ::WIMLIB_ERR_NOMEM
1195 * Failed to allocate the memory needed to duplicate the @a name string.
1197 extern int wimlib_set_image_name(WIMStruct *wim, int image, const char *name);
1200 * Set the functions that wimlib uses to allocate and free memory.
1202 * These settings are global and not per-WIM.
1204 * The default is to use the default @c malloc() and @c free() from the C
1207 * @param malloc_func
1208 * A function equivalent to @c malloc() that wimlib will use to allocate
1209 * memory. If @c NULL, the allocator function is set back to the default
1210 * @c malloc() from the C library.
1212 * A function equivalent to @c free() that wimlib will use to free memory.
1213 * If @c NULL, the free function is set back to the default @c free() from
1215 * @param realloc_func
1216 * A function equivalent to @c realloc() that wimlib will use to reallocate
1217 * memory. If @c NULL, the free function is set back to the default @c
1218 * realloc() from the C library.
1219 * @return 0 on success; nonzero on error.
1220 * @retval ::WIMLIB_ERR_UNSUPPORTED
1221 * wimlib was compiled with the @c --without-custom-memory-allocator flag,
1222 * so custom memory allocators are unsupported.
1224 int wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
1225 void (*free_func)(void *),
1226 void *(*realloc_func)(void *, size_t));
1229 * Sets whether wimlib is to print error messages to @c stderr when a function
1230 * fails or not. These error messages may provide information that cannot be
1231 * determined only from the error code that is returned.
1233 * This setting is global and not per-WIM.
1235 * By default, error messages are not printed.
1237 * @param show_messages
1238 * @c true if error messages are to be printed; @c false if error messages
1239 * are not to be printed.
1241 * @return 0 on success; nonzero on error.
1242 * @retval ::WIMLIB_ERR_UNSUPPORTED
1243 * @a show_messages was @c true, but wimlib was compiled with the @c
1244 * --without-error-messages option. Therefore, error messages cannot be
1247 extern int wimlib_set_print_errors(bool show_messages);
1250 * Splits a WIM into multiple parts.
1253 * Name of the WIM file to split. It must be a standalone, one-part WIM.
1255 * Name of the SWM file to create. This will be the name of the first
1256 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
1259 * The maximum size per part. It is not guaranteed that this will really
1260 * be the maximum size per part, because some file resources in the WIM may
1261 * be larger than this size, and the WIM file format provides no way to
1262 * split up file resources among multiple WIMs.
1264 * Bitwise OR of ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY and/or
1265 * ::WIMLIB_OPEN_FLAG_SHOW_PROGRESS.
1267 * @return 0 on success; nonzero on error. This function may return any value
1268 * returned by wimlib_open_wim() as well as the following error codes:
1270 * @retval ::WIMLIB_ERR_WRITE
1271 * An error occurred when trying to write data to one of the split WIMs.
1274 extern int wimlib_split(const char *wimfile, const char *swm_name,
1275 size_t part_size, int flags);
1278 * Unmounts a WIM image that was mounted using wimlib_mount().
1280 * Blocks until it is known whether the mount succeeded or failed.
1282 * To perform this operation, the process calling wimlib_unmount() communicates
1283 * with the process that had called wimlib_mount().
1285 * There is currently a design problem with this function because it is hard to
1286 * know whether the filesystem daemon is still working or whether it has
1287 * crashed, has been killed, or has reached an infinite loop. However, ideally
1288 * there should be no infinite loops or crashes in the code, so this wouldn't be
1289 * much of a problem. Currently, a timeout of 600 seconds (so long because WIMs
1290 * can be very large) is implemented so that this function will not wait forever
1291 * before returning failure.
1294 * The directory that the WIM image was mounted on.
1296 * Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY or
1297 * ::WIMLIB_UNMOUNT_FLAG_COMMIT. Neither of these flags affect read-only
1300 * @return 0 on success; nonzero on error.
1301 * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
1302 * The filesystem daemon was unable to remove the staging directory and the
1303 * temporary files that it contains.
1304 * @retval ::WIMLIB_ERR_FORK
1305 * Could not @c fork() the process.
1306 * @retval ::WIMLIB_ERR_FUSERMOUNT
1307 * The @b fusermount program could not be executed or exited with a failure
1309 * @retval ::WIMLIB_ERR_MQUEUE
1310 * Could not open a POSIX message queue to communicate with the filesystem
1311 * daemon servicing the mounted filesystem, could not send a message
1312 * through the queue, or could not receive a message through the queue.
1313 * @retval ::WIMLIB_ERR_NOMEM
1314 * Failed to allocate needed memory.
1315 * @retval ::WIMLIB_ERR_OPEN
1316 * The filesystem daemon could not open a temporary file for writing the
1318 * @retval ::WIMLIB_ERR_TIMEOUT
1319 * 600 seconds elapsed while waiting for the filesystem daemon to notify
1320 * the process of its exit status, so the WIM file probably was not written
1322 * @retval ::WIMLIB_ERR_READ
1323 * A read error occurred when the filesystem daemon tried to a file from
1324 * the staging directory
1325 * @retval ::WIMLIB_ERR_RENAME
1326 * The filesystem daemon failed to rename the newly written WIM file to the
1327 * original WIM file.
1328 * @retval ::WIMLIB_ERR_WRITE
1329 * A write error occurred when the filesystem daemon was writing to the new
1330 * WIM file, or the filesystem daemon was unable to flush changes that had
1331 * been made to files in the staging directory.
1333 extern int wimlib_unmount(const char *dir, int flags);
1336 * Writes the WIM to a file.
1339 * Pointer to the ::WIMStruct for a WIM file. There may have been
1340 * in-memory changes made to it, which are then reflected in the output
1343 * The path to the file to write the WIM to.
1345 * The image inside the WIM to write. Use ::WIM_ALL_IMAGES to include all
1348 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY and/or
1349 * ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS. If
1350 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY is given, an integrity table is
1351 * included in the WIM being written. If ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS
1352 * is given, the progress of the calculation of the integrity table is
1355 * @return 0 on success; nonzero on error.
1356 * @retval ::WIMLIB_ERR_DECOMPRESSION
1357 * Failed to decompress a metadata or file resource in @a wim.
1358 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1359 * A directory entry in the metadata resource for @a image in @a wim is
1361 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1362 * @a image does not specify a single existing image in @a wim, and is not
1364 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
1365 * A file that had previously been scanned for inclusion in the WIM by the
1366 * wimlib_add_image() or wimlib_add_image_from_ntfs_volume() functions was
1367 * concurrently modified, so it failed the SHA1 message digest check.
1368 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1369 * The metadata resource for @a image in @a wim is invalid.
1370 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1371 * The security data for @a image in @wim is invalid.
1372 * @retval ::WIMLIB_ERR_NOMEM
1373 * Failed to allocate needed memory.
1374 * @retval ::WIMLIB_ERR_OPEN
1375 * Failed to open @a path for writing, or some file resources in @a
1376 * wim refer to files in the outside filesystem, and one of these files
1377 * could not be opened for reading.
1378 * @retval ::WIMLIB_ERR_READ
1379 * An error occurred when trying to read data from the WIM file associated
1380 * with @a wim, or some file resources in @a wim refer to files in the
1381 * outside filesystem, and a read error occurred when reading one of these
1383 * @retval ::WIMLIB_ERR_WRITE
1384 * An error occurred when trying to write data to the new WIM file at @a
1387 extern int wimlib_write(WIMStruct *wim, const char *path, int image, int flags);
1391 #endif /* _WIMLIB_H */