diff options
author | Anton Altaparmakov <aia21@cantab.net> | 2006-03-23 15:53:03 (GMT) |
---|---|---|
committer | Anton Altaparmakov <aia21@cantab.net> | 2006-03-23 15:53:03 (GMT) |
commit | a0646a1f04f1ec4c7514e5b00496b54e054a2c99 (patch) | |
tree | 2cdf9023dd85b968a1cd3e4150019e1bbac19f1a /fs/ntfs/attrib.c | |
parent | 949763b2b8822c6dc6da0d0e1d4af092152546c2 (diff) | |
download | linux-a0646a1f04f1ec4c7514e5b00496b54e054a2c99.tar.xz |
NTFS: Add support for sparse files which have a compression unit of 0.
Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
Diffstat (limited to 'fs/ntfs/attrib.c')
-rw-r--r-- | fs/ntfs/attrib.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c index a92b9e9..7a568eb 100644 --- a/fs/ntfs/attrib.c +++ b/fs/ntfs/attrib.c @@ -1695,7 +1695,9 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size) a->data.non_resident.initialized_size = cpu_to_sle64(attr_size); if (NInoSparse(ni) || NInoCompressed(ni)) { - a->data.non_resident.compression_unit = 4; + a->data.non_resident.compression_unit = 0; + if (NInoCompressed(ni) || vol->major_ver < 3) + a->data.non_resident.compression_unit = 4; a->data.non_resident.compressed_size = a->data.non_resident.allocated_size; } else @@ -1714,13 +1716,20 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size) ni->allocated_size = new_size; if (NInoSparse(ni) || NInoCompressed(ni)) { ni->itype.compressed.size = ni->allocated_size; - ni->itype.compressed.block_size = 1U << - (a->data.non_resident.compression_unit + - vol->cluster_size_bits); - ni->itype.compressed.block_size_bits = - ffs(ni->itype.compressed.block_size) - 1; - ni->itype.compressed.block_clusters = 1U << - a->data.non_resident.compression_unit; + if (a->data.non_resident.compression_unit) { + ni->itype.compressed.block_size = 1U << (a->data. + non_resident.compression_unit + + vol->cluster_size_bits); + ni->itype.compressed.block_size_bits = + ffs(ni->itype.compressed.block_size) - + 1; + ni->itype.compressed.block_clusters = 1U << + a->data.non_resident.compression_unit; + } else { + ni->itype.compressed.block_size = 0; + ni->itype.compressed.block_size_bits = 0; + ni->itype.compressed.block_clusters = 0; + } vi->i_blocks = ni->itype.compressed.size >> 9; } else vi->i_blocks = ni->allocated_size >> 9; |