wimlib_mount_image(): Send final status after fuse_main() returns
authorEric Biggers <ebiggers3@gmail.com>
Tue, 5 Mar 2013 20:58:46 +0000 (14:58 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 5 Mar 2013 20:58:46 +0000 (14:58 -0600)
src/mount_image.c
src/util.c
src/wimlib.h
tests/test-imagex-mount

index b9b6345..6c5ec88 100644 (file)
@@ -109,6 +109,9 @@ struct wimfs_context {
 
        uid_t default_uid;
        gid_t default_gid;
+
+       int status;
+       bool have_status;
 };
 
 static void init_wimfs_context(struct wimfs_context *ctx)
@@ -1236,7 +1239,8 @@ out:
                                status = ret;
                }
        }
-       send_unmount_finished_msg(wimfs_ctx->daemon_to_unmount_mq, status);
+       wimfs_ctx->status = status;
+       wimfs_ctx->have_status = true;
        return MSG_BREAK_LOOP;
 }
 
@@ -1565,7 +1569,6 @@ static void wimfs_destroy(void *p)
                message_loop(wimfs_ctx->unmount_to_daemon_mq,
                             &daemon_msg_handler_callbacks,
                             &handler_ctx.hdr);
-               close_message_queues(wimfs_ctx);
        }
 }
 
@@ -2530,14 +2533,23 @@ WIMLIBAPI int wimlib_mount_image(WIMStruct *wim, int image, const char *dir,
 
        DEBUG("Returned from fuse_main() (ret = %d)", ret);
 
-       if (ret)
+       if (ret) {
                ret = WIMLIB_ERR_FUSE;
+       } else {
+               if (ctx.have_status)
+                       ret = ctx.status;
+               else
+                       ret = WIMLIB_ERR_TIMEOUT;
+       }
+       if (ctx.daemon_to_unmount_mq != (mqd_t)(-1)) {
+               send_unmount_finished_msg(ctx.daemon_to_unmount_mq, ret);
+               close_message_queues(&ctx);
+       }
 
        /* 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:
index f915f2f..f19f5a5 100644 (file)
@@ -137,6 +137,9 @@ static const char *error_strings[] = {
        [WIMLIB_ERR_FUSERMOUNT]
                = "Could not execute the `fusermount' program, or it exited "
                        "with a failure status",
+       [WIMLIB_ERR_ICONV_NOT_AVAILABLE]
+               = "The iconv() function does not seem to work. "
+                 "Maybe check to make sure the directory /usr/lib/gconv exists",
        [WIMLIB_ERR_IMAGE_COUNT]
                = "Inconsistent image count among the metadata "
                        "resources, the WIM header, and/or the XML data",
@@ -168,11 +171,10 @@ static const char *error_strings[] = {
                = "The part number or total parts of the WIM is invalid",
        [WIMLIB_ERR_INVALID_RESOURCE_HASH]
                = "The SHA1 message digest of a WIM resource did not match the expected value",
-       [WIMLIB_ERR_ICONV_NOT_AVAILABLE]
-               = "The iconv() function does not seem to work. "
-                 "Maybe check to make sure the directory /usr/lib/gconv exists",
        [WIMLIB_ERR_INVALID_RESOURCE_SIZE]
                = "A resource entry in the WIM has an invalid size",
+       [WIMLIB_ERR_INVALID_SECURITY_DATA]
+               = "The table of security descriptors in the WIM is invalid",
        [WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE]
                = "The version of wimlib that has mounted a WIM image is incompatible with the "
                  "version being used to unmount it",
@@ -223,6 +225,8 @@ static const char *error_strings[] = {
                = "The WIM is part of a split WIM, which is not supported for this operation",
        [WIMLIB_ERR_STAT]
                = "Could not read the metadata for a file or directory",
+       [WIMLIB_ERR_TIMEOUT]
+               = "Timed out while waiting for a message to arrive from another process",
        [WIMLIB_ERR_UNKNOWN_VERSION]
                = "The WIM file is marked with an unknown version number",
        [WIMLIB_ERR_UNSUPPORTED]
index 4395664..d1ee122 100644 (file)
@@ -711,6 +711,9 @@ typedef int (*wimlib_progress_func_t)(enum wimlib_progress_msg msg_type,
  * See the documentation for each wimlib function to see specifically what error
  * codes can be returned by a given function, and what they mean.
  */
+/* Note: these are currently in alphabetic order, but new error codes should be
+ * added at the end to maintain a compatible ABI, except when it's being broken
+ * anyway. */
 enum wimlib_error_code {
        WIMLIB_ERR_SUCCESS = 0,
        WIMLIB_ERR_ALREADY_LOCKED,
index 088e08b..906a3d6 100755 (executable)
@@ -54,8 +54,8 @@ for flag in "--compress=none" "--compress=maximum" "--compress=fast"; do
        fi
        mkdir tmp
        if ! imagex mount dir.wim dir tmp; then
-               error "Failed to mount test WIM read-only" \
-                     "Please read any error messages above before reporting this test failure."\
+               error "Failed to mount test WIM read-only" \
+                     "Please read any error messages above before reporting this test failure. "\
                      "Perhaps you don't have FUSE installed, or the FUSE kernel module isn't" \
                      "loaded, or you aren't a member of the FUSE group?"
        fi