- xml_update_image_info(w, w->current_image);
- ret = wimlib_overwrite(w, write_flags, 0, NULL);
- if (ret != 0)
- ERROR("Failed to commit changes to mounted WIM image");
- return ret;
+ if (wimfs_ctx->mount_flags & WIMLIB_MOUNT_FLAG_READWRITE) {
+ if (unmount_flags & WIMLIB_UNMOUNT_FLAG_COMMIT) {
+ int write_flags = 0;
+ if (unmount_flags & WIMLIB_UNMOUNT_FLAG_CHECK_INTEGRITY)
+ write_flags |= WIMLIB_WRITE_FLAG_CHECK_INTEGRITY;
+ if (unmount_flags & WIMLIB_UNMOUNT_FLAG_REBUILD)
+ write_flags |= WIMLIB_WRITE_FLAG_REBUILD;
+ if (unmount_flags & WIMLIB_UNMOUNT_FLAG_RECOMPRESS)
+ write_flags |= WIMLIB_WRITE_FLAG_RECOMPRESS;
+ status = rebuild_wim(wimfs_ctx, write_flags,
+ progress_func);
+ }
+ } else {
+ DEBUG("Read-only mount");
+ status = 0;
+ }
+
+out:
+ if (wimfs_ctx->mount_flags & WIMLIB_MOUNT_FLAG_READWRITE) {
+ ret = delete_staging_dir(wimfs_ctx);
+ if (ret != 0) {
+ ERROR("Failed to delete the staging directory");
+ if (status == 0)
+ status = ret;
+ }
+ }
+ wimfs_ctx->status = status;
+ wimfs_ctx->have_status = true;
+ return MSG_BREAK_LOOP;
+}
+
+static int
+msg_daemon_info_handler(const void *_msg, void *_handler_ctx)
+{
+ const struct msg_daemon_info *msg = _msg;
+ struct unmount_msg_handler_context *handler_ctx = _handler_ctx;
+
+ DEBUG("Handling daemon info msg");
+ if (msg->hdr.msg_size < sizeof(*msg))
+ return WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE;
+ handler_ctx->daemon_pid = msg->daemon_pid;
+ handler_ctx->mount_flags = msg->mount_flags;
+ handler_ctx->hdr.timeout_seconds = 1;
+ DEBUG("pid of daemon is %d; mount flags were %#x",
+ handler_ctx->daemon_pid,
+ handler_ctx->mount_flags);
+ return 0;