diff options
Diffstat (limited to 'fs/ecryptfs/mmap.c')
-rw-r--r-- | fs/ecryptfs/mmap.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c index 9a5e0d17f1c5..dc74b186145d 100644 --- a/fs/ecryptfs/mmap.c +++ b/fs/ecryptfs/mmap.c | |||
@@ -100,13 +100,14 @@ static void set_header_info(char *page_virt, | |||
100 | struct ecryptfs_crypt_stat *crypt_stat) | 100 | struct ecryptfs_crypt_stat *crypt_stat) |
101 | { | 101 | { |
102 | size_t written; | 102 | size_t written; |
103 | int save_num_header_extents_at_front = | 103 | size_t save_num_header_bytes_at_front = |
104 | crypt_stat->num_header_extents_at_front; | 104 | crypt_stat->num_header_bytes_at_front; |
105 | 105 | ||
106 | crypt_stat->num_header_extents_at_front = 1; | 106 | crypt_stat->num_header_bytes_at_front = |
107 | ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE; | ||
107 | ecryptfs_write_header_metadata(page_virt + 20, crypt_stat, &written); | 108 | ecryptfs_write_header_metadata(page_virt + 20, crypt_stat, &written); |
108 | crypt_stat->num_header_extents_at_front = | 109 | crypt_stat->num_header_bytes_at_front = |
109 | save_num_header_extents_at_front; | 110 | save_num_header_bytes_at_front; |
110 | } | 111 | } |
111 | 112 | ||
112 | /** | 113 | /** |
@@ -132,8 +133,11 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page, | |||
132 | loff_t view_extent_num = ((((loff_t)page->index) | 133 | loff_t view_extent_num = ((((loff_t)page->index) |
133 | * num_extents_per_page) | 134 | * num_extents_per_page) |
134 | + extent_num_in_page); | 135 | + extent_num_in_page); |
136 | size_t num_header_extents_at_front = | ||
137 | (crypt_stat->num_header_bytes_at_front | ||
138 | / crypt_stat->extent_size); | ||
135 | 139 | ||
136 | if (view_extent_num < crypt_stat->num_header_extents_at_front) { | 140 | if (view_extent_num < num_header_extents_at_front) { |
137 | /* This is a header extent */ | 141 | /* This is a header extent */ |
138 | char *page_virt; | 142 | char *page_virt; |
139 | 143 | ||
@@ -155,9 +159,8 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page, | |||
155 | } else { | 159 | } else { |
156 | /* This is an encrypted data extent */ | 160 | /* This is an encrypted data extent */ |
157 | loff_t lower_offset = | 161 | loff_t lower_offset = |
158 | ((view_extent_num - | 162 | ((view_extent_num * crypt_stat->extent_size) |
159 | crypt_stat->num_header_extents_at_front) | 163 | - crypt_stat->num_header_bytes_at_front); |
160 | * crypt_stat->extent_size); | ||
161 | 164 | ||
162 | rc = ecryptfs_read_lower_page_segment( | 165 | rc = ecryptfs_read_lower_page_segment( |
163 | page, (lower_offset >> PAGE_CACHE_SHIFT), | 166 | page, (lower_offset >> PAGE_CACHE_SHIFT), |