]> wimlib.net Git - wimlib/blobdiff - src/mount_image.c
wimlib_mount_image(): Move "argc = 0"
[wimlib] / src / mount_image.c
index 28a807d7afdfd7d26537a57a97d99e5203564841..7006c7e4478cb2cce196732b344402e8c567eea8 100644 (file)
@@ -848,12 +848,9 @@ static int set_message_queue_names(struct wimfs_context *ctx,
                        return WIMLIB_ERR_NOTDIR;
        }
 
-       p = dir_path;
-       while (*p) {
+       for (p = dir_path; *p; p++)
                if (*p == '/')
                        *p = 0xff;
-               p++;
-       }
 
        ctx->unmount_to_daemon_mq_name = strcat_dup(u2d_prefix, dir_path,
                                                    NAME_MAX);
@@ -2328,7 +2325,7 @@ WIMLIBAPI int wimlib_mount_image(WIMStruct *wim, int image, const char *dir,
                                 unsigned num_additional_swms,
                                 const char *staging_dir)
 {
-       int argc = 0;
+       int argc;
        char *argv[16];
        int ret;
        char *dir_copy;
@@ -2428,6 +2425,7 @@ WIMLIBAPI int wimlib_mount_image(WIMStruct *wim, int image, const char *dir,
        if (!dir_copy)
                goto out_free_message_queue_names;
 
+       argc = 0;
        argv[argc++] = "imagex";
        argv[argc++] = dir_copy;
 
@@ -2499,6 +2497,12 @@ WIMLIBAPI int wimlib_mount_image(WIMStruct *wim, int image, const char *dir,
 
        if (ret)
                ret = WIMLIB_ERR_FUSE;
+
+       /* Try to delete the staging directory if a deletion wasn't yet
+        * attempted due to an earlier error */
+       if (ctx.staging_dir_name)
+               delete_staging_dir(&ctx);
+
 out_free_dir_copy:
        FREE(dir_copy);
 out_unlock: