From: Eric Biggers Date: Wed, 19 Dec 2012 18:46:08 +0000 (-0600) Subject: write_ntfs_data_streams(): Reserve space for streams X-Git-Tag: v1.2.1~8 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=82e0045e9a93baed16ca1fa1bbe5accfcf11cf6c write_ntfs_data_streams(): Reserve space for streams Call ntfs_attr_truncate_solid() with the size of each stream before extracting it as a NTFS attribute. This should allocate the space (extents, etc.) needed for the data before actually extracting it. --- diff --git a/src/ntfs-apply.c b/src/ntfs-apply.c index ab46c917..090d5a1a 100644 --- a/src/ntfs-apply.c +++ b/src/ntfs-apply.c @@ -90,7 +90,6 @@ static int write_ntfs_data_streams(ntfs_inode *ni, const struct dentry *dentry, while (1) { struct lookup_table_entry *lte; - ntfs_attr *na; lte = inode_stream_lte_resolved(inode, stream_idx); @@ -112,6 +111,8 @@ static int write_ntfs_data_streams(ntfs_inode *ni, const struct dentry *dentry, * Otherwise, we must open the attribute and extract the data. * */ if (lte) { + ntfs_attr *na; + na = ntfs_attr_open(ni, AT_DATA, stream_name, stream_name_len); if (!na) { ERROR_WITH_ERRNO("Failed to open a data stream of " @@ -120,11 +121,17 @@ static int write_ntfs_data_streams(ntfs_inode *ni, const struct dentry *dentry, ret = WIMLIB_ERR_NTFS_3G; break; } + ret = ntfs_attr_truncate_solid(na, wim_resource_size(lte)); + if (ret != 0) { + ntfs_attr_close(na); + break; + } + ret = extract_wim_resource_to_ntfs_attr(lte, na); + ntfs_attr_close(na); if (ret != 0) break; args->progress.extract.completed_bytes += wim_resource_size(lte); - ntfs_attr_close(na); } if (stream_idx == inode->num_ads) break;