]> wimlib.net Git - wimlib/commitdiff
Doc updates and fix daemon polling
authorEric Biggers <ebiggers3@gmail.com>
Tue, 18 Dec 2012 06:28:08 +0000 (00:28 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 18 Dec 2012 06:28:08 +0000 (00:28 -0600)
doc/imagex-mount.1.in
src/mount_image.c
src/wimlib.h

index 708532202c3d4d844ba5695d16ea1b5fdc3faf81..83fd9f62cafb6136531049cbc50ae5498517d325 100644 (file)
@@ -150,21 +150,15 @@ Since a WIM is an archive and not a filesystem, \fBimagex mountrw\fR creates a
 temporary staging directory to contain files that are created or modified.  This
 directory is located in the same directory as \fIWIMFILE\fR by default, but the
 location can be set using the \fB--staging-dir\fR option.  When the filesystem
-is unmounted with \fB--commit\fR, the WIM is rebuilt, merging in the staging
-files as needed.  Then, the temporary staging directory is deleted.
-
-\fBimagex unmount\fR executes the \fBfusermount\fR (1) program, which should be
-installed as part of libfuse, to unmount the filesystem.  It then uses a POSIX
-message queue (see \fBmq_overview\fR (7)) to communicate with the filesystem
-daemon (the instance of \fBimagex\fR that has mounted the WIM image) so that it
-can know whether whether changes are to be committed and whether an integrity
-table is to be included.  A message is then sent from the filesystem daemon to
-unmounting process when the unmounting has been completed, and this message
-indicates whether the unmounting was successful or not.
-
-If the filesystem daemon has crashed or been killed, is possible for \fBimagex
-unmount\fR to wait a very long time before timing out.  A solution to this
-problem may be implemented in the future.
+is unmounted with \fB--commit\fR, the WIM is modified in-place (or rebuild
+completely with \fB--rebuild\fR), merging in the staging files as needed.  Then,
+the temporary staging directory is deleted.
+
+\fBimagex unmount\fR runs in a separate process from the process that previously
+ran \fBimagex mount\fR, and these two processes communicate using POSIX message
+queue.  See \fIsrc/mount_image.c\fR in the sources for details.  Note: As of wimlib
+v1.2.1, \fBimagex unmount\fR correctly fails with an error within a reasonable
+amount of time (1 second) if the filesystem daemon is abnormally terminated.
 
 .SH SEE ALSO
 .BR imagex (1)
index 7bede83da5026abd01e202c0e0f62e970d441511..fa7594b7b0efb38f1428f87d7ea349df28d4a363 100644 (file)
@@ -47,6 +47,7 @@
 #include <ftw.h>
 #include <mqueue.h>
 #include <utime.h>
+#include <signal.h>
 
 #ifdef ENABLE_XATTR
 #include <attr/xattr.h>
@@ -1012,13 +1013,11 @@ struct msg_handler_context {
        int timeout_seconds;
        union {
                struct {
-                       /*bool unmount_complete;*/
                        pid_t daemon_pid;
                        int mount_flags;
                        int status;
                } unmount;
                struct {
-                       /*int unmount_flags;*/
                        struct wimfs_context *wimfs_ctx;
                } daemon;
        };
@@ -1172,17 +1171,12 @@ static int unmount_timed_out_cb(struct msg_handler_context *handler_ctx)
        if (handler_ctx->unmount.daemon_pid == 0) {
                goto out_crashed;
        } else {
-               errno = 0;
                kill(handler_ctx->unmount.daemon_pid, 0);
                if (errno == ESRCH) {
                        goto out_crashed;
-               } else if (errno != 0) {
-                       ERROR_WITH_ERRNO("Error determining state of "
-                                        "filesystem daemon");
-                       return WIMLIB_ERR_MQUEUE;
                } else {
                        DEBUG("Filesystem daemon is still alive... "
-                             "Waiting another %d seconds",
+                             "Waiting another %d seconds\n",
                              handler_ctx->timeout_seconds);
                        return 0;
                }
@@ -1240,11 +1234,12 @@ static int receive_message(mqd_t mq, struct msg_handler_context *handler_ctx,
                                         mailbox_size, NULL, &timeout);
        hdr = mailbox;
        if (bytes_received == -1) {
-               ERROR_WITH_ERRNO("mq_timedreceive()");
-               if (errno == ETIMEDOUT)
+               if (errno == ETIMEDOUT) {
                        ret = WIMLIB_ERR_TIMEOUT;
-               else
+               } else {
+                       ERROR_WITH_ERRNO("mq_timedreceive()");
                        ret = WIMLIB_ERR_MQUEUE;
+               }
        } else if (bytes_received < sizeof(*hdr) ||
                   bytes_received != hdr->msg_size) {
                ret = WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE;
index 4225633ea17c2828d16ed7636fb2fd95fb08537a..c6a25410ee2d88c1241c282197767a2f5cfe9225 100644 (file)
@@ -1957,14 +1957,9 @@ extern int wimlib_split(WIMStruct *wim, const char *swm_name,
  *
  * To unmount the image, the thread calling this function communicates with the
  * thread that is managing the mounted WIM image.  This function blocks until it
- * is known whether the unmount succeeded or failed.  (This means until the
- * entire WIM has been re-written, in the case of a read-write mounted WIM.)
- *
- * There is currently a design problem with this function because it is hard to
- * know whether the filesystem thread is still working or whether it has crashed
- * or has been killed.  Currently, a timeout of 600 seconds (so long because
- * WIMs can be very large) is implemented so that this function will not wait
- * forever before returning failure.
+ * is known whether the unmount succeeded or failed.  In the case of a
+ * read-write mounted WIM, the unmount is not considered to have succeeded until
+ * all changes have been saved to the underlying WIM file.
  *
  * @param dir
  *     The directory that the WIM image was mounted on.
@@ -1977,9 +1972,13 @@ extern int wimlib_split(WIMStruct *wim, const char *swm_name,
  *     future.  Set to @c NULL.
  *
  * @return 0 on success; nonzero on error.
+ *
  * @retval ::WIMLIB_ERR_DELETE_STAGING_DIR
  *     The filesystem daemon was unable to remove the staging directory and the
  *     temporary files that it contains.
+ * @retval ::WIMLIB_ERR_FILESYSTEM_DAEMON_CRASHED
+ *     The filesystem daemon appears to have terminated before sending an exit
+ *     status.
  * @retval ::WIMLIB_ERR_FORK
  *     Could not @c fork() the process.
  * @retval ::WIMLIB_ERR_FUSERMOUNT
@@ -1994,10 +1993,6 @@ extern int wimlib_split(WIMStruct *wim, const char *swm_name,
  * @retval ::WIMLIB_ERR_OPEN
  *     The filesystem daemon could not open a temporary file for writing the
  *     new WIM.
- * @retval ::WIMLIB_ERR_TIMEOUT
- *     600 seconds elapsed while waiting for the filesystem daemon to notify
- *     the process of its exit status, so the WIM file probably was not written
- *     successfully.
  * @retval ::WIMLIB_ERR_READ
  *     A read error occurred when the filesystem daemon tried to a file from
  *     the staging directory