]> wimlib.net Git - wimlib/blobdiff - src/update_image.c
A few cleanups and fixes from recent changes
[wimlib] / src / update_image.c
index fc149f0a415cd6e5771783634abc91dab89b9200..b973c21d8a896ac1d4b28ba570f9bf197c144fb3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * update_image.c - Update a WIM image.
+ * update_image.c - see description below
  */
 
 /*
  * along with this file; if not, see http://www.gnu.org/licenses/.
  */
 
+/*
+ * This file contains the implementation of wimlib_update_image(), which is one
+ * of the two ways by which library users can make changes to a WIM image.  (The
+ * other way is by mounting an image read-write.)  wimlib_update_image() is also
+ * used in the implementation of wimlib_add_image(), since "create a WIM image
+ * from this directory tree" is equivalent to "create an empty WIM image, then
+ * update it to add this directory tree as the root".
+ *
+ * wimlib_update_image() processes a list of commands passed to it.  Currently,
+ * the following types of commands are supported:
+ *
+ * - Add a directory tree from an external source (filesystem or NTFS volume).
+ *   This can be used to add new files or to replace existing files.
+ * - Delete a file or directory tree.
+ * - Rename a file or directory tree.
+ *
+ * Not supported are creating links to existing files or changing metadata of
+ * existing files.
+ *
+ * wimlib_update_image() is atomic.  If it cannot complete successfully, then
+ * all changes are rolled back and the WIMStruct is left unchanged.  Rollback is
+ * implemented by breaking the commands into primitive operations such as "link
+ * this dentry tree here" which can be undone by doing the opposite operations
+ * in reverse order.
+ */
+
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
 #endif
 
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#include "wimlib/alloca.h"
+#include "wimlib/assert.h"
 #include "wimlib/capture.h"
 #include "wimlib/dentry.h"
 #include "wimlib/encoding.h"
 #include "wimlib/progress.h"
 #include "wimlib/xml.h"
 
-#include <errno.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-
-#ifdef HAVE_ALLOCA_H
-#  include <alloca.h>
-#endif
-
 /* Saved specification of a "primitive" update operation that was performed.  */
 struct update_primitive {
        enum {
@@ -508,7 +532,7 @@ handle_conflict(struct wim_dentry *branch, struct wim_dentry *existing,
                                return ret;
                        }
                }
-               free_dentry(branch);
+               free_dentry_tree(branch, j->lookup_table);
                return 0;
        } else if (add_flags & WIMLIB_ADD_FLAG_NO_REPLACE) {
                /* Can't replace nondirectory file  */
@@ -765,7 +789,7 @@ execute_add_command(struct update_command_journal *j,
        tchar *fs_source_path;
        tchar *wim_target_path;
        const tchar *config_file;
-       struct add_image_params params;
+       struct capture_params params;
        struct capture_config config;
        capture_tree_t capture_tree = platform_default_capture_tree;
 #ifdef WITH_NTFS_3G