4 * External header for wimlib.
6 * Copyright (C) 2012 Eric Biggers
8 * wimlib - Library for working with WIM files
10 * This library is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU Lesser General Public License as published by the Free
12 * Software Foundation; either version 2.1 of the License, or (at your option) any
15 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
16 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
17 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License along
20 * with this library; if not, write to the Free Software Foundation, Inc., 59
21 * Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 * \section intro Introduction
28 * wimlib is a C library to read, write, and mount archive files in the Windows
29 * Imaging Format (WIM files). These files are normally created using the @c
30 * imagex.exe utility on Windows, but this library provides a free
31 * implementetion of @c imagex for UNIX-based systems and an API to allow other
32 * programs to read, write, and mount WIM files. wimlib is comparable to
33 * Microsoft's WIMGAPI, but was designed independently and is not a clone of it.
35 * The main intended use of wimlib is to create customized images of Windows PE,
36 * the Windows Preinstallation Environment, without having to rely on Windows.
37 * Windows PE, which is the operating system that runs when you boot from the
38 * Windows Vista or Windows 7 DVD, is a lightweight version of Windows that can
39 * run entirely from memory. It can be used to install Windows from local media
40 * or a network drive or perform maintenance.
42 * You can find Windows PE on the installation media for Windows Vista, Windows
43 * 7, and Windows 8. The Windows PE image itself is a WIM file, @c
44 * sources/boot.wim, on the ISO filesystem. Windows PE can also be found in the
45 * Windows Automated Installation Kit (WAIK) inside the @c WinPE.cab file, which
46 * you can extract if you install the @c cabextract program.
48 * \section format WIM files
50 * A <b>Windows Imaging (WIM)</b> file is an archive. Like some other archive
51 * formats such as ZIP, files in WIM archives may be compressed. WIM archives
52 * support two Microsoft-specific compression formats: @b LZX and @b XPRESS.
53 * Both are based on LZ77 and Huffman encoding, and both are supported by
56 * Unlike ZIP files, WIM files can contain multiple independent toplevel
57 * directory trees known as @a images. While each image has its own metadata,
58 * files are not duplicated for each image; instead, each file is included only
59 * once in the entire WIM. Microsoft did this so that in one WIM file, they
60 * could do things like have 5 different versions of Windows that are almost
63 * WIM files may contain a integrity table. The integrity table, if it exists,
64 * is located at the end of the WIM file and contains SHA1 message digests of
65 * 10MB chunks of the WIM.
67 * Microsoft provides documentation for the WIM file format, XPRESS compression
68 * format, and LZX compression format. However, there are errors and omissions
69 * in some places in their documentation.
71 * \section starting Getting Started
73 * wimlib uses the GNU autotools, so it should be easy to install with
74 * <code>configure && make && sudo make install</code>, provided that you have
75 * @c libxml2 and @c libfuse installed. To use wimlib in a program after
76 * installing it, include @c wimlib.h and link your program with @c -lwim.
78 * wimlib wraps up a WIM file in an opaque ::WIMStruct structure.
80 * All functions in wimlib's public API are prefixed with @c wimlib. Most
81 * return an integer error code on failure. Use wimlib_get_error_string() to
82 * get a string that describes an error code. wimlib also can print error
83 * messages itself when an error happens, and these may be more informative than
84 * the error code; to enable this, call wimlib_set_print_errors().
86 * wimlib is thread-safe as long as different ::WIMStruct's are used, with the
87 * following exceptions: wimlib_set_print_errors() and
88 * wimlib_set_memory_allocator() apply globally, and wimlib_mount() can only be
89 * used by one ::WIMStruct at a time.
91 * To open an existing WIM, use wimlib_open_wim().
93 * To create a new WIM that initially contains no images, use
94 * wimlib_create_new_wim().
96 * To add an image to a WIM file from a directory tree on your filesystem, call
97 * wimlib_add_image(). This can be done with a ::WIMStruct gotten from
98 * wimlib_open_wim() or from wimlib_create_new_wim().
100 * To extract an image from a WIM file, call wimlib_set_output_dir() to set the
101 * output directory, then call wimlib_extract_image().
103 * wimlib supports mounting WIM files either read-only or read-write. Mounting
104 * is done using wimlib_mount() and unmounting is done using wimlib_unmount().
105 * Mounting can be done without root privileges because it is implemented using
106 * FUSE (Filesystem in Userspace). If wimlib is compiled with the
107 * <code>--without-fuse</code> flag, these functions will be available but will
110 * After creating or modifying a WIM file, you can write it to a file using
111 * wimlib_write(). Alternatively, if the WIM was originally read from a file,
112 * you can use wimlib_overwrite() to overwrite the original file. In some
113 * cases, wimlib_overwrite_xml_and_header() can be used instead.
115 * After you are done with the WIM file, use wimlib_free() to free all memory
116 * associated with a ::WIMStruct and close all files associated with it.
118 * To see an example of how to use wimlib, see the file
119 * @c programs/imagex.c in wimlib's source tree.
121 * wimlib supports custom memory allocators; use wimlib_set_memory_allocator()
124 * \section imagex imagex
126 * wimlib comes with the <b>imagex</b> program, which is documented in man pages.
128 * \section mkwinpeimg mkwinpeimg
130 * wimlib comes with the <b>mkwinpeimg</b> script, which is documented in a man
133 * \section Limitations
135 * While wimlib supports the main features of WIM files, wimlib currently has
136 * the following limitations:
137 * - wimlib does not support "security data", which describes the access rights
138 * of the files in the WIM. This data is very Windows-specific, and it would
139 * be difficult to do anything with it. Microsoft's software can still read a
140 * WIM without security data, including a boot.wim for Windows PE, but <b>do
141 * not expect to be able to use wimlib to image a Windows installation and
142 * preserve file attributes</b>.
143 * - There is no way to directly extract or mount split WIMs.
144 * - There is not yet any code to verify that there are no collisions between
145 * different files that happen to have the same SHA1 message digest.
146 * This is extremely unlikely, but could result in something bad such as a
147 * file going missing.
148 * - Alternate stream entries for directory entries are ignored.
149 * - Different versions of the WIM file format, if they even exist, are
150 * unsupported. Let me know if you notice WIM files with a different version.
151 * - Chunk sizes other than 32768 are unsupported (except for uncompressed WIMs,
152 * for which the chunk size field is ignored). As far as I can tell, other
153 * chunk sizes are not used in compressed WIMs. Let me know if you find a WIM
154 * file with a different chunk size.
155 * - wimlib does not provide a clone of the @b PEImg tool that allows you to
156 * make certain Windows-specific modifications to a Windows PE image, such as
157 * adding a driver or Windows component. Such a tool could conceivably be
158 * implemented on top of wimlib, although it likely would be hard to implement
159 * because it would have to do very Windows-specific things such as
160 * manipulating the driver store. wimlib does provide the @b mkwinpeimg
161 * script for a similar purpose, however. With regards to adding drivers to
162 * Windows PE, you have the option of putting them anywhere in the Windows PE
163 * image, then loading them after boot using @b drvload.exe.
164 * - There is not yet a way to extract specific files or directories from a WIM
165 * file without mounting it, or to add, remove, or modify files in a WIM
166 * without mounting it, other than by adding or removing an entire image. I
167 * can implement this if requested, but I intend the FUSE mount feature to be
168 * used for this purpose, as it is easy to do these things in whatever way you
169 * want after the image is mounted.
171 * Currently, Microsoft's @a image.exe can create slightly smaller WIM files
172 * than wimlib when using maximum (LZX) compression because it knows how to
173 * split up LZX compressed blocks, which is not yet implemented in wimlib.
175 * wimlib is experimental and likely contains bugs; use Microsoft's @a
176 * imagex.exe if you want to make sure your WIM files are made "correctly".
178 * \section legal License
180 * The wimlib library is licensed under the GNU Lesser General Public License
181 * version 2.1 or later.
183 * @b imagex and @b mkwinpeiso are licensed under the GNU General Public License
184 * version 3 or later.
194 #ifndef _WIMLIB_INTERNAL_H
196 * Opaque structure that represents a WIM file.
198 typedef struct WIMStruct WIMStruct;
202 * Specifies the way in which identical files are linked when extracting
203 * image(s) from the WIM.
206 /** Hard link identical files when extracting files from the WIM. */
207 WIM_LINK_TYPE_HARD = 0,
208 /** Symbolic link identical files when extracting files from the WIM. */
209 WIM_LINK_TYPE_SYMBOLIC = 1,
210 /** Do not create links when extracting identical files from the WIM (default).
212 WIM_LINK_TYPE_NONE = 2,
216 * Specifies the compression type of a WIM file.
219 enum wim_compression_type {
220 /** An invalid compression type. */
221 WIM_COMPRESSION_TYPE_INVALID = -1,
223 /** The WIM does not include any compressed resources. */
224 WIM_COMPRESSION_TYPE_NONE = 0,
226 /** Compressed resources in the WIM use LZX compression. */
227 WIM_COMPRESSION_TYPE_LZX = 1,
229 /** Compressed resources in the WIM use XPRESS compression. */
230 WIM_COMPRESSION_TYPE_XPRESS = 2,
233 /** Mount the WIM read-write. */
234 #define WIMLIB_MOUNT_FLAG_READWRITE 0x1
236 /** For debugging only. (This passes the @c -d flag to @c fuse_main()).*/
237 #define WIMLIB_MOUNT_FLAG_DEBUG 0x2
239 /** Include an integrity table in the new WIM being written during the unmount.
240 * Ignored for read-only mounts. */
241 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x1
243 /** Unless this flag is given, changes to a mounted WIM are discarded. Ignored
244 * for read-only mounts. */
245 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x2
247 /** Include an integrity table in the new WIM file. */
248 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x1
250 /** Print progress information when writing the integrity table. */
251 #define WIMLIB_WRITE_FLAG_SHOW_PROGRESS 0x2
253 /** Mark the image being added as the bootable image of the WIM. */
254 #define WIMLIB_ADD_IMAGE_FLAG_BOOT 0x1
256 /** See documentation for wimlib_export_image(). */
257 #define WIMLIB_EXPORT_FLAG_BOOT 0x1
259 /** Verify the integrity of the WIM if an integrity table is present. */
260 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x1
262 /** Print progress information when verifying integrity table. */
263 #define WIMLIB_OPEN_FLAG_SHOW_PROGRESS 0x2
265 /** If this flag is not given, an error is issued if the WIM is part of a split
267 #define WIMLIB_OPEN_FLAG_SPLIT_OK 0x4
270 * Possible values of the error code returned by many functions in wimlib.
272 * See the documentation for each wimlib function to see specifically what error
273 * codes can be returned by a given function, and what they mean.
275 enum wimlib_error_code {
276 WIMLIB_ERR_SUCCESS = 0,
277 WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE,
278 WIMLIB_ERR_DECOMPRESSION,
279 WIMLIB_ERR_DELETE_STAGING_DIR,
282 WIMLIB_ERR_FUSERMOUNT,
283 WIMLIB_ERR_IMAGE_COUNT,
284 WIMLIB_ERR_IMAGE_NAME_COLLISION,
285 WIMLIB_ERR_INTEGRITY,
286 WIMLIB_ERR_INVALID_CHUNK_SIZE,
287 WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
288 WIMLIB_ERR_INVALID_DENTRY,
289 WIMLIB_ERR_INVALID_HEADER_SIZE,
290 WIMLIB_ERR_INVALID_IMAGE,
291 WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
292 WIMLIB_ERR_INVALID_PARAM,
293 WIMLIB_ERR_INVALID_RESOURCE_SIZE,
299 WIMLIB_ERR_NOT_A_WIM_FILE,
300 WIMLIB_ERR_NO_FILENAME,
305 WIMLIB_ERR_SPLIT_INVALID,
306 WIMLIB_ERR_SPLIT_UNSUPPORTED,
309 WIMLIB_ERR_UNKNOWN_VERSION,
310 WIMLIB_ERR_UNSUPPORTED,
316 /** Used to indicate that no WIM image is currently selected. */
317 #define WIM_NO_IMAGE 0
319 /** Used to specify all images in the WIM. */
320 #define WIM_ALL_IMAGES (-1)
324 * Adds an image to a WIM file from a directory tree on disk.
326 * The directory tree is read immediately for the purpose of constructing a
327 * directory entry tree in-memory. Also, all files are read to calculate their
328 * SHA1 message digests. However, because the directory tree may contain a very
329 * large amount of data, the files themselves are not read into memory
330 * permanently, and instead references to their paths saved. This means that
331 * the directory tree must not be modified, other than by adding entirely new
332 * files or directories, before executing a call to wimlib_write() or
333 * wimlib_overwrite(). Otherwise, wimlib_write() may fail or incorrect files may
334 * be included in the WIM written by wimlib_write().
337 * Pointer to the ::WIMStruct for a WIM file to which the image will be
340 * A path to a directory in the outside filesystem. It will become the
341 * root directory for the WIM image.
343 * The name to give the image. This must be non-@c NULL.
345 * The description to give the image. This parameter may be left @c
346 * NULL, in which case no description is given to the image.
347 * @param flags_element
348 * What to put in the <FLAGS> element for the image's XML data. This
349 * parameter may be left @c NULL, in which case no <FLAGS> element is
350 * given to the image.
352 * If set to ::WIMLIB_ADD_IMAGE_FLAG_BOOT, change the image in @a wim
353 * marked as bootable to the one being added. Otherwise, leave the boot
356 * @return 0 on success; nonzero on error.
357 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
358 * There is already an image named @a name in @a w.
359 * @retval ::WIMLIB_ERR_INVALID_PARAM
360 * @a dir was @c NULL, @a name was @c NULL, or @a name was the empty string.
361 * @retval ::WIMLIB_ERR_NOMEM
362 * Failed to allocate needed memory.
363 * @retval ::WIMLIB_ERR_NOTDIR
364 * @a dir is not a directory.
365 * @retval ::WIMLIB_ERR_OPEN
366 * Failed to open a file or directory in the directory tree rooted at @a
368 * @retval ::WIMLIB_ERR_READ
369 * Failed to read a file in the directory tree rooted at @a dir.
370 * @retval ::WIMLIB_ERR_STAT
371 * Failed obtain the metadata for a file or directory in the directory tree
375 extern int wimlib_add_image(WIMStruct *wim, const char *dir,
376 const char *name, const char *description,
377 const char *flags_element, int flags);
380 * Creates a WIMStruct for a new WIM file.
383 * The type of compression to be used in the new WIM file. Must be
384 * ::WIM_COMPRESSION_TYPE_NONE, ::WIM_COMPRESSION_TYPE_LZX, or
385 * ::WIM_COMPRESSION_TYPE_XPRESS.
387 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
388 * written to the memory location pointed to by this paramater. The
389 * ::WIMStruct must be freed using using wimlib_free() when finished with
391 * @return 0 on success; nonzero on error.
392 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
393 * @a ctype was not ::WIM_COMPRESSION_TYPE_NONE,
394 * ::WIM_COMPRESSION_TYPE_LZX, or ::WIM_COMPRESSION_TYPE_XPRESS.
395 * @retval ::WIMLIB_ERR_NOMEM
396 * Failed to allocate needed memory.
398 extern int wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
401 * Deletes an image, or all images, from a WIM file.
403 * All file resources referenced by the image(s) being deleted are removed from
404 * the WIM if they are not referenced by any other images in the WIM.
407 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
410 * The number of the image to delete, or ::WIM_ALL_IMAGES to delete all
412 * @return 0 on success; nonzero on error.
413 * @retval ::WIMLIB_ERR_DECOMPRESSION
414 * Could not decompress the metadata resource for @a image.
415 * @retval ::WIMLIB_ERR_INVALID_DENTRY
416 * A directory entry in the metadata resource for @a image in the WIM is
418 * @retval ::WIMLIB_ERR_INVALID_IMAGE
419 * @a image does not exist in the WIM and is not ::WIM_ALL_IMAGES.
420 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
421 * The metadata resource for @a image in the WIM is invalid.
422 * @retval ::WIMLIB_ERR_NOMEM Failed to allocate needed memory.
423 * @retval ::WIMLIB_ERR_READ
424 * Could not read the metadata resource for @a image from the WIM.
426 extern int wimlib_delete_image(WIMStruct *wim, int image);
429 * Copies an image, or all the images, from a WIM file, into another WIM file.
432 * Pointer to the ::WIMStruct for a WIM file that contains the image(s)
435 * The image to export from @a src_wim. Can be the number of an image, or
436 * ::WIM_ALL_IMAGES to export all images.
438 * Pointer to the ::WIMStruct for a WIM filethat will receive the images being
441 * The name to give the exported image in the new WIM file. If left @c NULL,
442 * the name from @a src_wim is used. This parameter must be left @c NULL
443 * if @a src_image is ::WIM_ALL_IMAGES and @a src_wim contains more than one
444 * image; in that case, the names are all taken from the @a src_wim.
445 * @param dest_description
446 * The description to give the exported image in the new WIM file. If left
447 * @c NULL, the description from the @a src_wim is used. This parameter must
448 * be left @c NULL if @a src_image is ::WIM_ALL_IMAGES and @a src_wim contains
449 * more than one image; in that case, the descriptions are all taken from
452 * ::WIMLIB_EXPORT_FLAG_BOOT if the image being exported is to be made
453 * bootable, or 0 if which image is marked as bootable in the destination
454 * WIM is to be left unchanged. If @a src_image is ::WIM_ALL_IMAGES and
455 * there are multiple images in @a src_wim, specifying
456 * ::WIMLIB_EXPORT_FLAG_BOOT is valid only if one of the exported images is
457 * currently marked as bootable in @a src_wim; if that is the case, then
458 * that image is marked as bootable in the destination WIM.
460 * @return 0 on success; nonzero on error.
461 * @retval ::WIMLIB_ERR_DECOMPRESSION
462 * Could not decompress the metadata resource for @a src_image
464 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
465 * One or more of the names being given to an exported image was already in
466 * use in the destination WIM.
467 * @retval ::WIMLIB_ERR_INVALID_DENTRY
468 * A directory entry in the metadata resource for @a src_image in @a
469 * src_wim is invalid.
470 * @retval ::WIMLIB_ERR_INVALID_IMAGE
471 * @a src_image does not exist in @a src_wim.
472 * @retval ::WIMLIB_ERR_INVALID_PARAM
473 * ::WIMLIB_EXPORT_FLAG_BOOT was specified in @a flags, @a src_image was
474 * ::WIM_ALL_IMAGES, @a src_wim contains multiple images, and no images in
475 * @a src_wim are marked as bootable; or @a dest_name and/or @a
476 * dest_description were non-<code>NULL</code>, @a src_image was
477 * ::WIM_ALL_IMAGES, and @a src_wim contains multiple images.
478 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
479 * The metadata resource for @a src_image in @a src_wim is invalid.
480 * @retval ::WIMLIB_ERR_NOMEM
481 * Failed to allocate needed memory.
482 * @retval ::WIMLIB_ERR_READ
483 * Could not read the metadata resource for @a src_image from @a src_wim.
485 extern int wimlib_export_image(WIMStruct *src_wim, int src_image,
486 WIMStruct *dest_wim, const char *dest_name,
487 const char *dest_description, int flags);
490 * Extracts an image, or all images, from a WIM file.
492 * The output directory must have been previously set with
493 * wimlib_set_output_dir().
495 * The link type used for extracted files is that specified by a previous call
496 * to wimlib_set_link_type(), or ::WIM_LINK_TYPE_NONE by default.
499 * Pointer to the ::WIMStruct for a WIM file.
501 * The image to extract. Can be the number of an image, or ::WIM_ALL_IMAGES
502 * to specify that all images are to be extracted.
504 * @return 0 on success; nonzero on error.
505 * @retval ::WIMLIB_ERR_DECOMPRESSION
506 * Could not decompress a resource (file or metadata) for @a image in @a
508 * @retval ::WIMLIB_ERR_INVALID_DENTRY
509 * A directory entry in the metadata resource for @a image in @a wim is
511 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
512 * A resource (file or metadata) for @a image in @a wim is invalid.
513 * @retval ::WIMLIB_ERR_LINK
514 * Failed to create a symbolic link or a hard link.
515 * @retval ::WIMLIB_ERR_MKDIR
516 * Failed create a needed directory.
517 * @retval ::WIMLIB_ERR_NOMEM
518 * Failed to allocate needed memory.
519 * @retval ::WIMLIB_ERR_NOTDIR
520 * wimlib_set_output_dir() has not been successfully called on @a wim.
521 * @retval ::WIMLIB_ERR_OPEN
522 * Could not open one of the files being extracted for writing.
523 * @retval ::WIMLIB_ERR_READ
524 * A unexpected end-of-file or read error occurred when trying to read data
525 * from the WIM file associated with @a wim.
526 * @retval ::WIMLIB_ERR_WRITE
527 * Failed to write a file being extracted.
529 extern int wimlib_extract_image(WIMStruct *wim, int image);
532 * Extracts the XML data for a WIM file to a file stream. Every WIM file
533 * includes a string of XML that describes the images contained in the WIM.
536 * Pointer to the ::WIMStruct for a WIM file.
538 * @c stdout, or a FILE* opened for writing, to extract the data to.
540 * @return 0 on success; nonzero on error.
541 * @retval ::WIMLIB_ERR_WRITE
542 * Failed to completely write the XML data to @a fp.
544 extern int wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
547 * Frees all memory allocated for a WIMStruct and closes all files associated
551 * Pointer to the ::WIMStruct for a WIM file.
553 * @return This function has no return value.
555 extern void wimlib_free(WIMStruct *wim);
558 * Finds which image in a WIM is bootable.
561 * Pointer to the ::WIMStruct for a WIM file.
564 * 0 if no image is marked as bootable, or the number of the image marked
565 * as bootable (numbered starting at 1).
567 extern int wimlib_get_boot_idx(const WIMStruct *wim);
570 * Gets the compression type used in the WIM.
573 * Pointer to the ::WIMStruct for a WIM file
576 * ::WIM_COMPRESSION_TYPE_NONE, ::WIM_COMPRESSION_TYPE_LZX, or
577 * ::WIM_COMPRESSION_TYPE_XPRESS.
579 extern int wimlib_get_compression_type(const WIMStruct *wim);
582 * Converts a compression type enumeration value into a string.
585 * ::WIM_COMPRESSION_TYPE_NONE, ::WIM_COMPRESSION_TYPE_LZX,
586 * ::WIM_COMPRESSION_TYPE_XPRESS, or another value.
589 * A statically allocated string: "None", "LZX", "XPRESS", or "Invalid",
592 extern const char *wimlib_get_compression_type_string(int ctype);
595 * Converts an error code into a string describing it.
598 * The error code returned by one of wimlib's functions.
601 * Pointer to a statically allocated string describing the error code,
602 * or @c NULL if the error code is not valid.
604 extern const char *wimlib_get_error_string(enum wimlib_error_code code);
607 * Returns the description of the specified image.
610 * Pointer to the ::WIMStruct for a WIM file.
612 * The number of the image, numbered starting at 1.
615 * The description of the image, or @c NULL if there is no such image, or @c NULL
616 * if the specified image has no description.
618 extern const char *wimlib_get_image_description(const WIMStruct *wim, int image);
621 * Returns the name of the specified image.
624 * Pointer to the ::WIMStruct for a WIM file.
626 * The number of the image, numbered starting at 1.
629 * The name of the image, or @c NULL if there is no such image.
631 extern const char *wimlib_get_image_name(const WIMStruct *wim, int image);
635 * Gets the number of images contained in the WIM.
638 * Pointer to the ::WIMStruct for a WIM file.
641 * The number of images contained in the WIM file.
643 extern int wimlib_get_num_images(const WIMStruct *wim);
646 * Gets the part number of the wim (in a split WIM).
649 * Pointer to the ::WIMStruct for a WIM file.
650 * @param total_parts_ret
651 * If non-@c NULL, the total number of parts in the split WIM (1 for
652 * non-split WIMs) is written to this location.
655 * The part number of the WIM (1 for non-split WIMs)
657 extern int wimlib_get_part_number(const WIMStruct *wim, int *total_parts_ret);
660 * Returns true if the WIM has an integrity table.
663 * Pointer to the ::WIMStruct for a WIM file.
665 * @c true if the WIM has an integrity table; false otherwise.
667 extern bool wimlib_has_integrity_table(const WIMStruct *wim);
671 * Determines if an image name is already used by some image in the WIM.
674 * Pointer to the ::WIMStruct for a WIM file.
679 * @c true if there is already an image in @a wim named @a name; @c
680 * false if there is no image named @a name in @a wim.
682 extern bool wimlib_image_name_in_use(const WIMStruct *wim, const char *name);
685 * Joins a set of split WIMs into a one-part WIM.
688 * An array of strings that give the filenames of all parts of the split
691 * Number of filenames in @a swms.
693 * The path to write the one-part WIM to.
695 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY to check the split WIMs' integrity
696 * tables (if present) when opening them, and include an integrity table in
699 * @return 0 on success; nonzero on error. This function may return any value
700 * returned by wimlib_open_wim() except ::WIMLIB_ERR_SPLIT_UNSUPPORTED, as well
701 * as the following error codes:
703 * @retval ::WIMLIB_ERR_SPLIT_INVALID
704 * The split WIMs do not form a valid WIM because they do not include all
705 * the parts of the original WIM, there are duplicate parts, or not all the
706 * parts have the same GUID and compression type.
707 * @retval ::WIMLIB_ERR_WRITE
708 * An error occurred when trying to write data to the new WIM at @a output_path.
710 * Note that this function merely copies the resources, so it will not check to
711 * see if the resources, including the metadata resource, are valid or not.
713 extern int wimlib_join(const char **swms, int num_swms,
714 const char *output_path, int flags);
717 * Mounts an image in a WIM file on a directory read-only or read-write.
719 * A daemon will be forked to service the filesystem.
721 * If the mount is read-write, modifications to the WIM are staged in a staging
724 * wimlib_mount() currently cannot be used with multiple ::WIMStruct's without
725 * intervening wimlib_unmount()s. If there was a way to have libfuse pass a
726 * pointer to user data to each FUSE callback, then this would be possible, but
727 * there doesn't seem to be a way to do this currently.
730 * Pointer to the ::WIMStruct for the WIM file to be mounted.
732 * The number of the image to mount, numbered from 1. It must be an
733 * existing, single image.
735 * The path to an existing directory to mount the image on.
737 * Bitwise OR of the flags ::WIMLIB_MOUNT_FLAG_READWRITE or
738 * ::WIMLIB_MOUNT_FLAG_DEBUG. If ::WIMLIB_MOUNT_FLAG_READWRITE is not
739 * given, the WIM is mounted read-only.
741 * @return 0 on success; nonzero on error.
742 * @retval ::WIMLIB_ERR_DECOMPRESSION
743 * Could not decompress the metadata resource for @a image in @a wim.
744 * @retval ::WIMLIB_ERR_FUSE
745 * A non-zero status was returned by @c fuse_main().
746 * @retval ::WIMLIB_ERR_INVALID_DENTRY
747 * A directory entry in the metadata resource for @a image in @a wim is
749 * @retval ::WIMLIB_ERR_INVALID_IMAGE
750 * @a image does not specify an existing, single image in @a wim.
751 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
752 * The metadata resource for @a image in @a wim is invalid.
753 * @retval ::WIMLIB_ERR_MKDIR
754 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @a flags, but the staging
755 * directory could not be created.
756 * @retval ::WIMLIB_ERR_NOMEM
757 * Failed to allocate needed memory.
758 * @retval ::WIMLIB_ERR_NOTDIR
759 * Could not determine the current working directory.
760 * @retval ::WIMLIB_ERR_READ
761 * An unexpected end-of-file or read error occurred when trying to read
762 * data from the WIM file associated with @a wim.
765 extern int wimlib_mount(WIMStruct *wim, int image, const char *dir, int flags);
768 * Opens a WIM file and creates a ::WIMStruct for it.
771 * The path to the WIM file to open.
773 * Bitwise OR of ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY and/or
774 * ::WIMLIB_OPEN_FLAG_SHOW_PROGRESS.
775 * If ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is given, the integrity table
776 * of the WIM, if it exists, is checked, and the function will fail with an
777 * ::WIMLIB_ERR_INTEGRITY status if any of the computed SHA1 message
778 * digests of the WIM do not exactly match the corresponding message
779 * digests given in the integrity table.
780 * If ::WIMLIB_OPEN_FLAG_SHOW_PROGRESS is given, progress information will
781 * be shown if the integrity of the WIM is checked.
782 * If ::WIMLIB_OPEN_FLAG_SPLIT_OK is given, no error will be issued if the
783 * WIM is part of a split WIM. However, wimlib does not fully support
784 * split WIMs, so not all functions will work correctly after opening a
785 * split WIM. For example, you cannot use wimlib_mount() or
786 * wimlib_extract_image() on a split WIM.
789 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
790 * is written to the memory location pointed to by this parameter. The
791 * ::WIMStruct must be freed using using wimlib_free() when finished with
794 * @return 0 on success; nonzero on error.
795 * @retval ::WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE
796 * The lookup table of @a wim_file is compressed. Support for this can be
797 * added to wimlib if needed, but it appears to be the case that the lookup
798 * table is never compressed.
799 * @retval ::WIMLIB_ERR_IMAGE_COUNT
800 * The WIM is not the non-first part of a split WIM, and the number of
801 * metadata resources found in the WIM did not match the image count given
802 * in the WIM header, or the number of <IMAGE> elements in the XML
803 * data for the WIM did not match the image count given in the WIM header.
804 * @retval ::WIMLIB_ERR_INTEGRITY
805 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a flags and @a
806 * wim_file contains an integrity table, but the SHA1 message digest for a
807 * chunk of the WIM does not match the corresponding message digest given
808 * in the integrity table.
809 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
810 * Resources in @a wim_file are compressed, but the chunk size is not 32768.
811 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
812 * The header of @a wim_file says that resources in the WIM are compressed,
813 * but the header flag indicating LZX or XPRESS compression is not set.
814 * @retval ::WIMLIB_ERR_INVALID_HEADER_SIZE
815 * The length field of the WIM header is not 208.
816 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
817 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a flags and @a
818 * wim_file contains an integrity table, but the integrity table is
820 * @retval ::WIMLIB_ERR_NOMEM
821 * Failed to allocated needed memory.
822 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
823 * @a wim_file does not begin with the expected magic characters.
824 * @retval ::WIMLIB_ERR_OPEN
825 * Failed to open the file @a wim_file for reading.
826 * @retval ::WIMLIB_ERR_READ
827 * An unexpected end-of-file or read error occurred when trying to read
828 * data from @a wim_file.
829 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
830 * @a wim_file is a split WIM, but ::WIMLIB_OPEN_FLAG_SPLIT_OK was not
832 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
833 * A number other than 0x10d00 is written in the version field of the WIM
834 * header of @a wim_file.
835 * @retval ::WIMLIB_ERR_XML
836 * The XML data for @a wim_file is invalid.
838 extern int wimlib_open_wim(const char *wim_file, int flags,
839 WIMStruct **wim_ret);
842 * Overwrites the file that the WIM was originally read from, with changes made.
844 * The new WIM is written to a temporary file and then renamed to the original
845 * file after it is has been completely written. The temporary file currently
846 * is made in the same directory as the original WIM file.
848 * Note that it is not possible for this function to delete the original file
849 * before having written the new file because it is very likely that file
850 * resources in the new WIM file need to be retrieved from the old WIM file.
852 * After this function returns, @a wim must be freed using wimlib_free(). Any
853 * further actions on @a wim before doing this are undefined.
856 * Pointer to the ::WIMStruct for the WIM file to write. There may have
857 * been in-memory changes made to it, which are then reflected in the
860 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY and/or
861 * ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS.
863 * @return 0 on success; nonzero on error. This function may return any value
864 * returned by wimlib_write() as well as the following error codes:
865 * @retval ::WIMLIB_ERR_NO_FILENAME
866 * @a wim corresponds to a WIM created with wimlib_create_new_wim() rather
867 * than a WIM read with wimlib_open_wim().
868 * @retval ::WIMLIB_ERR_RENAME
869 * The temporary file that the WIM was written to could not be renamed to
870 * the original filename of @a wim.
872 extern int wimlib_overwrite(WIMStruct *wim, int flags);
875 * Updates the header and XML data of the WIM file, without the need to write
876 * out the entire WIM to a temporary file as in wimlib_write().
878 * This function must only be used if no files, directories, or images have been
879 * added, removed, or changed in the WIM. It must be used when only the boot
880 * index or the name or description of image(s) has been changed.
882 * After this function returns, @a wim must be freed using wimlib_free(). Any
883 * further actions on @a wim before doing this are undefined.
886 * Pointer to the ::WIMStruct for the WIM file to overwrite.
888 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY and/or
889 * ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS.
891 * @return 0 on success; nonzero on error.
893 * @retval ::WIMLIB_ERR_NO_FILENAME
894 * @a wim corresponds to a WIM created with wimlib_create_new_wim() rather
895 * than a WIM read with wimlib_open_wim().
896 * @retval ::WIMLIB_ERR_NOMEM
897 * Failed to allocate needed memory.
898 * @retval ::WIMLIB_ERR_OPEN
899 * The WIM file associated with @a wim could not be re-opened read-write.
900 * @retval ::WIMLIB_ERR_READ
901 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY was specified in @a flags, but data
902 * from the WIM file associated with @a wim could not be read to compute
903 * the SHA1 message digests, or the old integrity table (if it existed)
905 * @retval ::WIMLIB_ERR_WRITE
906 * Failed to write the WIM header, the XML data, or the integrity table to
907 * the WIM file associated with @a wim.
909 extern int wimlib_overwrite_xml_and_header(WIMStruct *wim, int flags);
912 * Prints information about one image, or all images, contained in a WIM.
915 * Pointer to the ::WIMStruct for a WIM file.
917 * The image about which to print information. Can be the number of an
918 * image, or ::WIM_ALL_IMAGES to print information about all images in the
921 * @return This function has no return value.
923 extern void wimlib_print_available_images(const WIMStruct *wim, int image);
926 * Prints the full paths to all files contained in an image, or all images, in a
930 * Pointer to the ::WIMStruct for a WIM file.
932 * Which image to print files for. Can be the number of an image, or
933 * ::WIM_ALL_IMAGES to print the files contained in all images.
935 * @return 0 on success; nonzero on error.
936 * @retval ::WIMLIB_ERR_DECOMPRESSION
937 * The metadata resource for one of the specified images could not be
939 * @retval ::WIMLIB_ERR_INVALID_DENTRY
940 * A directory entry in the metadata resource for one of the specified
942 * @retval ::WIMLIB_ERR_INVALID_IMAGE
943 * @a image does not specify a valid image in @a wim, and is not
945 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
946 * The metadata resource for one of the specified images is invalid.
947 * @retval ::WIMLIB_ERR_NOMEM
948 * Failed to allocate needed memory.
949 * @retval ::WIMLIB_ERR_READ
950 * An unexpected read error or end-of-file occurred when reading the
951 * metadata resource for one of the specified images.
953 extern int wimlib_print_files(WIMStruct *wim, int image);
956 * Prints detailed information from the header of a WIM file.
959 * Pointer to the ::WIMStruct for a WIM file.
961 * @return This function has no return value.
964 extern void wimlib_print_header(const WIMStruct *wim);
967 * Prints the lookup table of a WIM file. The lookup table maps SHA1 message
968 * digests, as found in the directory entry tree in the WIM file, to file
969 * resources in the WIM file. This table includes one entry for each unique
970 * file in the WIM, so it can be quite long. There is only one lookup table per
974 * Pointer to the ::WIMStruct for a WIM file.
976 * @return This function has no return value.
978 extern void wimlib_print_lookup_table(WIMStruct *wim);
981 * Prints the metadata of the specified image in a WIM file. The metadata
982 * consists of the security data as well as the directory entry tree, and each
983 * image has its own metadata.
986 * Pointer to the ::WIMStruct for a WIM file.
988 * Which image to print the metadata for. Can be the number of an image,
989 * or ::WIM_ALL_IMAGES to print the metadata for all images in the WIM.
991 * @return 0 on success; nonzero on error.
992 * @retval ::WIMLIB_ERR_DECOMPRESSION
993 * The metadata resource for one of the specified images could not be
995 * @retval ::WIMLIB_ERR_INVALID_DENTRY
996 * A directory entry in the metadata resource for one of the specified
998 * @retval ::WIMLIB_ERR_INVALID_IMAGE
999 * @a image does not specify a valid image in @a wim, and is not
1001 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1002 * The metadata resource for one of the specified images is invalid.
1003 * @retval ::WIMLIB_ERR_NOMEM
1004 * Failed to allocate needed memory.
1005 * @retval ::WIMLIB_ERR_READ
1006 * An unexpected read error or end-of-file occurred when reading the
1007 * metadata resource for one of the specified images.
1009 extern int wimlib_print_metadata(WIMStruct *wim, int image);
1012 * Prints some basic information about a WIM file. All information printed by
1013 * this function is also printed by wimlib_print_header(), but
1014 * wimlib_print_wim_information() prints some of this information more concisely
1015 * and in a more readable form.
1018 * Pointer to the ::WIMStruct for a WIM file.
1020 * @return This function has no return value.
1022 extern void wimlib_print_wim_information(const WIMStruct *wim);
1025 * Translates a string specifying the name or number of an image in the WIM into
1026 * the number of the image. The images are numbered starting at 1.
1029 * Pointer to the ::WIMStruct for a WIM file.
1030 * @param image_name_or_num
1031 * A string specifying which image. If it begins with a number, it is
1032 * taken to be a string specifying the image number. Otherwise, it is
1033 * taken to be the name of an image, as specified in the XML data for the
1034 * WIM file. It also may be the keyword "all", which will resolve to
1038 * If the string resolved to a single existing image, the number of that
1039 * image, counting starting at 1, is returned. If the keyword "all" was
1040 * specified, ::WIM_ALL_IMAGES is returned. Otherwise, ::WIM_NO_IMAGE is
1043 extern int wimlib_resolve_image(WIMStruct *wim, const char *image_name_or_num);
1046 * Sets which image in the WIM is marked as bootable.
1049 * Pointer to the ::WIMStruct for a WIM file.
1051 * The number of the image to mark as bootable, or 0 to mark no image as
1053 * @return 0 on success; nonzero on error.
1054 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1055 * @a boot_idx does not specify an existing image in @a wim, and it was not
1058 extern int wimlib_set_boot_idx(WIMStruct *wim, int boot_idx);
1061 * Changes the description of an image in the WIM.
1064 * Pointer to the ::WIMStruct for a WIM file.
1066 * The number of the image for which to change the description.
1067 * @param description
1068 * The new description to give the image. It may be @c NULL, which
1069 * indicates that the image is to be given no description.
1071 * @return 0 on success; nonzero on error.
1072 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1073 * @a image does not specify a single existing image in @a wim.
1074 * @retval ::WIMLIB_ERR_NOMEM
1075 * Failed to allocate the memory needed to duplicate the @a description
1078 extern int wimlib_set_image_descripton(WIMStruct *wim, int image,
1079 const char *description);
1082 * Changes the name of an image in the WIM.
1085 * Pointer to the ::WIMStruct for a WIM file.
1087 * The number of the image for which to change the name.
1089 * The new name to give the image. It must not be @c NULL.
1091 * @return 0 on success; nonzero on error.
1092 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1093 * There is already an image named @a name in @a wim.
1094 * @retval ::WIMLIB_ERR_INVALID_PARAM
1095 * @a name was @c NULL or the empty string.
1096 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1097 * @a image does not specify a single existing image in @a wim.
1098 * @retval ::WIMLIB_ERR_NOMEM
1099 * Failed to allocate the memory needed to duplicate the @a name string.
1101 extern int wimlib_set_image_name(WIMStruct *wim, int image, const char *name);
1104 * Sets the link type to use when extracting files from a WIM. This applies
1105 * when extracting one image as well as when extracting all images. Cross-image
1106 * links may save a lot of space because it is common for files to be referenced
1107 * multiple times in WIM files. By default, the link type used for extraction
1108 * is ::WIM_LINK_TYPE_NONE, meaning that links are not created.
1111 * Pointer to the ::WIMStruct for a WIM file
1113 * ::WIM_LINK_TYPE_NONE, ::WIM_LINK_TYPE_SYMBOLIC, or ::WIM_LINK_TYPE_HARD.
1115 * @return 0 on success; nonzero on error.
1116 * @retval ::WIMLIB_ERR_INVALID_PARAM
1117 * @a link_type was not ::WIM_LINK_TYPE_NONE, ::WIM_LINK_TYPE_SYMBOLIC,
1118 * or ::WIM_LINK_TYPE_HARD.
1120 extern int wimlib_set_link_type(WIMStruct *wim, int link_type);
1123 * Set the functions that wimlib uses to allocate and free memory.
1125 * These settings are global and not per-WIM.
1127 * The default is to use the default @c malloc() and @c free() from the C
1130 * @param malloc_func
1131 * A function equivalent to @c malloc() that wimlib will use to allocate
1132 * memory. If @c NULL, the allocator function is set back to the default
1133 * @c malloc() from the C library.
1135 * A function equivalent to @c free() that wimlib will use to free memory.
1136 * If @c NULL, the free function is set back to the default @c free() from
1138 * @param realloc_func
1139 * A function equivalent to @c realloc() that wimlib will use to reallocate
1140 * memory. If @c NULL, the free function is set back to the default @c
1141 * realloc() from the C library.
1142 * @return 0 on success; nonzero on error.
1143 * @retval ::WIMLIB_ERR_UNSUPPORTED
1144 * wimlib was compiled with the @c --without-custom-memory-allocator flag,
1145 * so custom memory allocators are unsupported.
1147 int wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
1148 void (*free_func)(void *),
1149 void *(*realloc_func)(void *, size_t));
1152 * Sets whether wimlib is to print error messages to @c stderr when a function
1153 * fails or not. These error messages may provide information that cannot be
1154 * determined only from the error code that is returned.
1156 * This setting is global and not per-WIM.
1158 * By default, error messages are not printed.
1160 * @param show_messages
1161 * @c true if error messages are to be printed; @c false if error messages
1162 * are not to be printed.
1164 * @return 0 on success; nonzero on error.
1165 * @retval ::WIMLIB_ERR_UNSUPPORTED
1166 * @a show_messages was @c true, but wimlib was compiled with the @c
1167 * --without-error-messages option. Therefore, error messages cannot be
1170 extern int wimlib_set_print_errors(bool show_messages);
1173 * Sets whether wimlib is to be verbose when extracting files from a WIM or when
1174 * creating an image from a directory (i.e. whether it will print all affected
1175 * files or not.) This is a per-WIM parameter.
1178 * Pointer to the ::WIMStruct for the WIM file.
1180 * Whether wimlib is to be verbose when extracting files from @a wim using
1181 * wimlib_extract_image() or when adding an image to @a wim using
1182 * wimlib_add_image().
1184 * @return This function has no return value.
1186 extern void wimlib_set_verbose(WIMStruct *wim, bool verbose);
1189 * Sets and creates the directory to which files are to be extracted when
1190 * extracting files from the WIM.
1193 * Pointer to the ::WIMStruct for the WIM file.
1195 * The name of the directory to extract files to.
1197 * @return 0 on success; nonzero on error.
1198 * @retval ::WIMLIB_ERR_INVALID_PARAM
1199 * @a dir was @c NULL.
1200 * @retval ::WIMLIB_ERR_MKDIR
1201 * @a dir does not already exist and it could not created.
1202 * @retval ::WIMLIB_ERR_NOMEM
1203 * Failed to allocate the memory needed to duplicate the @a dir string.
1205 extern int wimlib_set_output_dir(WIMStruct *wim, const char *dir);
1208 * Splits a WIM into multiple parts.
1211 * Name of the WIM file to split. It must be a standalone, one-part WIM.
1213 * Name of the SWM file to create. This will be the name of the first
1214 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
1217 * The maximum size per part. It is not guaranteed that this will really
1218 * be the maximum size per part, because some file resources in the WIM may
1219 * be larger than this size, and the WIM file format provides no way to
1220 * split up file resources among multiple WIMs.
1222 * Bitwise OR of ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY and/or
1223 * ::WIMLIB_OPEN_FLAG_SHOW_PROGRESS.
1225 * @return 0 on success; nonzero on error. This function may return any value
1226 * returned by wimlib_open_wim() as well as the following error codes:
1228 * @retval ::WIMLIB_ERR_WRITE
1229 * An error occurred when trying to write data to one of the split WIMs.
1232 extern int wimlib_split(const char *wimfile, const char *swm_name,
1233 size_t part_size, int flags);
1236 * Unmounts a WIM image that was mounted using wimlib_mount().
1238 * Blocks until it is known whether the mount succeeded or failed.
1240 * To perform this operation, the process calling wimlib_unmount() communicates
1241 * with the process that had called wimlib_mount().
1243 * There is currently a design problem with this function because it is hard to
1244 * know whether the filesystem daemon is still working or whether it has
1245 * crashed, has been killed, or has reached an infinite loop. However, ideally
1246 * there should be no infinite loops or crashes in the code, so this wouldn't be
1247 * much of a problem. Currently, a timeout of 600 seconds (so long because WIMs
1248 * can be very large) is implemented so that this function will not wait forever
1249 * before returning failure.
1252 * The directory that the WIM image was mounted on.
1254 * Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY or
1255 * ::WIMLIB_UNMOUNT_FLAG_COMMIT. Neither of these flags affect read-only
1258 * @return 0 on success; nonzero on error.
1259 * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
1260 * The filesystem daemon was unable to remove the staging directory and the
1261 * temporary files that it contains.
1262 * @retval ::WIMLIB_ERR_FORK
1263 * Could not @c fork() the process.
1264 * @retval ::WIMLIB_ERR_FUSERMOUNT
1265 * The @b fusermount program could not be executed or exited with a failure
1267 * @retval ::WIMLIB_ERR_MQUEUE
1268 * Could not open a POSIX message queue to communicate with the filesystem
1269 * daemon servicing the mounted filesystem, could not send a message
1270 * through the queue, or could not receive a message through the queue.
1271 * @retval ::WIMLIB_ERR_NOMEM
1272 * Failed to allocate needed memory.
1273 * @retval ::WIMLIB_ERR_OPEN
1274 * The filesystem daemon could not open a temporary file for writing the
1276 * @retval ::WIMLIB_ERR_TIMEOUT
1277 * 600 seconds elapsed while waiting for the filesystem daemon to notify
1278 * the process of its exit status, so the WIM file probably was not written
1280 * @retval ::WIMLIB_ERR_READ
1281 * A read error occurred when the filesystem daemon tried to a file from
1282 * the staging directory
1283 * @retval ::WIMLIB_ERR_RENAME
1284 * The filesystem daemon failed to rename the newly written WIM file to the
1285 * original WIM file.
1286 * @retval ::WIMLIB_ERR_WRITE
1287 * A write error occurred when the filesystem daemon was writing to the new
1288 * WIM file, or the filesystem daemon was unable to flush changes that had
1289 * been made to files in the staging directory.
1291 extern int wimlib_unmount(const char *dir, int flags);
1294 * Writes the WIM to a file.
1297 * Pointer to the ::WIMStruct for a WIM file. There may have been
1298 * in-memory changes made to it, which are then reflected in the output
1301 * The path to the file to write the WIM to.
1303 * The image inside the WIM to write. Use ::WIM_ALL_IMAGES to include all
1306 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY and/or
1307 * ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS. If
1308 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY is given, an integrity table is
1309 * included in the WIM being written. If ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS
1310 * is given, the progress of the calculation of the integrity table is
1313 * @return 0 on success; nonzero on error.
1314 * @retval ::WIMLIB_ERR_DECOMPRESSION
1315 * Failed to decompress a metadata or file resource in @a wim.
1316 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1317 * A directory entry in the metadata resource for @a image in @a wim is
1319 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1320 * @a image does not specify a single existing image in @a wim, and is not
1322 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1323 * The metadata resource for @a image in @a wim is invalid.
1324 * @retval ::WIMLIB_ERR_NOMEM
1325 * Failed to allocate needed memory.
1326 * @retval ::WIMLIB_ERR_OPEN
1327 * Failed to open @a path for writing, or some file resources in @a
1328 * wim refer to files in the outside filesystem, and one of these files
1329 * could not be opened for reading.
1330 * @retval ::WIMLIB_ERR_READ
1331 * An error occurred when trying to read data from the WIM file associated
1332 * with @a wim, or some file resources in @a wim refer to files in the
1333 * outside filesystem, and a read error occurred when reading one of these
1335 * @retval ::WIMLIB_ERR_WRITE
1336 * An error occurred when trying to write data to the new WIM file at @a
1339 extern int wimlib_write(WIMStruct *wim, const char *path, int image, int flags);
1343 #endif /* _WIMLIB_H */