@@ -142,19 +142,10 @@ ecryptfs_do_create(struct inode *directory_inode,
142142static int grow_file (struct dentry * ecryptfs_dentry )
143143{
144144 struct inode * ecryptfs_inode = ecryptfs_dentry -> d_inode ;
145- struct file fake_file ;
146- struct ecryptfs_file_info tmp_file_info ;
147145 char zero_virt [] = { 0x00 };
148146 int rc = 0 ;
149147
150- memset (& fake_file , 0 , sizeof (fake_file ));
151- fake_file .f_path .dentry = ecryptfs_dentry ;
152- memset (& tmp_file_info , 0 , sizeof (tmp_file_info ));
153- ecryptfs_set_file_private (& fake_file , & tmp_file_info );
154- ecryptfs_set_file_lower (
155- & fake_file ,
156- ecryptfs_inode_to_private (ecryptfs_inode )-> lower_file );
157- rc = ecryptfs_write (& fake_file , zero_virt , 0 , 1 );
148+ rc = ecryptfs_write (ecryptfs_inode , zero_virt , 0 , 1 );
158149 i_size_write (ecryptfs_inode , 0 );
159150 rc = ecryptfs_write_inode_size_to_metadata (ecryptfs_inode );
160151 ecryptfs_inode_to_private (ecryptfs_inode )-> crypt_stat .flags |=
@@ -784,8 +775,6 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
784775{
785776 int rc = 0 ;
786777 struct inode * inode = dentry -> d_inode ;
787- struct dentry * lower_dentry ;
788- struct file fake_ecryptfs_file ;
789778 struct ecryptfs_crypt_stat * crypt_stat ;
790779 loff_t i_size = i_size_read (inode );
791780 loff_t lower_size_before_truncate ;
@@ -796,23 +785,6 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
796785 goto out ;
797786 }
798787 crypt_stat = & ecryptfs_inode_to_private (dentry -> d_inode )-> crypt_stat ;
799- /* Set up a fake ecryptfs file, this is used to interface with
800- * the file in the underlying filesystem so that the
801- * truncation has an effect there as well. */
802- memset (& fake_ecryptfs_file , 0 , sizeof (fake_ecryptfs_file ));
803- fake_ecryptfs_file .f_path .dentry = dentry ;
804- /* Released at out_free: label */
805- ecryptfs_set_file_private (& fake_ecryptfs_file ,
806- kmem_cache_alloc (ecryptfs_file_info_cache ,
807- GFP_KERNEL ));
808- if (unlikely (!ecryptfs_file_to_private (& fake_ecryptfs_file ))) {
809- rc = - ENOMEM ;
810- goto out ;
811- }
812- lower_dentry = ecryptfs_dentry_to_lower (dentry );
813- ecryptfs_set_file_lower (
814- & fake_ecryptfs_file ,
815- ecryptfs_inode_to_private (dentry -> d_inode )-> lower_file );
816788 /* Switch on growing or shrinking file */
817789 if (ia -> ia_size > i_size ) {
818790 char zero [] = { 0x00 };
@@ -822,7 +794,7 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
822794 * this triggers code that will fill in 0's throughout
823795 * the intermediate portion of the previous end of the
824796 * file and the new and of the file */
825- rc = ecryptfs_write (& fake_ecryptfs_file , zero ,
797+ rc = ecryptfs_write (inode , zero ,
826798 (ia -> ia_size - 1 ), 1 );
827799 } else { /* ia->ia_size < i_size_read(inode) */
828800 /* We're chopping off all the pages down to the page
@@ -835,27 +807,27 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
835807 if (!(crypt_stat -> flags & ECRYPTFS_ENCRYPTED )) {
836808 rc = vmtruncate (inode , ia -> ia_size );
837809 if (rc )
838- goto out_free ;
810+ goto out ;
839811 lower_ia -> ia_size = ia -> ia_size ;
840812 lower_ia -> ia_valid |= ATTR_SIZE ;
841- goto out_free ;
813+ goto out ;
842814 }
843815 if (num_zeros ) {
844816 char * zeros_virt ;
845817
846818 zeros_virt = kzalloc (num_zeros , GFP_KERNEL );
847819 if (!zeros_virt ) {
848820 rc = - ENOMEM ;
849- goto out_free ;
821+ goto out ;
850822 }
851- rc = ecryptfs_write (& fake_ecryptfs_file , zeros_virt ,
823+ rc = ecryptfs_write (inode , zeros_virt ,
852824 ia -> ia_size , num_zeros );
853825 kfree (zeros_virt );
854826 if (rc ) {
855827 printk (KERN_ERR "Error attempting to zero out "
856828 "the remainder of the end page on "
857829 "reducing truncate; rc = [%d]\n" , rc );
858- goto out_free ;
830+ goto out ;
859831 }
860832 }
861833 vmtruncate (inode , ia -> ia_size );
@@ -864,7 +836,7 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
864836 printk (KERN_ERR "Problem with "
865837 "ecryptfs_write_inode_size_to_metadata; "
866838 "rc = [%d]\n" , rc );
867- goto out_free ;
839+ goto out ;
868840 }
869841 /* We are reducing the size of the ecryptfs file, and need to
870842 * know if we need to reduce the size of the lower file. */
@@ -878,10 +850,6 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
878850 } else
879851 lower_ia -> ia_valid &= ~ATTR_SIZE ;
880852 }
881- out_free :
882- if (ecryptfs_file_to_private (& fake_ecryptfs_file ))
883- kmem_cache_free (ecryptfs_file_info_cache ,
884- ecryptfs_file_to_private (& fake_ecryptfs_file ));
885853out :
886854 return rc ;
887855}
0 commit comments