diff options
author | Anton Altaparmakov <aia21@cantab.net> | 2005-09-08 17:04:20 -0400 |
---|---|---|
committer | Anton Altaparmakov <aia21@cantab.net> | 2005-09-08 17:04:20 -0400 |
commit | 311120eca0013083f5eb0aff13ffb8aa9fdd050c (patch) | |
tree | f93f77b4fc129b45d7b72c180e9e30a592959d4e /fs/ntfs/aops.c | |
parent | 8273d5d4c28a9fde68f830cc6ff61e37e8ae1dca (diff) |
NTFS: Fixup handling of sparse, compressed, and encrypted attributes in
fs/ntfs/aops.c::ntfs_readpage().
Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
Diffstat (limited to 'fs/ntfs/aops.c')
-rw-r--r-- | fs/ntfs/aops.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 59389a8801bc..2482b677a82a 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c | |||
@@ -379,31 +379,38 @@ retry_readpage: | |||
379 | return 0; | 379 | return 0; |
380 | } | 380 | } |
381 | ni = NTFS_I(page->mapping->host); | 381 | ni = NTFS_I(page->mapping->host); |
382 | 382 | /* | |
383 | * Only $DATA attributes can be encrypted and only unnamed $DATA | ||
384 | * attributes can be compressed. Index root can have the flags set but | ||
385 | * this means to create compressed/encrypted files, not that the | ||
386 | * attribute is compressed/encrypted. | ||
387 | */ | ||
388 | if (ni->type != AT_INDEX_ROOT) { | ||
389 | /* If attribute is encrypted, deny access, just like NT4. */ | ||
390 | if (NInoEncrypted(ni)) { | ||
391 | BUG_ON(ni->type != AT_DATA); | ||
392 | err = -EACCES; | ||
393 | goto err_out; | ||
394 | } | ||
395 | /* Compressed data streams are handled in compress.c. */ | ||
396 | if (NInoNonResident(ni) && NInoCompressed(ni)) { | ||
397 | BUG_ON(ni->type != AT_DATA); | ||
398 | BUG_ON(ni->name_len); | ||
399 | return ntfs_read_compressed_block(page); | ||
400 | } | ||
401 | } | ||
383 | /* NInoNonResident() == NInoIndexAllocPresent() */ | 402 | /* NInoNonResident() == NInoIndexAllocPresent() */ |
384 | if (NInoNonResident(ni)) { | 403 | if (NInoNonResident(ni)) { |
385 | /* | 404 | /* Normal, non-resident data stream. */ |
386 | * Only unnamed $DATA attributes can be compressed or | ||
387 | * encrypted. | ||
388 | */ | ||
389 | if (ni->type == AT_DATA && !ni->name_len) { | ||
390 | /* If file is encrypted, deny access, just like NT4. */ | ||
391 | if (NInoEncrypted(ni)) { | ||
392 | err = -EACCES; | ||
393 | goto err_out; | ||
394 | } | ||
395 | /* Compressed data streams are handled in compress.c. */ | ||
396 | if (NInoCompressed(ni)) | ||
397 | return ntfs_read_compressed_block(page); | ||
398 | } | ||
399 | /* Normal data stream. */ | ||
400 | return ntfs_read_block(page); | 405 | return ntfs_read_block(page); |
401 | } | 406 | } |
402 | /* | 407 | /* |
403 | * Attribute is resident, implying it is not compressed or encrypted. | 408 | * Attribute is resident, implying it is not compressed or encrypted. |
404 | * This also means the attribute is smaller than an mft record and | 409 | * This also means the attribute is smaller than an mft record and |
405 | * hence smaller than a page, so can simply zero out any pages with | 410 | * hence smaller than a page, so can simply zero out any pages with |
406 | * index above 0. | 411 | * index above 0. Note the attribute can actually be marked compressed |
412 | * but if it is resident the actual data is not compressed so we are | ||
413 | * ok to ignore the compressed flag here. | ||
407 | */ | 414 | */ |
408 | if (unlikely(page->index > 0)) { | 415 | if (unlikely(page->index > 0)) { |
409 | kaddr = kmap_atomic(page, KM_USER0); | 416 | kaddr = kmap_atomic(page, KM_USER0); |