X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fmount_image.c;h=839acbc86f51947378fcbd3aa0ec9884bf1755e9;hb=811a38dfe05ef337e2d627f654f8a3e559900790;hp=b9b63450868866832b3a24b5f10254c7057f12b4;hpb=4016a9dba036f4d2eca0253c99370e6647a9ccb6;p=wimlib diff --git a/src/mount_image.c b/src/mount_image.c index b9b63450..839acbc8 100644 --- a/src/mount_image.c +++ b/src/mount_image.c @@ -8,7 +8,7 @@ */ /* - * Copyright (C) 2012 Eric Biggers + * Copyright (C) 2012, 2013 Eric Biggers * * This file is part of wimlib, a library for working with WIM files. * @@ -109,6 +109,9 @@ struct wimfs_context { uid_t default_uid; gid_t default_gid; + + int status; + bool have_status; }; static void init_wimfs_context(struct wimfs_context *ctx) @@ -1236,7 +1239,8 @@ out: status = ret; } } - send_unmount_finished_msg(wimfs_ctx->daemon_to_unmount_mq, status); + wimfs_ctx->status = status; + wimfs_ctx->have_status = true; return MSG_BREAK_LOOP; } @@ -1565,7 +1569,6 @@ static void wimfs_destroy(void *p) message_loop(wimfs_ctx->unmount_to_daemon_mq, &daemon_msg_handler_callbacks, &handler_ctx.hdr); - close_message_queues(wimfs_ctx); } } @@ -2112,7 +2115,6 @@ static int wimfs_setxattr(const char *path, const char *name, if (existing_ads_entry) { if (flags & XATTR_CREATE) return -EEXIST; - inode_remove_ads(inode, ads_idx, ctx->wim->lookup_table); } else { if (flags & XATTR_REPLACE) return -ENOATTR; @@ -2120,7 +2122,13 @@ static int wimfs_setxattr(const char *path, const char *name, ret = inode_add_ads_with_data(inode, name, (const u8*)value, size, ctx->wim->lookup_table); - return ret ? -ENOMEM : 0; + if (ret == 0) { + if (existing_ads_entry) + inode_remove_ads(inode, ads_idx, ctx->wim->lookup_table); + } else { + ret = -ENOMEM; + } + return ret; } #endif @@ -2530,14 +2538,23 @@ WIMLIBAPI int wimlib_mount_image(WIMStruct *wim, int image, const char *dir, DEBUG("Returned from fuse_main() (ret = %d)", ret); - if (ret) + if (ret) { ret = WIMLIB_ERR_FUSE; + } else { + if (ctx.have_status) + ret = ctx.status; + else + ret = WIMLIB_ERR_TIMEOUT; + } + if (ctx.daemon_to_unmount_mq != (mqd_t)(-1)) { + send_unmount_finished_msg(ctx.daemon_to_unmount_mq, ret); + close_message_queues(&ctx); + } /* Try to delete the staging directory if a deletion wasn't yet * attempted due to an earlier error */ if (ctx.staging_dir_name) delete_staging_dir(&ctx); - out_free_dir_copy: FREE(dir_copy); out_unlock: @@ -2608,8 +2625,12 @@ out: static inline int mount_unsupported_error() { +#if defined(__CYGWIN__) || defined (__WIN32__) + ERROR("Sorry-- Mounting WIM images is not supported on Windows!"); +#else ERROR("wimlib was compiled with --without-fuse, which disables support " "for mounting WIMs."); +#endif return WIMLIB_ERR_UNSUPPORTED; }