new = new_dentry_with_inode(basename);
if (!new)
- return -ENOMEM;
+ return -errno;
new->d_inode->resolved = 1;
new->d_inode->ino = ctx->next_ino++;
}
/* Parent */
- ret = wait(&status);
+ ret = waitpid(pid, &status, 0);
if (ret == -1) {
ERROR_WITH_ERRNO("Failed to wait for fusermount process to "
"terminate");
return WIMLIB_ERR_FUSERMOUNT;
}
- if (status != 0) {
- if (status == WIMLIB_ERR_FUSERMOUNT)
- ERROR("Could not find the `fusermount' program");
- else
- ERROR("fusermount exited with status %d", status);
+ if (!WIFEXITED(status)) {
+ ERROR("'fusermount' did not terminate normally!");
+ return WIMLIB_ERR_FUSERMOUNT;
+ }
- /* Try again, but with the `umount' program. This is required
- * on other FUSE implementations such as FreeBSD's that do not
- * have a `fusermount' program. */
+ status = WEXITSTATUS(status);
- pid = fork();
- if (pid == -1) {
- ERROR_WITH_ERRNO("Failed to fork()");
- return WIMLIB_ERR_FORK;
- }
- if (pid == 0) {
- /* Child */
- execlp("umount", "umount", dir, NULL);
- ERROR_WITH_ERRNO("Failed to execute `umount'");
- exit(WIMLIB_ERR_FUSERMOUNT);
- }
+ if (status == 0)
+ return 0;
- /* Parent */
- ret = wait(&status);
- if (ret == -1) {
- ERROR_WITH_ERRNO("Failed to wait for `umount' process to "
- "terminate");
- return WIMLIB_ERR_FUSERMOUNT;
- }
- if (status != 0) {
- ERROR("`umount' exited with failure status");
- return WIMLIB_ERR_FUSERMOUNT;
- }
+ if (status != WIMLIB_ERR_FUSERMOUNT)
+ return WIMLIB_ERR_FUSERMOUNT;
+
+ /* Try again, but with the `umount' program. This is required on other
+ * FUSE implementations such as FreeBSD's that do not have a
+ * `fusermount' program. */
+ ERROR("Falling back to 'umount'. Note: you may need to be "
+ "root for this to work");
+ pid = fork();
+ if (pid == -1) {
+ ERROR_WITH_ERRNO("Failed to fork()");
+ return WIMLIB_ERR_FORK;
+ }
+ if (pid == 0) {
+ /* Child */
+ execlp("umount", "umount", dir, NULL);
+ ERROR_WITH_ERRNO("Failed to execute `umount'");
+ exit(WIMLIB_ERR_FUSERMOUNT);
+ }
+
+ /* Parent */
+ ret = waitpid(pid, &status, 0);
+ if (ret == -1) {
+ ERROR_WITH_ERRNO("Failed to wait for `umount' process to "
+ "terminate");
+ return WIMLIB_ERR_FUSERMOUNT;
+ }
+ if (status != 0) {
+ ERROR("`umount' did not successfully complete");
+ return WIMLIB_ERR_FUSERMOUNT;
}
return 0;
}
return -EEXIST;
from_dentry = new_dentry(link_name);
if (!from_dentry)
- return -ENOMEM;
+ return -errno;
inode_add_dentry(from_dentry, inode);
from_dentry->d_inode = inode;
goto out;
}
+ if (imd->inode_list.first)
+ imd->inode_list.first->pprev = &imd->inode_list.first;
+
if (imd->modified) {
ERROR("Cannot mount image that was added "
"with wimlib_add_image()");