fixed compressions on parent directory or NTFS version < 3.0

This commit is contained in:
Jean-Pierre André 2010-05-25 09:52:34 +02:00
parent 74134fc76d
commit 51a9ab8c48
2 changed files with 16 additions and 1 deletions

View File

@ -465,9 +465,13 @@ ntfs_attr *ntfs_attr_open(ntfs_inode *ni, const ATTR_TYPES type,
* inode (for named data streams). The compression mark
* may change any time, the compression state can only
* change when stream is wiped out.
*
* Also prevent compression on NTFS version < 3.0
* or if cluster size > 4K
*/
a->flags &= ~ATTR_COMPRESSION_MASK;
if ((na->ni->flags & FILE_ATTR_COMPRESSED)
if ((ni->flags & FILE_ATTR_COMPRESSED)
&& (ni->vol->major_ver >= 3)
&& (ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE))
a->flags |= ATTR_IS_COMPRESSED;
}
@ -3704,6 +3708,7 @@ int ntfs_attr_add(ntfs_inode *ni, ATTR_TYPES type,
add_attr_record:
if ((ni->flags & FILE_ATTR_COMPRESSED)
&& (ni->vol->major_ver >= 3)
&& (ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE)
&& ((type == AT_DATA)
|| ((type == AT_INDEX_ROOT) && (name == NTFS_INDEX_I30))))
@ -4673,6 +4678,7 @@ static int ntfs_attr_make_resident(ntfs_attr *na, ntfs_attr_search_ctx *ctx)
*/
if (!na->data_size
&& (na->type == AT_DATA)
&& (na->ni->vol->major_ver >= 3)
&& (na->ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE)
&& (na->ni->flags & FILE_ATTR_COMPRESSED)) {
a->flags |= ATTR_IS_COMPRESSED;

View File

@ -1397,7 +1397,16 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni, le32 securid,
ni->flags = FILE_ATTR_SYSTEM;
}
ni->flags |= FILE_ATTR_ARCHIVE;
/*
* Set compression flag according to parent directory
* unless NTFS version < 3.0 or cluster size > 4K
* or parent directory is root directory (this is to
* avoid problems with boot loaders).
*/
if ((dir_ni->flags & FILE_ATTR_COMPRESSED)
&& (dir_ni->mft_no != FILE_root)
&& (dir_ni->vol->major_ver >= 3)
&& (dir_ni->vol->cluster_size <= MAX_COMPRESSION_CLUSTER_SIZE)
&& (S_ISREG(type) || S_ISDIR(type)))
ni->flags |= FILE_ATTR_COMPRESSED;
/* Add STANDARD_INFORMATION to inode. */