]> wimlib.net Git - wimlib/commitdiff
extract/update fixes
authorEric Biggers <ebiggers3@gmail.com>
Mon, 13 May 2013 05:41:29 +0000 (00:41 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 13 May 2013 05:41:29 +0000 (00:41 -0500)
programs/imagex.c
src/extract_image.c
src/security.c
src/update_image.c
src/wimlib.h
src/wimlib_internal.h

index ed0a977625ed136859fb3e38c52123c9d78b2cdd..591714e1684222a5b8f320025a3dfba7fbee7700 100644 (file)
@@ -342,9 +342,16 @@ static const struct option update_options[] = {
        {T("threads"),     required_argument, NULL, IMAGEX_THREADS_OPTION},
        {T("check"),       no_argument,       NULL, IMAGEX_CHECK_OPTION},
        {T("rebuild"),     no_argument,       NULL, IMAGEX_REBUILD_OPTION},
+
+       /* Default delete options */
        {T("force"),       no_argument,       NULL, IMAGEX_FORCE_OPTION},
        {T("recursive"),   no_argument,       NULL, IMAGEX_RECURSIVE_OPTION},
+
+       /* Global add option */
        {T("config"),      required_argument, NULL, IMAGEX_CONFIG_OPTION},
+
+       /* Default add options */
+       {T("verbose"),     no_argument,       NULL, IMAGEX_VERBOSE_OPTION},
        {T("dereference"), no_argument,       NULL, IMAGEX_DEREFERENCE_OPTION},
        {T("unix-data"),   no_argument,       NULL, IMAGEX_UNIX_DATA_OPTION},
        {T("noacls"),      no_argument,       NULL, IMAGEX_NO_ACLS_OPTION},
@@ -1233,7 +1240,9 @@ update_command_add_option(int op, const tchar *option,
        bool recognized = true;
        switch (op) {
        case WIMLIB_UPDATE_OP_ADD:
-               if (!tstrcmp(option, T("--unix-data")))
+               if (!tstrcmp(option, T("--verbose")))
+                       cmd->add.add_flags |= WIMLIB_ADD_IMAGE_FLAG_VERBOSE;
+               else if (!tstrcmp(option, T("--unix-data")))
                        cmd->add.add_flags |= WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA;
                else if (!tstrcmp(option, T("--no-acls")) || !tstrcmp(option, T("--noacls")))
                        cmd->add.add_flags |= WIMLIB_ADD_IMAGE_FLAG_NO_ACLS;
@@ -1252,7 +1261,7 @@ update_command_add_option(int op, const tchar *option,
                else
                        recognized = false;
                break;
-       case WIMLIB_UPDATE_OP_RENAME:
+       default:
                recognized = false;
                break;
        }
@@ -1347,8 +1356,8 @@ parse_update_command(tchar *line, size_t len,
                        if (!update_command_add_option(op, next_string, command))
                        {
                                imagex_error(T("Unrecognized option \"%"TS"\" to "
-                                              "update command on line %zu"),
-                                            next_string, line_number);
+                                              "update command \"%"TS"\" on line %zu"),
+                                            next_string, command_name, line_number);
 
                                return false;
                        }
@@ -2248,7 +2257,7 @@ imagex_extract(int argc, tchar **argv)
        win32_acquire_restore_privileges();
 #endif
 
-       ret = wimlib_extract_files(wim, image, 0, cmds, num_cmds,
+       ret = wimlib_extract_files(wim, image, cmds, num_cmds, 0,
                                   additional_swms, num_additional_swms,
                                   imagex_progress_func);
        if (ret == 0) {
@@ -2902,7 +2911,7 @@ imagex_update(int argc, tchar **argv)
        WIMStruct *wim;
        int ret;
        int open_flags = 0;
-       int write_flags = WIMLIB_WRITE_FLAG_SOFT_DELETE;
+       int write_flags = 0;
        int update_flags = 0;
        int default_add_flags = WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE;
        int default_delete_flags = 0;
@@ -2919,6 +2928,7 @@ imagex_update(int argc, tchar **argv)
 
        for_opt(c, update_options) {
                switch (c) {
+               /* Generic or write options */
                case IMAGEX_THREADS_OPTION:
                        num_threads = parse_num_threads(optarg);
                        if (num_threads == UINT_MAX) {
@@ -2933,15 +2943,24 @@ imagex_update(int argc, tchar **argv)
                case IMAGEX_REBUILD_OPTION:
                        write_flags |= WIMLIB_WRITE_FLAG_REBUILD;
                        break;
+
+               /* Default delete options */
                case IMAGEX_FORCE_OPTION:
                        default_delete_flags |= WIMLIB_DELETE_FLAG_FORCE;
                        break;
                case IMAGEX_RECURSIVE_OPTION:
                        default_delete_flags |= WIMLIB_DELETE_FLAG_RECURSIVE;
                        break;
+
+               /* Global add option */
                case IMAGEX_CONFIG_OPTION:
                        config_file = optarg;
                        break;
+
+               /* Default add options */
+               case IMAGEX_VERBOSE_OPTION:
+                       default_add_flags |= WIMLIB_ADD_IMAGE_FLAG_VERBOSE;
+                       break;
                case IMAGEX_DEREFERENCE_OPTION:
                        default_add_flags |= WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE;
                        break;
index e3229c33009e4b2d44d70bc76112b8ab01de5973..396753501084c55974d654482426f81e8d0fcd2b 100644 (file)
@@ -736,9 +736,9 @@ do_wimlib_extract_files(WIMStruct *wim,
 WIMLIBAPI int
 wimlib_extract_files(WIMStruct *wim,
                     int image,
-                    int default_extract_flags,
                     const struct wimlib_extract_command *cmds,
                     size_t num_cmds,
+                    int default_extract_flags,
                     WIMStruct **additional_swms,
                     unsigned num_additional_swms,
                     wimlib_progress_func_t progress_func)
index 871c243bdc44fc4aa4a07bb939e6e6350bddb183..16e7b912a03caa284400fe6b5dad110cb7e235bb 100644 (file)
@@ -501,7 +501,7 @@ insert_sd_node(struct sd_set *set, struct sd_node *new)
                else if (cmp > 0)
                        p = &((*p)->rb_right);
                else
-                       return false; /* Duplicate SHA1 message digest */
+                       return false; /* Duplicate security descriptor */
        }
        rb_link_node(&new->rb_node, rb_parent, p);
        rb_insert_color(&new->rb_node, root);
@@ -596,6 +596,9 @@ out:
        return -1;
 }
 
+/* Initialize a `struct sd_set' mapping from SHA1 message digests of security
+ * descriptors to indices into the security descriptors table of the WIM image
+ * (security IDs).  */
 int
 init_sd_set(struct sd_set *sd_set, struct wim_security_data *sd)
 {
@@ -603,6 +606,9 @@ init_sd_set(struct sd_set *sd_set, struct wim_security_data *sd)
 
        sd_set->sd = sd;
        sd_set->rb_root.rb_node = NULL;
+
+       /* Remember the original number of security descriptors so that newly
+        * added ones can be rolled back if needed. */
        sd_set->orig_num_entries = sd->num_entries;
        for (int32_t i = 0; i < sd->num_entries; i++) {
                struct sd_node *new;
index ecfef1fffa7bcc764edfc52fe318c1a3f37162ba..7247b1c06b8fb61064974f21c27e0baa670d1964 100644 (file)
@@ -403,20 +403,25 @@ execute_rename_command(WIMStruct *wim,
        ret = rename_wim_path(wim, rename_cmd->rename.wim_source_path,
                              rename_cmd->rename.wim_target_path);
        if (ret) {
+               ret = -ret;
+               errno = ret;
+               ERROR_WITH_ERRNO("Can't rename \"%"TS"\" to \"%"TS"\"",
+                                rename_cmd->rename.wim_source_path,
+                                rename_cmd->rename.wim_target_path);
                switch (ret) {
-               case -ENOMEM:
+               case ENOMEM:
                        ret = WIMLIB_ERR_NOMEM;
                        break;
-               case -ENOTDIR:
+               case ENOTDIR:
                        ret = WIMLIB_ERR_NOTDIR;
                        break;
-               case -ENOTEMPTY:
+               case ENOTEMPTY:
                        ret = WIMLIB_ERR_NOTEMPTY;
                        break;
-               case -EISDIR:
+               case EISDIR:
                        ret = WIMLIB_ERR_IS_DIRECTORY;
                        break;
-               case -ENOENT:
+               case ENOENT:
                default:
                        ret = WIMLIB_ERR_PATH_DOES_NOT_EXIST;
                        break;
@@ -436,7 +441,7 @@ update_op_to_str(int op)
        case WIMLIB_UPDATE_OP_RENAME:
                return T("rename");
        default:
-               return T("???");
+               wimlib_assert(0);
        }
 }
 
@@ -456,15 +461,12 @@ execute_update_commands(WIMStruct *wim,
                        break;
                case WIMLIB_UPDATE_OP_DELETE:
                        ret = execute_delete_command(wim, &cmds[i]);
-                       if (ret == 0)
-                               wim->deletion_occurred = 1;
                        break;
                case WIMLIB_UPDATE_OP_RENAME:
                        ret = execute_rename_command(wim, &cmds[i]);
                        break;
                default:
                        wimlib_assert(0);
-                       break;
                }
                if (ret)
                        break;
@@ -593,8 +595,6 @@ free_update_commands(struct wimlib_update_command *cmds, size_t num_cmds)
                                FREE(cmds[i].rename.wim_source_path);
                                FREE(cmds[i].rename.wim_target_path);
                                break;
-                       default:
-                               wimlib_assert(0);
                        }
                }
                FREE(cmds);
index c4635e89e5470c85b1118d5111fb76aeef8eb917..7cfd493576bc1cee67acdff46dc087005dfa2776 100644 (file)
@@ -1358,11 +1358,6 @@ wimlib_export_image(WIMStruct *src_wim, int src_image,
  *     The 1-based number of the image in @a wim from which the files or
  *     directory trees are to be extracted.  It cannot be ::WIMLIB_ALL_IMAGES.
  *
- * @param default_extract_flags
- *     Default extraction flags; the behavior shall be as if these flags had
- *     been specified in the ::wimlib_extract_command.extract_flags member in
- *     each extraction command, in combination with any flags already present.
- *
  * @param cmds
  *     An array of ::wimlib_extract_command structures that specifies the
  *     extractions to perform.
@@ -1370,6 +1365,11 @@ wimlib_export_image(WIMStruct *src_wim, int src_image,
  * @param num_cmds
  *     Number of commands in the @a cmds array.
  *
+ * @param default_extract_flags
+ *     Default extraction flags; the behavior shall be as if these flags had
+ *     been specified in the ::wimlib_extract_command.extract_flags member in
+ *     each extraction command, in combination with any flags already present.
+ *
  * @param additional_swms
  *     Array of pointers to the ::WIMStruct for each additional part in the
  *     split WIM.  Ignored if @a num_additional_swms is 0.  The pointers do not
@@ -1408,9 +1408,9 @@ wimlib_export_image(WIMStruct *src_wim, int src_image,
 extern int
 wimlib_extract_files(WIMStruct *wim,
                     int image,
-                    int default_extract_flags,
                     const struct wimlib_extract_command *cmds,
                     size_t num_cmds,
+                    int default_extract_flags,
                     WIMStruct **additional_swms,
                     unsigned num_additional_swms,
                     wimlib_progress_func_t progress_func);
index 9e55f37132aae8fe03a8e89e630b5f6c3f2b90da..a54e644cfddee8e8f5bb4759821fb09986534fcc 100644 (file)
@@ -313,7 +313,9 @@ struct WIMStruct {
         * image_metadata array. */
        int current_image;
 
+       /* Have any images been deleted? */
        u8 deletion_occurred : 1;
+
        u8 all_images_verified : 1;
        u8 wim_locked : 1;
 };