+
+struct unmount_msg_hdr {
+ u32 min_version;
+ u32 cur_version;
+ u32 msg_type;
+ u32 msg_size;
+} _packed_attribute;
+
+struct msg_unmount_request {
+ struct unmount_msg_hdr hdr;
+ u32 unmount_flags;
+ u8 want_progress_messages;
+} _packed_attribute;
+
+struct msg_daemon_info {
+ struct unmount_msg_hdr hdr;
+ pid_t daemon_pid;
+ u32 mount_flags;
+} _packed_attribute;
+
+struct msg_unmount_finished {
+ struct unmount_msg_hdr hdr;
+ s32 status;
+} _packed_attribute;
+
+struct msg_write_streams_progress {
+ struct unmount_msg_hdr hdr;
+ union wimlib_progress_info info;
+} _packed_attribute;
+
+enum {
+ MSG_TYPE_UNMOUNT_REQUEST,
+ MSG_TYPE_DAEMON_INFO,
+ MSG_TYPE_WRITE_STREAMS_PROGRESS,
+ MSG_TYPE_UNMOUNT_FINISHED,
+ MSG_TYPE_MAX,
+};
+
+struct msg_handler_context_hdr {
+ int timeout_seconds;
+};
+
+struct unmount_msg_handler_context {
+ struct msg_handler_context_hdr hdr;
+ pid_t daemon_pid;
+ int mount_flags;
+ int status;
+ wimlib_progress_func_t progress_func;
+};
+
+struct daemon_msg_handler_context {
+ struct msg_handler_context_hdr hdr;
+ struct wimfs_context *wimfs_ctx;
+};
+
+static int
+send_unmount_request_msg(mqd_t mq, int unmount_flags, u8 want_progress_messages)
+{
+ DEBUG("Sending unmount request msg");
+ struct msg_unmount_request msg = {
+ .hdr = {
+ .min_version = WIMLIB_MAKEVERSION(1, 2, 1),
+ .cur_version = WIMLIB_VERSION_CODE,
+ .msg_type = MSG_TYPE_UNMOUNT_REQUEST,
+ .msg_size = sizeof(msg),
+ },
+ .unmount_flags = unmount_flags,
+ .want_progress_messages = want_progress_messages,
+ };
+
+ if (mq_send(mq, (void*)&msg, sizeof(msg), 1)) {
+ ERROR_WITH_ERRNO("Failed to communicate with filesystem daemon");
+ return WIMLIB_ERR_MQUEUE;
+ }