X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fntfs-3g_apply.c;h=5f0e7c7ebbad122579b460a849c22529c6374288;hb=969809ef646ec6ceb9730da2eb21884feaff994d;hp=c61a8882ce4a9390fbbf55c73a6843b462af724e;hpb=cc7b6ee47d4037ae8fa11b4c2d5154091d543704;p=wimlib diff --git a/src/ntfs-3g_apply.c b/src/ntfs-3g_apply.c index c61a8882..5f0e7c7e 100644 --- a/src/ntfs-3g_apply.c +++ b/src/ntfs-3g_apply.c @@ -70,8 +70,6 @@ ntfs_3g_get_supported_features(const char *target, return 0; } -#define MAX_OPEN_ATTRS 1024 - struct ntfs_3g_apply_ctx { /* Extract flags, the pointer to the WIMStruct, etc. */ struct apply_ctx common; @@ -79,9 +77,9 @@ struct ntfs_3g_apply_ctx { /* Pointer to the open NTFS volume */ ntfs_volume *vol; - ntfs_attr *open_attrs[MAX_OPEN_ATTRS]; + ntfs_attr *open_attrs[MAX_OPEN_STREAMS]; unsigned num_open_attrs; - ntfs_inode *open_inodes[MAX_OPEN_ATTRS]; + ntfs_inode *open_inodes[MAX_OPEN_STREAMS]; unsigned num_open_inodes; struct reparse_buffer_disk rpbuf; @@ -91,8 +89,8 @@ struct ntfs_3g_apply_ctx { u64 offset; unsigned num_reparse_inodes; - ntfs_inode *ntfs_reparse_inodes[MAX_OPEN_ATTRS]; - struct wim_inode *wim_reparse_inodes[MAX_OPEN_ATTRS]; + ntfs_inode *ntfs_reparse_inodes[MAX_OPEN_STREAMS]; + struct wim_inode *wim_reparse_inodes[MAX_OPEN_STREAMS]; }; static size_t @@ -285,7 +283,7 @@ ntfs_3g_restore_dos_name(ntfs_inode *ni, ntfs_inode *dir_ni, goto out_close; if (!dir_ni) - dir_ni = ntfs_inode_open(vol, dentry->parent->d_inode->i_mft_no); + dir_ni = ntfs_inode_open(vol, dentry->d_parent->d_inode->i_mft_no); if (!ni) ni = ntfs_inode_open(vol, dentry->d_inode->i_mft_no); if (dir_ni && ni) { @@ -307,7 +305,7 @@ ntfs_3g_restore_dos_name(ntfs_inode *ni, ntfs_inode *dir_ni, /* Unlike most other NTFS-3g functions, ntfs_set_ntfs_dos_name() * changes the directory's last modification timestamp... * Change it back. */ - return ntfs_3g_restore_timestamps(vol, dentry->parent->d_inode); + return ntfs_3g_restore_timestamps(vol, dentry->d_parent->d_inode); out_close: /* ntfs_inode_close() can take a NULL argument, but it's probably best @@ -403,9 +401,10 @@ ntfs_3g_set_metadata(ntfs_inode *ni, const struct wim_inode *inode, ERROR_WITH_ERRNO("Failed to set security descriptor " "on \"%s\" in NTFS volume", dentry_full_path(one_dentry)); - fprintf(stderr, "The security descriptor is: "); - print_byte_field(desc, desc_size, stderr); - fprintf(stderr, "\n"); + fprintf(wimlib_error_file, + "The security descriptor is: "); + print_byte_field(desc, desc_size, wimlib_error_file); + fprintf(wimlib_error_file, "\n"); } return ret; } @@ -426,7 +425,7 @@ ntfs_3g_set_metadata(ntfs_inode *ni, const struct wim_inode *inode, * the NTFS inode @dir_ni. */ static int ntfs_3g_create_dirs_recursive(ntfs_inode *dir_ni, struct wim_dentry *dir, - const struct ntfs_3g_apply_ctx *ctx) + struct ntfs_3g_apply_ctx *ctx) { struct wim_dentry *child; @@ -449,7 +448,9 @@ ntfs_3g_create_dirs_recursive(ntfs_inode *dir_ni, struct wim_dentry *dir, child->d_inode->i_mft_no = ni->mft_no; - ret = ntfs_3g_set_metadata(ni, child->d_inode, ctx); + ret = report_file_created(&ctx->common); + if (!ret) + ret = ntfs_3g_set_metadata(ni, child->d_inode, ctx); if (!ret) ret = ntfs_3g_create_any_empty_ads(ni, child->d_inode, ctx); if (!ret) @@ -471,7 +472,7 @@ ntfs_3g_create_dirs_recursive(ntfs_inode *dir_ni, struct wim_dentry *dir, static int ntfs_3g_create_directories(struct wim_dentry *root, struct list_head *dentry_list, - const struct ntfs_3g_apply_ctx *ctx) + struct ntfs_3g_apply_ctx *ctx) { ntfs_inode *root_ni; int ret; @@ -505,6 +506,9 @@ ntfs_3g_create_directories(struct wim_dentry *root, ret = ntfs_3g_restore_dos_name(NULL, NULL, dentry, ctx->vol); if (ret) return ret; + ret = report_file_created(&ctx->common); + if (ret) + return ret; } return 0; } @@ -543,7 +547,7 @@ ntfs_3g_add_link(ntfs_inode *ni, struct wim_dentry *dentry) int res; /* Open the inode of the parent directory. */ - dir_ni = ntfs_inode_open(ni->vol, dentry->parent->d_inode->i_mft_no); + dir_ni = ntfs_inode_open(ni->vol, dentry->d_parent->d_inode->i_mft_no); if (!dir_ni) goto fail; @@ -578,10 +582,10 @@ ntfs_3g_create_nondirectory(struct wim_inode *inode, /* Create first link. */ - dir_ni = ntfs_inode_open(ctx->vol, first_dentry->parent->d_inode->i_mft_no); + dir_ni = ntfs_inode_open(ctx->vol, first_dentry->d_parent->d_inode->i_mft_no); if (!dir_ni) { ERROR_WITH_ERRNO("Can't open \"%s\" in NTFS volume", - dentry_full_path(first_dentry->parent)); + dentry_full_path(first_dentry->d_parent)); return WIMLIB_ERR_NTFS_3G; } @@ -619,7 +623,7 @@ ntfs_3g_create_nondirectory(struct wim_inode *inode, /* Close the directory in which the first link was created. */ if (ntfs_inode_close(dir_ni)) { ERROR_WITH_ERRNO("Failed to close \"%s\" in NTFS volume", - dentry_full_path(first_dentry->parent)); + dentry_full_path(first_dentry->d_parent)); ret = WIMLIB_ERR_NTFS_3G; goto out_close_ni; } @@ -627,7 +631,6 @@ ntfs_3g_create_nondirectory(struct wim_inode *inode, /* Create additional links if present. */ next = inode->i_extraction_aliases.next; - ret = 0; do { dentry = list_entry(next, struct wim_dentry, d_extraction_alias_node); @@ -662,7 +665,7 @@ out_close_ni: * Directories must have already been created. */ static int ntfs_3g_create_nondirectories(struct list_head *dentry_list, - const struct ntfs_3g_apply_ctx *ctx) + struct ntfs_3g_apply_ctx *ctx) { struct wim_dentry *dentry; struct wim_inode *inode; @@ -677,6 +680,9 @@ ntfs_3g_create_nondirectories(struct list_head *dentry_list, ret = ntfs_3g_create_nondirectory(inode, ctx); if (ret) return ret; + ret = report_file_created(&ctx->common); + if (ret) + return ret; } return 0; } @@ -726,6 +732,9 @@ ntfs_3g_begin_extract_stream_to_attr(struct wim_lookup_table_entry *stream, return WIMLIB_ERR_NTFS_3G; } + /* This should be ensured by extract_stream_list() */ + wimlib_assert(ctx->num_open_attrs < MAX_OPEN_STREAMS); + attr = ntfs_attr_open(ni, AT_DATA, stream_name, stream_name_nchars); if (!attr) { ERROR_WITH_ERRNO("Failed to open data stream of \"%s\"", @@ -791,8 +800,7 @@ ntfs_3g_open_inode(struct wim_inode *inode, struct ntfs_3g_apply_ctx *ctx) } static int -ntfs_3g_begin_extract_stream(struct wim_lookup_table_entry *stream, - u32 flags, void *_ctx) +ntfs_3g_begin_extract_stream(struct wim_lookup_table_entry *stream, void *_ctx) { struct ntfs_3g_apply_ctx *ctx = _ctx; const struct stream_owner *owners = stream_owners(stream); @@ -908,6 +916,8 @@ ntfs_3g_extract(struct list_head *dentry_list, struct apply_ctx *_ctx) /* Create all inodes and aliases, including short names, and set * metadata (attributes, security descriptors, and timestamps). */ + reset_file_progress(&ctx->common); + ret = ntfs_3g_create_directories(root, dentry_list, ctx); if (ret) goto out_unmount;