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. A ::WIMStruct
99 * may represent either a stand-alone WIM or one part of a split WIM.
101 * All functions in wimlib's public API are prefixed with @c wimlib. Most
102 * return an integer error code on failure. Use wimlib_get_error_string() to
103 * get a string that describes an error code. wimlib also can print error
104 * messages itself when an error happens, and these may be more informative than
105 * the error code; to enable this, call wimlib_set_print_errors(). Please note
106 * that this is for convenience only, and some errors can occur without a
107 * message being printed.
109 * wimlib is thread-safe as long as different ::WIMStruct's are used, with the
110 * following exceptions: wimlib_set_print_errors() and
111 * wimlib_set_memory_allocator() apply globally, and wimlib_mount() can only be
112 * used by one ::WIMStruct at a time.
114 * To open an existing WIM, use wimlib_open_wim().
116 * To create a new WIM that initially contains no images, use
117 * wimlib_create_new_wim().
119 * To add an image to a WIM file from a directory tree on your filesystem, call
120 * wimlib_add_image(). This can be done with a ::WIMStruct gotten from
121 * wimlib_open_wim() or from wimlib_create_new_wim(). Alternatively, if you
122 * want to capture a WIM image directly from a NTFS volume while preserving
123 * NTFS-specific data such as security descriptors, call
124 * wimlib_add_image_from_ntfs_volume() instead.
126 * To extract an image from a WIM file, call wimlib_extract_image().
127 * Alternatively, if you want to apply a WIM image directly to a NTFS volume
128 * while setting NTFS-specific data such as security descriptors, call
129 * wimlib_apply_image_to_ntfs_volume().
131 * The NTFS functions will fail if wimlib was compiled with the
132 * <code>--without-ntfs-3g</code> flag.
134 * wimlib supports mounting WIM files either read-only or read-write. Mounting
135 * is done using wimlib_mount() and unmounting is done using wimlib_unmount().
136 * Mounting can be done without root privileges because it is implemented using
137 * FUSE (Filesystem in Userspace). If wimlib is compiled with the
138 * <code>--without-fuse</code> flag, these functions will be available but will
141 * After creating or modifying a WIM file, you can write it to a file using
142 * wimlib_write(). Alternatively, if the WIM was originally read from a file,
143 * you can use wimlib_overwrite() to overwrite the original file. In some
144 * cases, wimlib_overwrite_xml_and_header() can be used instead.
146 * After you are done with the WIM file, use wimlib_free() to free all memory
147 * associated with a ::WIMStruct and close all files associated with it.
149 * To see an example of how to use wimlib, see the file
150 * @c programs/imagex.c in wimlib's source tree.
152 * wimlib supports custom memory allocators; use wimlib_set_memory_allocator()
153 * for this. However, if wimlib calls into @c libntfs-3g, the custom memory
154 * allocator may not be used.
156 * \section imagex imagex
158 * wimlib comes with the <b>imagex</b> program, which is documented in man pages.
160 * \section mkwinpeimg mkwinpeimg
162 * wimlib comes with the <b>mkwinpeimg</b> script, which is documented in a man
165 * \section Limitations
167 * While wimlib supports the main features of WIM files, wimlib currently has
168 * the following limitations:
169 * - Different versions of the WIM file format are unsupported. There is one
170 * different version of the format from development versions of Windows Vista,
171 * but I'm not planning to support it.
172 * - Compressed resource chunk sizes other than 32768 are unsupported (except for
173 * uncompressed WIMs, for which the chunk size field is ignored). As far as I
174 * can tell, other chunk sizes are not used in compressed WIMs. Let me know
175 * if you find a WIM file with a different chunk size.
176 * - wimlib does not provide a clone of the @b PEImg tool that allows you to
177 * make certain Windows-specific modifications to a Windows PE image, such as
178 * adding a driver or Windows component. Such a tool could conceivably be
179 * implemented on top of wimlib, although it likely would be hard to implement
180 * because it would have to do very Windows-specific things such as
181 * manipulating the driver store. wimlib does provide the @b mkwinpeimg
182 * script for a similar purpose, however. With regards to adding drivers to
183 * Windows PE, you have the option of putting them anywhere in the Windows PE
184 * image, then loading them after boot using @b drvload.exe.
185 * - There is not yet a way to extract specific files or directories from a WIM
186 * file without mounting it, or to add, remove, or modify files in a WIM
187 * without mounting it, other than by adding or removing an entire image. I
188 * can implement this if requested, but I intend the FUSE mount feature to be
189 * used for this purpose, as it is easy to do these things in whatever way you
190 * want after the image is mounted.
191 * - Currently, Microsoft's @a image.exe can create slightly smaller WIM files
192 * than wimlib when using maximum (LZX) compression because it knows how to
193 * split up LZX compressed blocks, which is not yet implemented in wimlib.
194 * - wimlib is experimental and likely contains bugs; use Microsoft's @a
195 * imagex.exe if you want to make sure your WIM files are made "correctly".
197 * \section legal License
199 * The wimlib library, as well as the programs and scripts distributed with it
200 * (@b imagex and @b mkwinpeimg), is licensed under the GNU General Public
201 * License version 3 or later.
211 #ifndef _WIMLIB_INTERNAL_H
213 * Opaque structure that represents a WIM file.
215 typedef struct WIMStruct WIMStruct;
219 * Specifies the compression type of a WIM file.
222 enum wim_compression_type {
223 /** An invalid compression type. */
224 WIM_COMPRESSION_TYPE_INVALID = -1,
226 /** The WIM does not include any compressed resources. */
227 WIM_COMPRESSION_TYPE_NONE = 0,
229 /** Compressed resources in the WIM use LZX compression. */
230 WIM_COMPRESSION_TYPE_LZX = 1,
232 /** Compressed resources in the WIM use XPRESS compression. */
233 WIM_COMPRESSION_TYPE_XPRESS = 2,
236 /** Mount the WIM read-write. */
237 #define WIMLIB_MOUNT_FLAG_READWRITE 0x00000001
239 /** For debugging only. (This passes the @c -d flag to @c fuse_main()).*/
240 #define WIMLIB_MOUNT_FLAG_DEBUG 0x00000002
242 /** Do not allow accessing alternate data streams. */
243 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE 0x00000010
245 /** Access alternate data streams through extended file attributes. This is the
247 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR 0x00000020
249 /** Access alternate data streams by specifying the file name, a colon, then the
250 * alternate file stream name. */
251 #define WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS 0x00000040
253 /** Include an integrity table in the new WIM being written during the unmount.
254 * Ignored for read-only mounts. */
255 #define WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY 0x00000001
257 /** Unless this flag is given, changes to a mounted WIM are discarded. Ignored
258 * for read-only mounts. */
259 #define WIMLIB_UNMOUNT_FLAG_COMMIT 0x00000002
261 /** Include an integrity table in the new WIM file. */
262 #define WIMLIB_WRITE_FLAG_CHECK_INTEGRITY 0x00000001
264 /** Print progress information when writing the integrity table. */
265 #define WIMLIB_WRITE_FLAG_SHOW_PROGRESS 0x00000002
267 /** Print file paths as we write then */
268 #define WIMLIB_WRITE_FLAG_VERBOSE 0x00000004
270 /** Mark the image being added as the bootable image of the WIM. */
271 #define WIMLIB_ADD_IMAGE_FLAG_BOOT 0x00000001
273 /** Print the name of each file or directory as it is scanned to be included in
275 #define WIMLIB_ADD_IMAGE_FLAG_VERBOSE 0x00000002
277 /** Follow symlinks; archive and dump the files they point to. */
278 #define WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE 0x00000004
280 /** See documentation for wimlib_export_image(). */
281 #define WIMLIB_EXPORT_FLAG_BOOT 0x00000001
283 /** Verify the integrity of the WIM if an integrity table is present. */
284 #define WIMLIB_OPEN_FLAG_CHECK_INTEGRITY 0x00000001
286 /** Print progress information when verifying integrity table. */
287 #define WIMLIB_OPEN_FLAG_SHOW_PROGRESS 0x00000002
289 /** If this flag is not given, an error is issued if the WIM is part of a split
291 #define WIMLIB_OPEN_FLAG_SPLIT_OK 0x00000004
294 /** When identical files are extracted from the WIM, always hard link them
296 #define WIMLIB_EXTRACT_FLAG_HARDLINK 0x00000001
298 /** When identical files are extracted from the WIM, always symlink them
300 #define WIMLIB_EXTRACT_FLAG_SYMLINK 0x00000002
302 /** Print the name of each file as it is extracted from the WIM image. */
303 #define WIMLIB_EXTRACT_FLAG_VERBOSE 0x00000008
306 * Possible values of the error code returned by many functions in wimlib.
308 * See the documentation for each wimlib function to see specifically what error
309 * codes can be returned by a given function, and what they mean.
311 enum wimlib_error_code {
312 WIMLIB_ERR_SUCCESS = 0,
313 WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE,
314 WIMLIB_ERR_DECOMPRESSION,
315 WIMLIB_ERR_DELETE_STAGING_DIR,
318 WIMLIB_ERR_FUSERMOUNT,
319 WIMLIB_ERR_IMAGE_COUNT,
320 WIMLIB_ERR_IMAGE_NAME_COLLISION,
321 WIMLIB_ERR_INTEGRITY,
322 WIMLIB_ERR_INVALID_CAPTURE_CONFIG,
323 WIMLIB_ERR_INVALID_CHUNK_SIZE,
324 WIMLIB_ERR_INVALID_COMPRESSION_TYPE,
325 WIMLIB_ERR_INVALID_DENTRY,
326 WIMLIB_ERR_INVALID_HEADER_SIZE,
327 WIMLIB_ERR_INVALID_IMAGE,
328 WIMLIB_ERR_INVALID_INTEGRITY_TABLE,
329 WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY,
330 WIMLIB_ERR_INVALID_PARAM,
331 WIMLIB_ERR_INVALID_RESOURCE_HASH,
332 WIMLIB_ERR_INVALID_RESOURCE_SIZE,
333 WIMLIB_ERR_INVALID_SECURITY_DATA,
339 WIMLIB_ERR_NOT_A_WIM_FILE,
340 WIMLIB_ERR_NO_FILENAME,
347 WIMLIB_ERR_SPECIAL_FILE,
348 WIMLIB_ERR_SPLIT_INVALID,
349 WIMLIB_ERR_SPLIT_UNSUPPORTED,
352 WIMLIB_ERR_UNKNOWN_VERSION,
353 WIMLIB_ERR_UNSUPPORTED,
359 /** Used to indicate that no WIM image is currently selected. */
360 #define WIM_NO_IMAGE 0
362 /** Used to specify all images in the WIM. */
363 #define WIM_ALL_IMAGES (-1)
367 * Adds an image to a WIM file from a directory tree on disk.
369 * The directory tree is read immediately for the purpose of constructing a
370 * directory entry tree in-memory. Also, all files are read to calculate their
371 * SHA1 message digests. However, because the directory tree may contain a very
372 * large amount of data, the files themselves are not read into memory
373 * permanently, and instead references to their paths saved. The files are then
374 * read on-demand if wimlib_write() or wimlib_overwrite() is called.
377 * Pointer to the ::WIMStruct for a WIM file to which the image will be
380 * A path to a directory in the outside filesystem. It will become the
381 * root directory for the WIM image.
383 * The name to give the image. This must be non-@c NULL.
385 * Pointer to the contents of an image capture configuration file. If @c
386 * NULL, a default string is used. Please see the manual page for
387 * <b>imagex capture</b> for more information.
389 * Length of the string @a config in bytes.
392 * Bitwise OR of flags prefixed with WIMLIB_ADD_IMAGE_FLAG. If
393 * ::WIMLIB_ADD_IMAGE_FLAG_BOOT is specified, the image in @a wim that is
394 * marked as bootable is changed to the one being added. If
395 * ::WIMLIB_ADD_IMAGE_FLAG_VERBOSE is specified, the name of each file is
396 * printed as it is scanned or captured. If
397 * ::WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE is specified, the files or
398 * directories pointed to by symbolic links are archived rather than the
399 * symbolic links themselves.
401 * @return 0 on success; nonzero on error. On error, changes to @a wim are
402 * discarded so that it appears to be in the same state as when this function
405 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
406 * There is already an image named @a name in @a w.
407 * @retval ::WIMLIB_ERR_INVALID_PARAM
408 * @a dir was @c NULL, @a name was @c NULL, or @a name was the empty string.
409 * @retval ::WIMLIB_ERR_NOMEM
410 * Failed to allocate needed memory.
411 * @retval ::WIMLIB_ERR_NOTDIR
412 * @a dir is not a directory.
413 * @retval ::WIMLIB_ERR_OPEN
414 * Failed to open a file or directory in the directory tree rooted at @a
416 * @retval ::WIMLIB_ERR_READ
417 * Failed to read a file in the directory tree rooted at @a dir.
418 * @retval ::WIMLIB_ERR_STAT
419 * Failed obtain the metadata for a file or directory in the directory tree
421 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
422 * @a wim is part of a split WIM. Adding an image to a split WIM is
425 extern int wimlib_add_image(WIMStruct *wim, const char *dir,
426 const char *name, const char *config,
427 size_t config_len, int flags);
430 * This function is similar to wimlib_add_image(), except instead of capturing
431 * the WIM image from a directory, it is captured from a NTFS volume specified
432 * by @a device. NTFS-3g errors are reported as ::WIMLIB_ERR_NTFS_3G.
433 * ::WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE may not be specified because we capture
434 * the reparse points exactly as they are.
436 extern int wimlib_add_image_from_ntfs_volume(WIMStruct *w, const char *device,
443 * This function is similar to wimlib_extract_image(), except that @a image may
444 * not be ::WIM_ALL_IMAGES, and @a device specifies the name of a file or block
445 * device containing a NTFS volume to apply the image to. NTFS-3g errors are
446 * reported as ::WIMLIB_ERR_NTFS_3G, and ::WIMLIB_EXTRACT_FLAG_HARDLINK or
447 * ::WIMLIB_EXTRACT_FLAG_SYMLINK may not be specified because in the NTFS
448 * apply mode we apply the reparse points and hard links exactly as they are in
451 extern int wimlib_apply_image_to_ntfs_volume(WIMStruct *w, int image,
452 const char *device, int flags,
453 WIMStruct **additional_swms,
454 unsigned num_additional_swms);
457 * Creates a WIMStruct for a new WIM file.
460 * The type of compression to be used in the new WIM file. Must be
461 * ::WIM_COMPRESSION_TYPE_NONE, ::WIM_COMPRESSION_TYPE_LZX, or
462 * ::WIM_COMPRESSION_TYPE_XPRESS.
464 * On success, a pointer to an opaque ::WIMStruct for the new WIM file is
465 * written to the memory location pointed to by this paramater. The
466 * ::WIMStruct must be freed using using wimlib_free() when finished with
468 * @return 0 on success; nonzero on error.
469 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
470 * @a ctype was not ::WIM_COMPRESSION_TYPE_NONE,
471 * ::WIM_COMPRESSION_TYPE_LZX, or ::WIM_COMPRESSION_TYPE_XPRESS.
472 * @retval ::WIMLIB_ERR_NOMEM
473 * Failed to allocate needed memory.
475 extern int wimlib_create_new_wim(int ctype, WIMStruct **wim_ret);
478 * Deletes an image, or all images, from a WIM file.
480 * All file resources referenced by the image(s) being deleted are removed from
481 * the WIM if they are not referenced by any other images in the WIM.
484 * Pointer to the ::WIMStruct for the WIM file that contains the image(s)
487 * The number of the image to delete, or ::WIM_ALL_IMAGES to delete all
489 * @return 0 on success; nonzero on error. On error, @a wim is left in an
490 * indeterminate state and should be freed with wimlib_free().
491 * @retval ::WIMLIB_ERR_DECOMPRESSION
492 * Could not decompress the metadata resource for @a image.
493 * @retval ::WIMLIB_ERR_INVALID_DENTRY
494 * A directory entry in the metadata resource for @a image in the WIM is
496 * @retval ::WIMLIB_ERR_INVALID_IMAGE
497 * @a image does not exist in the WIM and is not ::WIM_ALL_IMAGES.
498 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
499 * The metadata resource for @a image in the WIM is invalid.
500 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
501 * The security data for @a image in the WIM is invalid.
502 * @retval ::WIMLIB_ERR_NOMEM Failed to allocate needed memory.
503 * @retval ::WIMLIB_ERR_READ
504 * Could not read the metadata resource for @a image from the WIM.
505 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
506 * @a wim is part of a split WIM. Deleting an image from a split WIM is
509 extern int wimlib_delete_image(WIMStruct *wim, int image);
512 * Copies an image, or all the images, from a WIM file, into another WIM file.
515 * Pointer to the ::WIMStruct for a WIM file that contains the image(s)
518 * The image to export from @a src_wim. Can be the number of an image, or
519 * ::WIM_ALL_IMAGES to export all images.
521 * Pointer to the ::WIMStruct for a WIM filethat will receive the images being
524 * The name to give the exported image in the new WIM file. If left @c NULL,
525 * the name from @a src_wim is used. This parameter must be left @c NULL
526 * if @a src_image is ::WIM_ALL_IMAGES and @a src_wim contains more than one
527 * image; in that case, the names are all taken from the @a src_wim.
528 * @param dest_description
529 * The description to give the exported image in the new WIM file. If left
530 * @c NULL, the description from the @a src_wim is used. This parameter must
531 * be left @c NULL if @a src_image is ::WIM_ALL_IMAGES and @a src_wim contains
532 * more than one image; in that case, the descriptions are all taken from
535 * ::WIMLIB_EXPORT_FLAG_BOOT if the image being exported is to be made
536 * bootable, or 0 if which image is marked as bootable in the destination
537 * WIM is to be left unchanged. If @a src_image is ::WIM_ALL_IMAGES and
538 * there are multiple images in @a src_wim, specifying
539 * ::WIMLIB_EXPORT_FLAG_BOOT is valid only if one of the exported images is
540 * currently marked as bootable in @a src_wim; if that is the case, then
541 * that image is marked as bootable in the destination WIM.
543 * @return 0 on success; nonzero on error. On error, @dest_wim is left in an
544 * indeterminate state and should be freed with wimlib_free().
545 * @retval ::WIMLIB_ERR_DECOMPRESSION
546 * Could not decompress the metadata resource for @a src_image
548 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
549 * One or more of the names being given to an exported image was already in
550 * use in the destination WIM.
551 * @retval ::WIMLIB_ERR_INVALID_DENTRY
552 * A directory entry in the metadata resource for @a src_image in @a
553 * src_wim is invalid.
554 * @retval ::WIMLIB_ERR_INVALID_IMAGE
555 * @a src_image does not exist in @a src_wim.
556 * @retval ::WIMLIB_ERR_INVALID_PARAM
557 * ::WIMLIB_EXPORT_FLAG_BOOT was specified in @a flags, @a src_image was
558 * ::WIM_ALL_IMAGES, @a src_wim contains multiple images, and no images in
559 * @a src_wim are marked as bootable; or @a dest_name and/or @a
560 * dest_description were non-<code>NULL</code>, @a src_image was
561 * ::WIM_ALL_IMAGES, and @a src_wim contains multiple images; or @a src_wim
562 * or @a dest_wim was @c NULL.
563 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
564 * The metadata resource for @a src_image in @a src_wim is invalid.
565 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
566 * The security data for @a src_image in @a src_wim is invalid.
567 * @retval ::WIMLIB_ERR_NOMEM
568 * Failed to allocate needed memory.
569 * @retval ::WIMLIB_ERR_READ
570 * Could not read the metadata resource for @a src_image from @a src_wim.
571 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
572 * @a src_wim or @a dest_wim is part of a split WIM. Exporting an image
573 * from or to a split WIM is unsupported.
575 extern int wimlib_export_image(WIMStruct *src_wim, int src_image,
576 WIMStruct *dest_wim, const char *dest_name,
577 const char *dest_description, int flags);
580 * Extracts an image, or all images, from a standalone or split WIM file.
583 * Pointer to the ::WIMStruct for a standalone WIM file, or part 1 of a
586 * The image to extract. Can be the number of an image, or ::WIM_ALL_IMAGES
587 * to specify that all images are to be extracted.
589 * Directory to extract the WIM image(s) to. It is created if it does not
592 * Bitwise or of the flags prefixed with WIMLIB_EXTRACT_FLAG.
594 * One or none of ::WIMLIB_EXTRACT_FLAG_HARDLINK or
595 * ::WIMLIB_EXTRACT_FLAG_SYMLINK may be specified. These flags cause
596 * extracted files that are identical to be hardlinked or symlinked
597 * together, depending on the flag. These flags override the hard link
598 * groups that are specified in the WIM file itself. If ::WIM_ALL_IMAGES
599 * is provided as the @a image parameter, files may be hardlinked or
600 * symlinked across images if a file is found to occur in more than one
603 * You may also specify the flag ::WIMLIB_EXTRACT_FLAG_VERBOSE to cause
604 * informational messages to be printed during the extraction, including
605 * the name of each extracted file or directory.
606 * @param additional_swms
607 * Array of pointers to the ::WIMStruct for each additional part in the
608 * split WIM. Ignored if @a num_additional_swms is 0. The pointers do not
609 * need to be in any particular order, but they must include all parts of
610 * the split WIM other than the first part, which must be provided in the
612 * @param num_additional_swms
613 * Number of additional WIM parts provided in the @a additional_swms array.
614 * This number should be one less than the total number of parts in the
617 * @return 0 on success; nonzero on error.
618 * @retval ::WIMLIB_ERR_DECOMPRESSION
619 * Could not decompress a resource (file or metadata) for @a image in @a
621 * @retval ::WIMLIB_ERR_INVALID_DENTRY
622 * A directory entry in the metadata resource for @a image in @a wim is
624 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
625 * The SHA1 message digest of an extracted stream did not match the SHA1
626 * message digest given in the WIM file.
627 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
628 * A resource (file or metadata) for @a image in @a wim is invalid.
629 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
630 * The security data for @a image in @a wim is invalid.
631 * @retval ::WIMLIB_ERR_LINK
632 * Failed to create a symbolic link or a hard link.
633 * @retval ::WIMLIB_ERR_MKDIR
634 * Failed create a needed directory.
635 * @retval ::WIMLIB_ERR_NOMEM
636 * Failed to allocate needed memory.
637 * @retval ::WIMLIB_ERR_OPEN
638 * Could not open one of the files being extracted for writing.
639 * @retval ::WIMLIB_ERR_READ
640 * A unexpected end-of-file or read error occurred when trying to read data
641 * from the WIM file associated with @a wim.
642 * @retval ::WIMLIB_ERR_SPLIT_INVALID
643 * The WIM is a split WIM, but the parts specified do not form a complete
644 * split WIM because they do not include all the parts of the original WIM,
645 * there are duplicate parts, or not all the parts have the same GUID and
647 * @retval ::WIMLIB_ERR_WRITE
648 * Failed to write a file being extracted.
650 extern int wimlib_extract_image(WIMStruct *wim, int image,
651 const char *output_dir, int flags,
652 WIMStruct **additional_swms,
653 unsigned num_additional_swms);
656 * Extracts the XML data for a WIM file to a file stream. Every WIM file
657 * includes a string of XML that describes the images contained in the WIM.
658 * This function works on standalone WIMs as well as split WIM parts.
661 * Pointer to the ::WIMStruct for a WIM file.
663 * @c stdout, or a FILE* opened for writing, to extract the data to.
665 * @return 0 on success; nonzero on error.
666 * @retval ::WIMLIB_ERR_WRITE
667 * Failed to completely write the XML data to @a fp.
669 extern int wimlib_extract_xml_data(WIMStruct *wim, FILE *fp);
672 * Frees all memory allocated for a WIMStruct and closes all files associated
676 * Pointer to the ::WIMStruct for a WIM file.
678 * @return This function has no return value.
680 extern void wimlib_free(WIMStruct *wim);
683 * Finds which image in a WIM is bootable.
686 * Pointer to the ::WIMStruct for a WIM file.
689 * 0 if no image is marked as bootable, or the number of the image marked
690 * as bootable (numbered starting at 1).
692 extern int wimlib_get_boot_idx(const WIMStruct *wim);
695 * Gets the compression type used in the WIM.
698 * Pointer to the ::WIMStruct for a WIM file
701 * ::WIM_COMPRESSION_TYPE_NONE, ::WIM_COMPRESSION_TYPE_LZX, or
702 * ::WIM_COMPRESSION_TYPE_XPRESS.
704 extern int wimlib_get_compression_type(const WIMStruct *wim);
707 * Converts a compression type enumeration value into a string.
710 * ::WIM_COMPRESSION_TYPE_NONE, ::WIM_COMPRESSION_TYPE_LZX,
711 * ::WIM_COMPRESSION_TYPE_XPRESS, or another value.
714 * A statically allocated string: "None", "LZX", "XPRESS", or "Invalid",
717 extern const char *wimlib_get_compression_type_string(int ctype);
720 * Converts an error code into a string describing it.
723 * The error code returned by one of wimlib's functions.
726 * Pointer to a statically allocated string describing the error code,
727 * or @c NULL if the error code is not valid.
729 extern const char *wimlib_get_error_string(enum wimlib_error_code code);
732 * Returns the description of the specified image.
735 * Pointer to the ::WIMStruct for a WIM file. It may be either a
736 * standalone WIM or a split WIM part.
738 * The number of the image, numbered starting at 1.
741 * The description of the image, or @c NULL if there is no such image, or @c NULL
742 * if the specified image has no description.
744 extern const char *wimlib_get_image_description(const WIMStruct *wim, int image);
747 * Returns the name of the specified image.
750 * Pointer to the ::WIMStruct for a WIM file. It may be either a
751 * standalone WIM or a split WIM part.
753 * The number of the image, numbered starting at 1.
756 * The name of the image, or @c NULL if there is no such image.
758 extern const char *wimlib_get_image_name(const WIMStruct *wim, int image);
762 * Gets the number of images contained in the WIM.
765 * Pointer to the ::WIMStruct for a WIM file. It may be either a
766 * standalone WIM or a split WIM part.
769 * The number of images contained in the WIM file.
771 extern int wimlib_get_num_images(const WIMStruct *wim);
774 * Gets the part number of part of a split WIM.
777 * Pointer to the ::WIMStruct for a WIM file.
778 * @param total_parts_ret
779 * If non-@c NULL, the total number of parts in the split WIM (1 for
780 * non-split WIMs) is written to this location.
783 * The part number of the WIM (1 for non-split WIMs)
785 extern int wimlib_get_part_number(const WIMStruct *wim, int *total_parts_ret);
788 * Returns true if the WIM has an integrity table.
791 * Pointer to the ::WIMStruct for a WIM file.
793 * @c true if the WIM has an integrity table; @c false otherwise.
795 extern bool wimlib_has_integrity_table(const WIMStruct *wim);
799 * Determines if an image name is already used by some image in the WIM.
802 * Pointer to the ::WIMStruct for a WIM file.
807 * @c true if there is already an image in @a wim named @a name; @c
808 * false if there is no image named @a name in @a wim.
810 extern bool wimlib_image_name_in_use(const WIMStruct *wim, const char *name);
813 * Joins a set of split WIMs into a one-part WIM.
816 * An array of strings that give the filenames of all parts of the split
819 * Number of filenames in @a swms.
821 * The path to write the one-part WIM to.
823 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY to check the split WIMs' integrity
824 * tables (if present) when opening them, and include an integrity table in
827 * @return 0 on success; nonzero on error. This function may return any value
828 * returned by wimlib_open_wim() except ::WIMLIB_ERR_SPLIT_UNSUPPORTED, as well
829 * as the following error codes:
831 * @retval ::WIMLIB_ERR_SPLIT_INVALID
832 * The split WIMs do not form a valid WIM because they do not include all
833 * the parts of the original WIM, there are duplicate parts, or not all the
834 * parts have the same GUID and compression type.
835 * @retval ::WIMLIB_ERR_WRITE
836 * An error occurred when trying to write data to the new WIM at @a output_path.
838 * Note that this function merely copies the resources, so it will not check to
839 * see if the resources, including the metadata resource, are valid or not.
841 extern int wimlib_join(const char **swms, unsigned num_swms,
842 const char *output_path, int flags);
845 * Mounts an image in a WIM file on a directory read-only or read-write.
847 * A daemon will be forked to service the filesystem.
849 * If the mount is read-write, modifications to the WIM are staged in a staging
852 * wimlib_mount() currently cannot be used with multiple ::WIMStruct's without
853 * intervening wimlib_unmount()s. If there was a way to have libfuse pass a
854 * pointer to user data to each FUSE callback, then this would be possible, but
855 * there doesn't seem to be a way to do this currently.
858 * Pointer to the ::WIMStruct for the WIM file to be mounted.
860 * The number of the image to mount, numbered from 1. It must be an
861 * existing, single image.
863 * The path to an existing directory to mount the image on.
865 * Bitwise OR of the flags prefixed with WIMLIB_MOUNT_FLAG. If
866 * ::WIMLIB_MOUNT_FLAG_READWRITE is not given, the WIM is mounted
867 * read-only. The interface to the WIM named data streams is specified by
868 * exactly one of ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_NONE,
869 * ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_XATTR, or
870 * ::WIMLIB_MOUNT_FLAG_STREAM_INTERFACE_WINDOWS. The default interface is
871 * the XATTR interface.
873 * @return 0 on success; nonzero on error.
874 * @retval ::WIMLIB_ERR_DECOMPRESSION
875 * Could not decompress the metadata resource for @a image in @a wim.
876 * @retval ::WIMLIB_ERR_FUSE
877 * A non-zero status was returned by @c fuse_main().
878 * @retval ::WIMLIB_ERR_INVALID_DENTRY
879 * A directory entry in the metadata resource for @a image in @a wim is
881 * @retval ::WIMLIB_ERR_INVALID_IMAGE
882 * @a image does not specify an existing, single image in @a wim.
883 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
884 * The metadata resource for @a image in @a wim is invalid.
885 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
886 * The security data for @a image in @a wim is invalid.
887 * @retval ::WIMLIB_ERR_MKDIR
888 * ::WIMLIB_MOUNT_FLAG_READWRITE was specified in @a flags, but the staging
889 * directory could not be created.
890 * @retval ::WIMLIB_ERR_NOMEM
891 * Failed to allocate needed memory.
892 * @retval ::WIMLIB_ERR_NOTDIR
893 * Could not determine the current working directory.
894 * @retval ::WIMLIB_ERR_READ
895 * An unexpected end-of-file or read error occurred when trying to read
896 * data from the WIM file associated with @a wim.
898 extern int wimlib_mount(WIMStruct *wim, int image, const char *dir, int flags);
901 * Opens a WIM file and creates a ::WIMStruct for it.
904 * The path to the WIM file to open.
906 * Bitwise OR of ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY and/or
907 * ::WIMLIB_OPEN_FLAG_SHOW_PROGRESS.
908 * If ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is given, the integrity table
909 * of the WIM, if it exists, is checked, and the function will fail with an
910 * ::WIMLIB_ERR_INTEGRITY status if any of the computed SHA1 message
911 * digests of the WIM do not exactly match the corresponding message
912 * digests given in the integrity table.
913 * If ::WIMLIB_OPEN_FLAG_SHOW_PROGRESS is given, progress information will
914 * be shown if the integrity of the WIM is checked.
915 * If ::WIMLIB_OPEN_FLAG_SPLIT_OK is given, no error will be issued if the
916 * WIM is part of a split WIM. However, wimlib does not fully support
917 * split WIMs, so not all functions will work correctly after opening a
918 * split WIM. For example, you cannot use wimlib_mount() or
919 * wimlib_extract_image() on a split WIM.
922 * On success, a pointer to an opaque ::WIMStruct for the opened WIM file
923 * is written to the memory location pointed to by this parameter. The
924 * ::WIMStruct must be freed using using wimlib_free() when finished with
927 * @return 0 on success; nonzero on error.
928 * @retval ::WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE
929 * The lookup table of @a wim_file is compressed. Support for this can be
930 * added to wimlib if needed, but it appears to be the case that the lookup
931 * table is never compressed.
932 * @retval ::WIMLIB_ERR_IMAGE_COUNT
933 * The WIM is not the non-first part of a split WIM, and the number of
934 * metadata resources found in the WIM did not match the image count given
935 * in the WIM header, or the number of <IMAGE> elements in the XML
936 * data for the WIM did not match the image count given in the WIM header.
937 * @retval ::WIMLIB_ERR_INTEGRITY
938 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a flags and @a
939 * wim_file contains an integrity table, but the SHA1 message digest for a
940 * chunk of the WIM does not match the corresponding message digest given
941 * in the integrity table.
942 * @retval ::WIMLIB_ERR_INVALID_CHUNK_SIZE
943 * Resources in @a wim_file are compressed, but the chunk size is not 32768.
944 * @retval ::WIMLIB_ERR_INVALID_COMPRESSION_TYPE
945 * The header of @a wim_file says that resources in the WIM are compressed,
946 * but the header flag indicating LZX or XPRESS compression is not set.
947 * @retval ::WIMLIB_ERR_INVALID_HEADER_SIZE
948 * The length field of the WIM header is not 208.
949 * @retval ::WIMLIB_ERR_INVALID_INTEGRITY_TABLE
950 * ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY was specified in @a flags and @a
951 * wim_file contains an integrity table, but the integrity table is
953 * @retval ::WIMLIB_ERR_INVALID_LOOKUP_TABLE_ENTRY
954 * The lookup table for the WIM contained duplicate entries, or it
955 * contained an entry with a SHA1 message digest of all 0's.
956 * @retval ::WIMLIB_ERR_NOMEM
957 * Failed to allocated needed memory.
958 * @retval ::WIMLIB_ERR_NOT_A_WIM_FILE
959 * @a wim_file does not begin with the expected magic characters.
960 * @retval ::WIMLIB_ERR_OPEN
961 * Failed to open the file @a wim_file for reading.
962 * @retval ::WIMLIB_ERR_READ
963 * An unexpected end-of-file or read error occurred when trying to read
964 * data from @a wim_file.
965 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
966 * @a wim_file is a split WIM, but ::WIMLIB_OPEN_FLAG_SPLIT_OK was not
968 * @retval ::WIMLIB_ERR_UNKNOWN_VERSION
969 * A number other than 0x10d00 is written in the version field of the WIM
970 * header of @a wim_file.
971 * @retval ::WIMLIB_ERR_XML
972 * The XML data for @a wim_file is invalid.
974 extern int wimlib_open_wim(const char *wim_file, int flags,
975 WIMStruct **wim_ret);
978 * Overwrites the file that the WIM was originally read from, with changes made.
980 * The new WIM is written to a temporary file and then renamed to the original
981 * file after it is has been completely written. The temporary file currently
982 * is made in the same directory as the original WIM file.
984 * Note that it is not possible for this function to delete the original file
985 * before having written the new file because it is very likely that file
986 * resources in the new WIM file need to be retrieved from the old WIM file.
988 * After this function returns, @a wim must be freed using wimlib_free(). Any
989 * further actions on @a wim before doing this are undefined.
992 * Pointer to the ::WIMStruct for the WIM file to write. There may have
993 * been in-memory changes made to it, which are then reflected in the
996 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY and/or
997 * ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS.
999 * @return 0 on success; nonzero on error. This function may return any value
1000 * returned by wimlib_write() as well as the following error codes:
1001 * @retval ::WIMLIB_ERR_NO_FILENAME
1002 * @a wim corresponds to a WIM created with wimlib_create_new_wim() rather
1003 * than a WIM read with wimlib_open_wim().
1004 * @retval ::WIMLIB_ERR_RENAME
1005 * The temporary file that the WIM was written to could not be renamed to
1006 * the original filename of @a wim.
1008 extern int wimlib_overwrite(WIMStruct *wim, int flags);
1011 * Updates the header and XML data of the WIM file, without the need to write
1012 * out the entire WIM to a temporary file as in wimlib_write().
1014 * This function must only be used if no files, directories, or images have been
1015 * added, removed, or changed in the WIM. It must be used when only the boot
1016 * index or the name or description of image(s) has been changed.
1018 * After this function returns, @a wim must be freed using wimlib_free(). Any
1019 * further actions on @a wim before doing this are undefined.
1022 * Pointer to the ::WIMStruct for the WIM file to overwrite.
1024 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY and/or
1025 * ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS.
1027 * @return 0 on success; nonzero on error.
1029 * @retval ::WIMLIB_ERR_NO_FILENAME
1030 * @a wim corresponds to a WIM created with wimlib_create_new_wim() rather
1031 * than a WIM read with wimlib_open_wim().
1032 * @retval ::WIMLIB_ERR_NOMEM
1033 * Failed to allocate needed memory.
1034 * @retval ::WIMLIB_ERR_OPEN
1035 * The WIM file associated with @a wim could not be re-opened read-write.
1036 * @retval ::WIMLIB_ERR_READ
1037 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY was specified in @a flags, but data
1038 * from the WIM file associated with @a wim could not be read to compute
1039 * the SHA1 message digests, or the old integrity table (if it existed)
1040 * could not be read.
1041 * @retval ::WIMLIB_ERR_WRITE
1042 * Failed to write the WIM header, the XML data, or the integrity table to
1043 * the WIM file associated with @a wim.
1045 extern int wimlib_overwrite_xml_and_header(WIMStruct *wim, int flags);
1048 * Prints information about one image, or all images, contained in a WIM.
1051 * Pointer to the ::WIMStruct for a WIM file.
1053 * The image about which to print information. Can be the number of an
1054 * image, or ::WIM_ALL_IMAGES to print information about all images in the
1057 * @return This function has no return value.
1059 extern void wimlib_print_available_images(const WIMStruct *wim, int image);
1062 * Prints the full paths to all files contained in an image, or all images, in a
1066 * Pointer to the ::WIMStruct for a WIM file.
1068 * Which image to print files for. Can be the number of an image, or
1069 * ::WIM_ALL_IMAGES to print the files contained in all images.
1071 * @return 0 on success; nonzero on error.
1072 * @retval ::WIMLIB_ERR_DECOMPRESSION
1073 * The metadata resource for one of the specified images could not be
1075 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1076 * A directory entry in the metadata resource for one of the specified
1077 * images is invaled.
1078 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1079 * @a image does not specify a valid image in @a wim, and is not
1081 * @retval ::WIMLIB_ERR_INVALID_PARAM
1082 * @a wim was @c NULL.
1083 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1084 * The metadata resource for one of the specified images is invalid.
1085 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1086 * The security data for one of the specified images is invalid.
1087 * @retval ::WIMLIB_ERR_NOMEM
1088 * Failed to allocate needed memory.
1089 * @retval ::WIMLIB_ERR_READ
1090 * An unexpected read error or end-of-file occurred when reading the
1091 * metadata resource for one of the specified images.
1092 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
1093 * @a wim was not a standalone WIM and was not the first part of a split
1096 extern int wimlib_print_files(WIMStruct *wim, int image);
1099 * Prints detailed information from the header of a WIM file.
1102 * Pointer to the ::WIMStruct for a WIM file. It may be either a
1103 * standalone WIM or part of a split WIM.
1105 * @return This function has no return value.
1108 extern void wimlib_print_header(const WIMStruct *wim);
1111 * Prints the lookup table of a WIM file. The lookup table maps SHA1 message
1112 * digests, as found in the directory entry tree in the WIM file, to file
1113 * resources in the WIM file. This table includes one entry for each unique
1114 * file in the WIM, so it can be quite long. There is only one lookup table per
1118 * Pointer to the ::WIMStruct for a WIM file.
1120 * @return This function has no return value.
1122 extern void wimlib_print_lookup_table(WIMStruct *wim);
1125 * Prints the metadata of the specified image in a WIM file. The metadata
1126 * consists of the security data as well as the directory entry tree, and each
1127 * image has its own metadata.
1130 * Pointer to the ::WIMStruct for a WIM file.
1132 * Which image to print the metadata for. Can be the number of an image,
1133 * or ::WIM_ALL_IMAGES to print the metadata for all images in the WIM.
1135 * @return 0 on success; nonzero on error.
1136 * @retval ::WIMLIB_ERR_DECOMPRESSION
1137 * The metadata resource for one of the specified images could not be
1139 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1140 * A directory entry in the metadata resource for one of the specified
1141 * images is invaled.
1142 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1143 * @a image does not specify a valid image in @a wim, and is not
1145 * @retval ::WIMLIB_ERR_INVALID_PARAM
1146 * @a wim was @c NULL.
1147 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1148 * The metadata resource for one of the specified images is invalid.
1149 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1150 * The security data for one of the specified images is invalid.
1151 * @retval ::WIMLIB_ERR_NOMEM
1152 * Failed to allocate needed memory.
1153 * @retval ::WIMLIB_ERR_READ
1154 * An unexpected read error or end-of-file occurred when reading the
1155 * metadata resource for one of the specified images.
1156 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
1157 * @a wim was not a standalone WIM and was not the first part of a split
1160 extern int wimlib_print_metadata(WIMStruct *wim, int image);
1163 * Prints some basic information about a WIM file. All information printed by
1164 * this function is also printed by wimlib_print_header(), but
1165 * wimlib_print_wim_information() prints some of this information more concisely
1166 * and in a more readable form.
1169 * Pointer to the ::WIMStruct for a WIM file.
1171 * @return This function has no return value.
1173 extern void wimlib_print_wim_information(const WIMStruct *wim);
1176 * Translates a string specifying the name or number of an image in the WIM into
1177 * the number of the image. The images are numbered starting at 1.
1180 * Pointer to the ::WIMStruct for a WIM file.
1181 * @param image_name_or_num
1182 * A string specifying which image. If it begins with a number, it is
1183 * taken to be a string specifying the image number. Otherwise, it is
1184 * taken to be the name of an image, as specified in the XML data for the
1185 * WIM file. It also may be the keyword "all", which will resolve to
1189 * If the string resolved to a single existing image, the number of that
1190 * image, counting starting at 1, is returned. If the keyword "all" was
1191 * specified, ::WIM_ALL_IMAGES is returned. Otherwise, ::WIM_NO_IMAGE is
1194 extern int wimlib_resolve_image(WIMStruct *wim, const char *image_name_or_num);
1197 * Sets which image in the WIM is marked as bootable.
1200 * Pointer to the ::WIMStruct for a WIM file.
1202 * The number of the image to mark as bootable, or 0 to mark no image as
1204 * @return 0 on success; nonzero on error.
1205 * @retval ::WIMLIB_ERR_INVALID_PARAM
1206 * @a wim was @c NULL.
1207 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1208 * @a boot_idx does not specify an existing image in @a wim, and it was not
1210 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
1211 * @a wim is part of a split WIM. We do not support changing the boot
1212 * index of a split WIM.
1214 extern int wimlib_set_boot_idx(WIMStruct *wim, int boot_idx);
1217 * Changes the description of an image in the WIM.
1220 * Pointer to the ::WIMStruct for a WIM file. It may be either a
1221 * standalone WIM or part of a split WIM; however, you should set the same
1222 * description on all parts of a split WIM.
1224 * The number of the image for which to change the description.
1225 * @param description
1226 * The new description to give the image. It may be @c NULL, which
1227 * indicates that the image is to be given no description.
1229 * @return 0 on success; nonzero on error.
1230 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1231 * @a image does not specify a single existing image in @a wim.
1232 * @retval ::WIMLIB_ERR_INVALID_PARAM
1233 * @a wim was @c NULL.
1234 * @retval ::WIMLIB_ERR_NOMEM
1235 * Failed to allocate the memory needed to duplicate the @a description
1238 extern int wimlib_set_image_descripton(WIMStruct *wim, int image,
1239 const char *description);
1242 * Changes what is written in the <FLAGS> element in the WIM XML data (something
1243 * like "Core" or "Ultimate")
1246 * Pointer to the ::WIMStruct for a WIM file. It may be either a
1247 * standalone WIM or part of a split WIM; however, you should set the same
1248 * <FLAGS> element on all parts of a split WIM.
1250 * The number of the image for which to change the description.
1252 * The new <FLAGS> element to give the image. It may be @c NULL, which
1253 * indicates that the image is to be given no <FLAGS> element.
1255 * @return 0 on success; nonzero on error.
1256 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1257 * @a image does not specify a single existing image in @a wim.
1258 * @retval ::WIMLIB_ERR_INVALID_PARAM
1259 * @a wim was @c NULL.
1260 * @retval ::WIMLIB_ERR_NOMEM
1261 * Failed to allocate the memory needed to duplicate the @a flags string.
1263 extern int wimlib_set_image_flags(WIMStruct *w, int image,
1267 * Changes the name of an image in the WIM.
1270 * Pointer to the ::WIMStruct for a WIM file. It may be either a
1271 * standalone WIM or part of a split WIM; however, you should set the same
1272 * name on all parts of a split WIM.
1274 * The number of the image for which to change the name.
1276 * The new name to give the image. It must not a nonempty string.
1278 * @return 0 on success; nonzero on error.
1279 * @retval ::WIMLIB_ERR_IMAGE_NAME_COLLISION
1280 * There is already an image named @a name in @a wim.
1281 * @retval ::WIMLIB_ERR_INVALID_PARAM
1282 * @a name was @c NULL or the empty string, or @a wim was @c NULL.
1283 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1284 * @a image does not specify a single existing image in @a wim.
1285 * @retval ::WIMLIB_ERR_NOMEM
1286 * Failed to allocate the memory needed to duplicate the @a name string.
1288 extern int wimlib_set_image_name(WIMStruct *wim, int image, const char *name);
1291 * Set the functions that wimlib uses to allocate and free memory.
1293 * These settings are global and not per-WIM.
1295 * The default is to use the default @c malloc() and @c free() from the C
1298 * Please note that some external functions we call still may use the standard
1299 * memory allocation functions.
1301 * @param malloc_func
1302 * A function equivalent to @c malloc() that wimlib will use to allocate
1303 * memory. If @c NULL, the allocator function is set back to the default
1304 * @c malloc() from the C library.
1306 * A function equivalent to @c free() that wimlib will use to free memory.
1307 * If @c NULL, the free function is set back to the default @c free() from
1309 * @param realloc_func
1310 * A function equivalent to @c realloc() that wimlib will use to reallocate
1311 * memory. If @c NULL, the free function is set back to the default @c
1312 * realloc() from the C library.
1313 * @return 0 on success; nonzero on error.
1314 * @retval ::WIMLIB_ERR_UNSUPPORTED
1315 * wimlib was compiled with the @c --without-custom-memory-allocator flag,
1316 * so custom memory allocators are unsupported.
1318 int wimlib_set_memory_allocator(void *(*malloc_func)(size_t),
1319 void (*free_func)(void *),
1320 void *(*realloc_func)(void *, size_t));
1323 * Sets whether wimlib is to print error messages to @c stderr when a function
1324 * fails. These error messages may provide information that cannot be
1325 * determined only from the error code that is returned. Not every error will
1326 * result in an error message being printed.
1328 * This setting is global and not per-WIM.
1330 * By default, error messages are not printed.
1332 * @param show_messages
1333 * @c true if error messages are to be printed; @c false if error messages
1334 * are not to be printed.
1336 * @return 0 on success; nonzero on error.
1337 * @retval ::WIMLIB_ERR_UNSUPPORTED
1338 * @a show_messages was @c true, but wimlib was compiled with the @c
1339 * --without-error-messages option. Therefore, error messages cannot be
1342 extern int wimlib_set_print_errors(bool show_messages);
1345 * Splits a WIM into multiple parts.
1348 * Name of the WIM file to split. It must be a standalone, one-part WIM.
1350 * Name of the SWM file to create. This will be the name of the first
1351 * part. The other parts will have the same name with 2, 3, 4, ..., etc.
1354 * The maximum size per part. It is not guaranteed that this will really
1355 * be the maximum size per part, because some file resources in the WIM may
1356 * be larger than this size, and the WIM file format provides no way to
1357 * split up file resources among multiple WIMs.
1359 * Bitwise OR of ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY and/or
1360 * ::WIMLIB_OPEN_FLAG_SHOW_PROGRESS.
1362 * @return 0 on success; nonzero on error. This function may return any value
1363 * returned by wimlib_open_wim() as well as the following error codes:
1365 * @retval ::WIMLIB_ERR_WRITE
1366 * An error occurred when trying to write data to one of the split WIMs.
1369 extern int wimlib_split(const char *wimfile, const char *swm_name,
1370 size_t part_size, int flags);
1373 * Unmounts a WIM image that was mounted using wimlib_mount().
1375 * Blocks until it is known whether the mount succeeded or failed.
1377 * To perform this operation, the process calling wimlib_unmount() communicates
1378 * with the process that had called wimlib_mount().
1380 * There is currently a design problem with this function because it is hard to
1381 * know whether the filesystem daemon is still working or whether it has
1382 * crashed, has been killed, or has reached an infinite loop. However, ideally
1383 * there should be no infinite loops or crashes in the code, so this wouldn't be
1384 * much of a problem. Currently, a timeout of 600 seconds (so long because WIMs
1385 * can be very large) is implemented so that this function will not wait forever
1386 * before returning failure.
1389 * The directory that the WIM image was mounted on.
1391 * Bitwise OR of the flags ::WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY or
1392 * ::WIMLIB_UNMOUNT_FLAG_COMMIT. Neither of these flags affect read-only
1395 * @return 0 on success; nonzero on error.
1396 * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
1397 * The filesystem daemon was unable to remove the staging directory and the
1398 * temporary files that it contains.
1399 * @retval ::WIMLIB_ERR_FORK
1400 * Could not @c fork() the process.
1401 * @retval ::WIMLIB_ERR_FUSERMOUNT
1402 * The @b fusermount program could not be executed or exited with a failure
1404 * @retval ::WIMLIB_ERR_MQUEUE
1405 * Could not open a POSIX message queue to communicate with the filesystem
1406 * daemon servicing the mounted filesystem, could not send a message
1407 * through the queue, or could not receive a message through the queue.
1408 * @retval ::WIMLIB_ERR_NOMEM
1409 * Failed to allocate needed memory.
1410 * @retval ::WIMLIB_ERR_OPEN
1411 * The filesystem daemon could not open a temporary file for writing the
1413 * @retval ::WIMLIB_ERR_TIMEOUT
1414 * 600 seconds elapsed while waiting for the filesystem daemon to notify
1415 * the process of its exit status, so the WIM file probably was not written
1417 * @retval ::WIMLIB_ERR_READ
1418 * A read error occurred when the filesystem daemon tried to a file from
1419 * the staging directory
1420 * @retval ::WIMLIB_ERR_RENAME
1421 * The filesystem daemon failed to rename the newly written WIM file to the
1422 * original WIM file.
1423 * @retval ::WIMLIB_ERR_WRITE
1424 * A write error occurred when the filesystem daemon was writing to the new
1425 * WIM file, or the filesystem daemon was unable to flush changes that had
1426 * been made to files in the staging directory.
1428 extern int wimlib_unmount(const char *dir, int flags);
1431 * Writes the WIM to a file.
1434 * Pointer to the ::WIMStruct for a WIM file. There may have been
1435 * in-memory changes made to it, which are then reflected in the output
1438 * The path to the file to write the WIM to.
1440 * The image inside the WIM to write. Use ::WIM_ALL_IMAGES to include all
1443 * Bitwise OR of ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY and/or
1444 * ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS. If
1445 * ::WIMLIB_WRITE_FLAG_CHECK_INTEGRITY is given, an integrity table is
1446 * included in the WIM being written. If ::WIMLIB_WRITE_FLAG_SHOW_PROGRESS
1447 * is given, the progress of the calculation of the integrity table is
1450 * @return 0 on success; nonzero on error.
1451 * @retval ::WIMLIB_ERR_DECOMPRESSION
1452 * Failed to decompress a metadata or file resource in @a wim.
1453 * @retval ::WIMLIB_ERR_INVALID_DENTRY
1454 * A directory entry in the metadata resource for @a image in @a wim is
1456 * @retval ::WIMLIB_ERR_INVALID_IMAGE
1457 * @a image does not specify a single existing image in @a wim, and is not
1459 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_HASH
1460 * A file that had previously been scanned for inclusion in the WIM by the
1461 * wimlib_add_image() or wimlib_add_image_from_ntfs_volume() functions was
1462 * concurrently modified, so it failed the SHA1 message digest check.
1463 * @retval ::WIMLIB_ERR_INVALID_PARAM
1464 * @a wim or @a path was @c NULL.
1465 * @retval ::WIMLIB_ERR_INVALID_RESOURCE_SIZE
1466 * The metadata resource for @a image in @a wim is invalid.
1467 * @retval ::WIMLIB_ERR_INVALID_SECURITY_DATA
1468 * The security data for @a image in @wim is invalid.
1469 * @retval ::WIMLIB_ERR_NOMEM
1470 * Failed to allocate needed memory.
1471 * @retval ::WIMLIB_ERR_OPEN
1472 * Failed to open @a path for writing, or some file resources in @a
1473 * wim refer to files in the outside filesystem, and one of these files
1474 * could not be opened for reading.
1475 * @retval ::WIMLIB_ERR_READ
1476 * An error occurred when trying to read data from the WIM file associated
1477 * with @a wim, or some file resources in @a wim refer to files in the
1478 * outside filesystem, and a read error occurred when reading one of these
1480 * @retval ::WIMLIB_ERR_SPLIT_UNSUPPORTED
1481 * @a wim is part of a split WIM. You may not call this function on a
1483 * @retval ::WIMLIB_ERR_WRITE
1484 * An error occurred when trying to write data to the new WIM file at @a
1487 extern int wimlib_write(WIMStruct *wim, const char *path, int image, int flags);
1491 #endif /* _WIMLIB_H */