X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fmount_image.c;h=af39246128e2fdffa04fe256c49bb6f507abbd03;hb=cdf7299e77148206b8a4cb665ddd7a00a0e8ed91;hp=905157c08101e111cfe78d6cc0fcfe7f05f60689;hpb=49893f3a5c7cd5bfe962c3b63b299ee713170b8e;p=wimlib diff --git a/src/mount_image.c b/src/mount_image.c index 905157c0..af392461 100644 --- a/src/mount_image.c +++ b/src/mount_image.c @@ -758,7 +758,7 @@ static int update_lte_of_staging_file(struct wim_lookup_table_entry *lte, inode_update_lte_ptr(lte->lte_inode, lte, NULL); free_lookup_table_entry(lte); } else { - wimlib_assert(<e->file_on_disk == <e->staging_file_name); + BUILD_BUG_ON(<e->file_on_disk != <e->staging_file_name); lte->resource_entry.original_size = stbuf.st_size; lte->resource_entry.size = stbuf.st_size; lte->resource_location = RESOURCE_IN_FILE_ON_DISK; @@ -802,7 +802,7 @@ static int rebuild_wim(struct wimfs_context *ctx, int write_flags, } DEBUG("Calculating SHA1 checksums for all new staging files."); - list_for_each_entry(lte, &ctx->staging_list, staging_list) { + list_for_each_entry_safe(lte, tmp, &ctx->staging_list, staging_list) { ret = update_lte_of_staging_file(lte, w->lookup_table); if (ret != 0) return ret; @@ -848,12 +848,9 @@ static int set_message_queue_names(struct wimfs_context *ctx, return WIMLIB_ERR_NOTDIR; } - p = dir_path; - while (*p) { + for (p = dir_path; *p; p++) if (*p == '/') *p = 0xff; - p++; - } ctx->unmount_to_daemon_mq_name = strcat_dup(u2d_prefix, dir_path, NAME_MAX); @@ -1613,15 +1610,13 @@ static int wimfs_link(const char *to, const char *from) if (!inode) return -errno; - if (inode->i_attributes & FILE_ATTRIBUTE_REPARSE_POINT) - return -EEXIST; - - if (inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY) + if (inode->i_attributes & (FILE_ATTRIBUTE_DIRECTORY | + FILE_ATTRIBUTE_REPARSE_POINT)) return -EPERM; from_dentry_parent = get_parent_dentry(w, from); if (!from_dentry_parent) - return -ENOENT; + return -errno; if (!dentry_is_directory(from_dentry_parent)) return -ENOTDIR; @@ -1779,7 +1774,7 @@ static int wimfs_open(const char *path, struct fuse_file_info *fi) } ret = alloc_wimfs_fd(inode, stream_id, lte, &fd, - wimfs_ctx_readonly(ctx)); + wimfs_ctx_readonly(ctx)); if (ret != 0) return ret; @@ -2002,7 +1997,7 @@ static int wimfs_rename(const char *from, const char *to) return -ENOTDIR; } - ret = set_dentry_name(src, to); + ret = set_dentry_name(src, path_basename(to)); if (ret != 0) return -ENOMEM; if (dst) @@ -2330,7 +2325,7 @@ WIMLIBAPI int wimlib_mount_image(WIMStruct *wim, int image, const char *dir, unsigned num_additional_swms, const char *staging_dir) { - int argc = 0; + int argc; char *argv[16]; int ret; char *dir_copy; @@ -2430,6 +2425,7 @@ WIMLIBAPI int wimlib_mount_image(WIMStruct *wim, int image, const char *dir, if (!dir_copy) goto out_free_message_queue_names; + argc = 0; argv[argc++] = "imagex"; argv[argc++] = dir_copy; @@ -2501,6 +2497,12 @@ WIMLIBAPI int wimlib_mount_image(WIMStruct *wim, int image, const char *dir, if (ret) ret = WIMLIB_ERR_FUSE; + + /* 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: