- DEBUG("Handling unmount request msg");
-
- wimfs_ctx = handler_ctx->wimfs_ctx;
- if (msg->hdr.msg_size < sizeof(*msg)) {
- status = WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE;
- goto out;
- }
-
- unmount_flags = msg->unmount_flags;
- if (msg->want_progress_messages)
- progress_func = unmount_progress_func;
- else
- progress_func = NULL;
-
- ret = send_daemon_info_msg(wimfs_ctx->daemon_to_unmount_mq, getpid(),
- wimfs_ctx->mount_flags);
- if (ret != 0) {
- status = ret;
- goto out;
- }
-
- if (wimfs_ctx->mount_flags & WIMLIB_MOUNT_FLAG_READWRITE) {
- if (unmount_flags & WIMLIB_UNMOUNT_FLAG_COMMIT) {
-
- if (unmount_flags & WIMLIB_UNMOUNT_FLAG_NEW_IMAGE) {
- ret = renew_current_image(wimfs_ctx);
- if (ret) {
- status = ret;
- goto out;
- }
- } else {
- release_extra_refcnts(wimfs_ctx);
- }
- INIT_LIST_HEAD(&wimfs_ctx->orig_stream_list);
-
- 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;