aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ecryptfs/inode.c')
-rw-r--r--fs/ecryptfs/inode.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 1548be26b5e6..0981ae35ea16 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -800,6 +800,25 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
800 goto out_fput; 800 goto out_fput;
801 } 801 }
802 } else { /* new_length < i_size_read(inode) */ 802 } else { /* new_length < i_size_read(inode) */
803 pgoff_t index = 0;
804 int end_pos_in_page = -1;
805
806 if (new_length != 0) {
807 index = ((new_length - 1) >> PAGE_CACHE_SHIFT);
808 end_pos_in_page = ((new_length - 1) & ~PAGE_CACHE_MASK);
809 }
810 if (end_pos_in_page != (PAGE_CACHE_SIZE - 1)) {
811 if ((rc = ecryptfs_write_zeros(&fake_ecryptfs_file,
812 index,
813 (end_pos_in_page + 1),
814 ((PAGE_CACHE_SIZE - 1)
815 - end_pos_in_page)))) {
816 printk(KERN_ERR "Error attempting to zero out "
817 "the remainder of the end page on "
818 "reducing truncate; rc = [%d]\n", rc);
819 goto out_fput;
820 }
821 }
803 vmtruncate(inode, new_length); 822 vmtruncate(inode, new_length);
804 rc = ecryptfs_write_inode_size_to_metadata( 823 rc = ecryptfs_write_inode_size_to_metadata(
805 lower_file, lower_dentry->d_inode, inode, dentry, 824 lower_file, lower_dentry->d_inode, inode, dentry,