From 39e281d7a53eb18cffeca94c17d5df746ce31db4 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Thu, 8 Sep 2005 22:04:20 +0100 Subject: [PATCH] --- yaml --- r: 7775 b: refs/heads/master c: 311120eca0013083f5eb0aff13ffb8aa9fdd050c h: refs/heads/master i: 7773: 48046537118ad753a2d14a992b4ef473b1defc4e 7771: be04979486022d3c7eac2513f0097cb72622af18 7767: b5158bfec2ea1ecc83a4a02a20e2a00bf34b9848 7759: 6011e1603e5988609d691111b98edce88d2105a2 7743: e5c3c2712dc67565ea61658b8ec03345ae1a0448 v: v3 --- [refs] | 2 +- trunk/fs/ntfs/ChangeLog | 5 ++--- trunk/fs/ntfs/aops.c | 41 ++++++++++++++++++++++++----------------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/[refs] b/[refs] index 26946af8014e..00425b257db9 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 8273d5d4c28a9fde68f830cc6ff61e37e8ae1dca +refs/heads/master: 311120eca0013083f5eb0aff13ffb8aa9fdd050c diff --git a/trunk/fs/ntfs/ChangeLog b/trunk/fs/ntfs/ChangeLog index 7f24cb19c69e..c3b510210743 100644 --- a/trunk/fs/ntfs/ChangeLog +++ b/trunk/fs/ntfs/ChangeLog @@ -76,11 +76,10 @@ ToDo/Notes: - Truncate {a,c,m}time to the ntfs supported time granularity when updating the times in the inode in ntfs_setattr(). - Fixup handling of sparse, compressed, and encrypted attributes in - fs/ntfs/inode.c::ntfs_read_locked_{,attr_,index_}inode(). + fs/ntfs/inode.c::ntfs_read_locked_{,attr_,index_}inode(), + fs/ntfs/aops.c::ntfs_{read,write}page(). - Make ntfs_write_block() not instantiate sparse blocks if they contain only zeroes. - - Fixup handling of sparse, compressed, and encrypted attributes in - fs/ntfs/aops.c::ntfs_writepage(). - Optimize fs/ntfs/aops.c::ntfs_write_block() by extending the page lock protection over the buffer submission for i/o which allows the removal of the get_bh()/put_bh() pairs for each buffer. diff --git a/trunk/fs/ntfs/aops.c b/trunk/fs/ntfs/aops.c index 59389a8801bc..2482b677a82a 100644 --- a/trunk/fs/ntfs/aops.c +++ b/trunk/fs/ntfs/aops.c @@ -379,31 +379,38 @@ static int ntfs_readpage(struct file *file, struct page *page) return 0; } ni = NTFS_I(page->mapping->host); - + /* + * Only $DATA attributes can be encrypted and only unnamed $DATA + * attributes can be compressed. Index root can have the flags set but + * this means to create compressed/encrypted files, not that the + * attribute is compressed/encrypted. + */ + if (ni->type != AT_INDEX_ROOT) { + /* If attribute is encrypted, deny access, just like NT4. */ + if (NInoEncrypted(ni)) { + BUG_ON(ni->type != AT_DATA); + err = -EACCES; + goto err_out; + } + /* Compressed data streams are handled in compress.c. */ + if (NInoNonResident(ni) && NInoCompressed(ni)) { + BUG_ON(ni->type != AT_DATA); + BUG_ON(ni->name_len); + return ntfs_read_compressed_block(page); + } + } /* NInoNonResident() == NInoIndexAllocPresent() */ if (NInoNonResident(ni)) { - /* - * Only unnamed $DATA attributes can be compressed or - * encrypted. - */ - if (ni->type == AT_DATA && !ni->name_len) { - /* If file is encrypted, deny access, just like NT4. */ - if (NInoEncrypted(ni)) { - err = -EACCES; - goto err_out; - } - /* Compressed data streams are handled in compress.c. */ - if (NInoCompressed(ni)) - return ntfs_read_compressed_block(page); - } - /* Normal data stream. */ + /* Normal, non-resident data stream. */ return ntfs_read_block(page); } /* * Attribute is resident, implying it is not compressed or encrypted. * This also means the attribute is smaller than an mft record and * hence smaller than a page, so can simply zero out any pages with - * index above 0. + * index above 0. Note the attribute can actually be marked compressed + * but if it is resident the actual data is not compressed so we are + * ok to ignore the compressed flag here. */ if (unlikely(page->index > 0)) { kaddr = kmap_atomic(page, KM_USER0);