]> wimlib.net Git - wimlib/blobdiff - src/mount_image.c
Check for missing streams when resolving them
[wimlib] / src / mount_image.c
index 3f1c590668e6dfd281899e232aba936a0c9d3a4a..088363829bf0cd1376fb73692b585d84ae61de62 100644 (file)
@@ -1444,7 +1444,7 @@ message_loop(mqd_t mq,
  *  daemon to finish writing the WIM file.
  */
 static int
-execute_fusermount(const char *dir)
+execute_fusermount(const char *dir, bool lazy)
 {
        pid_t pid;
        int ret;
@@ -1457,7 +1457,15 @@ execute_fusermount(const char *dir)
        }
        if (pid == 0) {
                /* Child */
-               execlp("fusermount", "fusermount", "-u", dir, NULL);
+               char *argv[10];
+               char **argp = argv;
+               *argp++ = "fusermount";
+               if (lazy)
+                       *argp++ = "-z";
+               *argp++ = "-u";
+               *argp++ = (char*)dir;
+               *argp = NULL;
+               execvp("fusermount", argv);
                ERROR_WITH_ERRNO("Failed to execute `fusermount'");
                exit(WIMLIB_ERR_FUSERMOUNT);
        }
@@ -1495,7 +1503,14 @@ execute_fusermount(const char *dir)
        }
        if (pid == 0) {
                /* Child */
-               execlp("umount", "umount", dir, NULL);
+               char *argv[10];
+               char **argp = argv;
+               *argp++ = "umount";
+               if (lazy)
+                       *argp++ = "-l";
+               *argp++ = (char*)dir;
+               *argp = NULL;
+               execvp("umount", argv);
                ERROR_WITH_ERRNO("Failed to execute `umount'");
                exit(WIMLIB_ERR_FUSERMOUNT);
        }
@@ -2392,24 +2407,14 @@ wimlib_mount_image(WIMStruct *wim, int image, const char *dir,
        if (ret)
                goto out;
 
-       if ((mount_flags & WIMLIB_MOUNT_FLAG_READWRITE) && (wim->hdr.total_parts != 1)) {
-               ERROR("Cannot mount a split WIM read-write");
-               ret = WIMLIB_ERR_SPLIT_UNSUPPORTED;
-               goto out;
-       }
-
-       if (num_additional_swms)
-               merge_lookup_tables(wim, additional_swms, num_additional_swms);
-
        if (mount_flags & WIMLIB_MOUNT_FLAG_READWRITE) {
-               ret = wim_run_full_verifications(wim);
+               ret = can_delete_from_wim(wim);
                if (ret)
-                       goto out_restore_lookup_table;
+                       goto out;
        }
 
-       ret = wim_checksum_unhashed_streams(wim);
-       if (ret)
-               goto out_restore_lookup_table;
+       if (num_additional_swms)
+               merge_lookup_tables(wim, additional_swms, num_additional_swms);
 
        ret = select_wim_image(wim, image);
        if (ret)
@@ -2529,7 +2534,9 @@ wimlib_mount_image(WIMStruct *wim, int image, const char *dir,
        DEBUG("Resolving lookup table entries and assigning inode numbers");
        ctx.next_ino = 1;
        image_for_each_inode(inode, imd) {
-               inode_resolve_ltes(inode, wim->lookup_table);
+               ret = inode_resolve_ltes(inode, wim->lookup_table);
+               if (ret)
+                       goto out_delete_staging_dir;
                inode->i_ino = ctx.next_ino++;
        }
        DEBUG("(next_ino = %"PRIu64")", ctx.next_ino);
@@ -2555,6 +2562,7 @@ wimlib_mount_image(WIMStruct *wim, int image, const char *dir,
 
        /* Try to delete the staging directory if a deletion wasn't yet
         * attempted due to an earlier error */
+out_delete_staging_dir:
        if (ctx.staging_dir_name)
                delete_staging_dir(&ctx);
 out_free_dir_copy:
@@ -2597,7 +2605,7 @@ wimlib_unmount_image(const char *dir, int unmount_flags,
        if (ret != 0)
                goto out_close_message_queues;
 
-       ret = execute_fusermount(dir);
+       ret = execute_fusermount(dir, (unmount_flags & WIMLIB_UNMOUNT_FLAG_LAZY) != 0);
        if (ret != 0)
                goto out_close_message_queues;