diff options
author | Tyler Hicks <tyhicks@linux.vnet.ibm.com> | 2010-02-11 06:09:14 -0500 |
---|---|---|
committer | Tyler Hicks <tyhicks@linux.vnet.ibm.com> | 2010-03-23 13:30:41 -0400 |
commit | fa3ef1cb4e6e9958a9bfaa977c107c515907f102 (patch) | |
tree | f297192533a0c8720534c76c6429e68ae92b94d9 /fs/ecryptfs | |
parent | 157f1071354db1aed885816094888e0e257c9d0a (diff) |
eCryptfs: Rename ecryptfs_crypt_stat.num_header_bytes_at_front
This patch renames the num_header_bytes_at_front variable to
metadata_size since it now contains the max size of the metadata.
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r-- | fs/ecryptfs/crypto.c | 24 | ||||
-rw-r--r-- | fs/ecryptfs/ecryptfs_kernel.h | 4 | ||||
-rw-r--r-- | fs/ecryptfs/inode.c | 2 | ||||
-rw-r--r-- | fs/ecryptfs/mmap.c | 5 |
4 files changed, 15 insertions, 20 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index c907f6f49351..391f558eb4d0 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
@@ -834,14 +834,13 @@ void ecryptfs_set_default_sizes(struct ecryptfs_crypt_stat *crypt_stat) | |||
834 | set_extent_mask_and_shift(crypt_stat); | 834 | set_extent_mask_and_shift(crypt_stat); |
835 | crypt_stat->iv_bytes = ECRYPTFS_DEFAULT_IV_BYTES; | 835 | crypt_stat->iv_bytes = ECRYPTFS_DEFAULT_IV_BYTES; |
836 | if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) | 836 | if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) |
837 | crypt_stat->num_header_bytes_at_front = | 837 | crypt_stat->metadata_size = ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE; |
838 | ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE; | ||
839 | else { | 838 | else { |
840 | if (PAGE_CACHE_SIZE <= ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE) | 839 | if (PAGE_CACHE_SIZE <= ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE) |
841 | crypt_stat->num_header_bytes_at_front = | 840 | crypt_stat->metadata_size = |
842 | ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE; | 841 | ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE; |
843 | else | 842 | else |
844 | crypt_stat->num_header_bytes_at_front = PAGE_CACHE_SIZE; | 843 | crypt_stat->metadata_size = PAGE_CACHE_SIZE; |
845 | } | 844 | } |
846 | } | 845 | } |
847 | 846 | ||
@@ -1238,8 +1237,7 @@ ecryptfs_write_header_metadata(char *virt, | |||
1238 | 1237 | ||
1239 | header_extent_size = (u32)crypt_stat->extent_size; | 1238 | header_extent_size = (u32)crypt_stat->extent_size; |
1240 | num_header_extents_at_front = | 1239 | num_header_extents_at_front = |
1241 | (u16)(crypt_stat->num_header_bytes_at_front | 1240 | (u16)(crypt_stat->metadata_size / crypt_stat->extent_size); |
1242 | / crypt_stat->extent_size); | ||
1243 | put_unaligned_be32(header_extent_size, virt); | 1241 | put_unaligned_be32(header_extent_size, virt); |
1244 | virt += 4; | 1242 | virt += 4; |
1245 | put_unaligned_be16(num_header_extents_at_front, virt); | 1243 | put_unaligned_be16(num_header_extents_at_front, virt); |
@@ -1382,7 +1380,7 @@ int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry) | |||
1382 | rc = -EINVAL; | 1380 | rc = -EINVAL; |
1383 | goto out; | 1381 | goto out; |
1384 | } | 1382 | } |
1385 | virt_len = crypt_stat->num_header_bytes_at_front; | 1383 | virt_len = crypt_stat->metadata_size; |
1386 | order = get_order(virt_len); | 1384 | order = get_order(virt_len); |
1387 | /* Released in this function */ | 1385 | /* Released in this function */ |
1388 | virt = (char *)ecryptfs_get_zeroed_pages(GFP_KERNEL, order); | 1386 | virt = (char *)ecryptfs_get_zeroed_pages(GFP_KERNEL, order); |
@@ -1428,16 +1426,15 @@ static int parse_header_metadata(struct ecryptfs_crypt_stat *crypt_stat, | |||
1428 | header_extent_size = get_unaligned_be32(virt); | 1426 | header_extent_size = get_unaligned_be32(virt); |
1429 | virt += sizeof(__be32); | 1427 | virt += sizeof(__be32); |
1430 | num_header_extents_at_front = get_unaligned_be16(virt); | 1428 | num_header_extents_at_front = get_unaligned_be16(virt); |
1431 | crypt_stat->num_header_bytes_at_front = | 1429 | crypt_stat->metadata_size = (((size_t)num_header_extents_at_front |
1432 | (((size_t)num_header_extents_at_front | 1430 | * (size_t)header_extent_size)); |
1433 | * (size_t)header_extent_size)); | ||
1434 | (*bytes_read) = (sizeof(__be32) + sizeof(__be16)); | 1431 | (*bytes_read) = (sizeof(__be32) + sizeof(__be16)); |
1435 | if ((validate_header_size == ECRYPTFS_VALIDATE_HEADER_SIZE) | 1432 | if ((validate_header_size == ECRYPTFS_VALIDATE_HEADER_SIZE) |
1436 | && (crypt_stat->num_header_bytes_at_front | 1433 | && (crypt_stat->metadata_size |
1437 | < ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE)) { | 1434 | < ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE)) { |
1438 | rc = -EINVAL; | 1435 | rc = -EINVAL; |
1439 | printk(KERN_WARNING "Invalid header size: [%zd]\n", | 1436 | printk(KERN_WARNING "Invalid header size: [%zd]\n", |
1440 | crypt_stat->num_header_bytes_at_front); | 1437 | crypt_stat->metadata_size); |
1441 | } | 1438 | } |
1442 | return rc; | 1439 | return rc; |
1443 | } | 1440 | } |
@@ -1452,8 +1449,7 @@ static int parse_header_metadata(struct ecryptfs_crypt_stat *crypt_stat, | |||
1452 | */ | 1449 | */ |
1453 | static void set_default_header_data(struct ecryptfs_crypt_stat *crypt_stat) | 1450 | static void set_default_header_data(struct ecryptfs_crypt_stat *crypt_stat) |
1454 | { | 1451 | { |
1455 | crypt_stat->num_header_bytes_at_front = | 1452 | crypt_stat->metadata_size = ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE; |
1456 | ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE; | ||
1457 | } | 1453 | } |
1458 | 1454 | ||
1459 | /** | 1455 | /** |
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index 8456f70606ad..d031efd7666b 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h | |||
@@ -273,7 +273,7 @@ struct ecryptfs_crypt_stat { | |||
273 | u32 flags; | 273 | u32 flags; |
274 | unsigned int file_version; | 274 | unsigned int file_version; |
275 | size_t iv_bytes; | 275 | size_t iv_bytes; |
276 | size_t num_header_bytes_at_front; | 276 | size_t metadata_size; |
277 | size_t extent_size; /* Data extent size; default is 4096 */ | 277 | size_t extent_size; /* Data extent size; default is 4096 */ |
278 | size_t key_size; | 278 | size_t key_size; |
279 | size_t extent_shift; | 279 | size_t extent_shift; |
@@ -469,7 +469,7 @@ ecryptfs_lower_header_size(struct ecryptfs_crypt_stat *crypt_stat) | |||
469 | { | 469 | { |
470 | if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) | 470 | if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) |
471 | return 0; | 471 | return 0; |
472 | return crypt_stat->num_header_bytes_at_front; | 472 | return crypt_stat->metadata_size; |
473 | } | 473 | } |
474 | 474 | ||
475 | static inline struct ecryptfs_file_info * | 475 | static inline struct ecryptfs_file_info * |
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 1a739531b0dd..a50efb18701c 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -335,7 +335,7 @@ int ecryptfs_lookup_and_interpose_lower(struct dentry *ecryptfs_dentry, | |||
335 | ecryptfs_dentry->d_sb)->mount_crypt_stat; | 335 | ecryptfs_dentry->d_sb)->mount_crypt_stat; |
336 | if (mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED) { | 336 | if (mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED) { |
337 | if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) | 337 | if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) |
338 | file_size = (crypt_stat->num_header_bytes_at_front | 338 | file_size = (crypt_stat->metadata_size |
339 | + i_size_read(lower_dentry->d_inode)); | 339 | + i_size_read(lower_dentry->d_inode)); |
340 | else | 340 | else |
341 | file_size = i_size_read(lower_dentry->d_inode); | 341 | file_size = i_size_read(lower_dentry->d_inode); |
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c index 5a30e01547f1..270f42ae7c0d 100644 --- a/fs/ecryptfs/mmap.c +++ b/fs/ecryptfs/mmap.c | |||
@@ -122,8 +122,7 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page, | |||
122 | * num_extents_per_page) | 122 | * num_extents_per_page) |
123 | + extent_num_in_page); | 123 | + extent_num_in_page); |
124 | size_t num_header_extents_at_front = | 124 | size_t num_header_extents_at_front = |
125 | (crypt_stat->num_header_bytes_at_front | 125 | (crypt_stat->metadata_size / crypt_stat->extent_size); |
126 | / crypt_stat->extent_size); | ||
127 | 126 | ||
128 | if (view_extent_num < num_header_extents_at_front) { | 127 | if (view_extent_num < num_header_extents_at_front) { |
129 | /* This is a header extent */ | 128 | /* This is a header extent */ |
@@ -152,7 +151,7 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page, | |||
152 | /* This is an encrypted data extent */ | 151 | /* This is an encrypted data extent */ |
153 | loff_t lower_offset = | 152 | loff_t lower_offset = |
154 | ((view_extent_num * crypt_stat->extent_size) | 153 | ((view_extent_num * crypt_stat->extent_size) |
155 | - crypt_stat->num_header_bytes_at_front); | 154 | - crypt_stat->metadata_size); |
156 | 155 | ||
157 | rc = ecryptfs_read_lower_page_segment( | 156 | rc = ecryptfs_read_lower_page_segment( |
158 | page, (lower_offset >> PAGE_CACHE_SHIFT), | 157 | page, (lower_offset >> PAGE_CACHE_SHIFT), |