Commit fa3ef1cb authored by Tyler Hicks's avatar Tyler Hicks

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: default avatarEric Sandeen <sandeen@redhat.com>
Signed-off-by: default avatarTyler Hicks <tyhicks@linux.vnet.ibm.com>
parent 157f1071
...@@ -834,14 +834,13 @@ void ecryptfs_set_default_sizes(struct ecryptfs_crypt_stat *crypt_stat) ...@@ -834,14 +834,13 @@ void ecryptfs_set_default_sizes(struct ecryptfs_crypt_stat *crypt_stat)
set_extent_mask_and_shift(crypt_stat); set_extent_mask_and_shift(crypt_stat);
crypt_stat->iv_bytes = ECRYPTFS_DEFAULT_IV_BYTES; crypt_stat->iv_bytes = ECRYPTFS_DEFAULT_IV_BYTES;
if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR)
crypt_stat->num_header_bytes_at_front = crypt_stat->metadata_size = ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE;
ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE;
else { else {
if (PAGE_CACHE_SIZE <= ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE) if (PAGE_CACHE_SIZE <= ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE)
crypt_stat->num_header_bytes_at_front = crypt_stat->metadata_size =
ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE; ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE;
else else
crypt_stat->num_header_bytes_at_front = PAGE_CACHE_SIZE; crypt_stat->metadata_size = PAGE_CACHE_SIZE;
} }
} }
...@@ -1238,8 +1237,7 @@ ecryptfs_write_header_metadata(char *virt, ...@@ -1238,8 +1237,7 @@ ecryptfs_write_header_metadata(char *virt,
header_extent_size = (u32)crypt_stat->extent_size; header_extent_size = (u32)crypt_stat->extent_size;
num_header_extents_at_front = num_header_extents_at_front =
(u16)(crypt_stat->num_header_bytes_at_front (u16)(crypt_stat->metadata_size / crypt_stat->extent_size);
/ crypt_stat->extent_size);
put_unaligned_be32(header_extent_size, virt); put_unaligned_be32(header_extent_size, virt);
virt += 4; virt += 4;
put_unaligned_be16(num_header_extents_at_front, virt); put_unaligned_be16(num_header_extents_at_front, virt);
...@@ -1382,7 +1380,7 @@ int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry) ...@@ -1382,7 +1380,7 @@ int ecryptfs_write_metadata(struct dentry *ecryptfs_dentry)
rc = -EINVAL; rc = -EINVAL;
goto out; goto out;
} }
virt_len = crypt_stat->num_header_bytes_at_front; virt_len = crypt_stat->metadata_size;
order = get_order(virt_len); order = get_order(virt_len);
/* Released in this function */ /* Released in this function */
virt = (char *)ecryptfs_get_zeroed_pages(GFP_KERNEL, order); 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,16 +1426,15 @@ static int parse_header_metadata(struct ecryptfs_crypt_stat *crypt_stat,
header_extent_size = get_unaligned_be32(virt); header_extent_size = get_unaligned_be32(virt);
virt += sizeof(__be32); virt += sizeof(__be32);
num_header_extents_at_front = get_unaligned_be16(virt); num_header_extents_at_front = get_unaligned_be16(virt);
crypt_stat->num_header_bytes_at_front = crypt_stat->metadata_size = (((size_t)num_header_extents_at_front
(((size_t)num_header_extents_at_front
* (size_t)header_extent_size)); * (size_t)header_extent_size));
(*bytes_read) = (sizeof(__be32) + sizeof(__be16)); (*bytes_read) = (sizeof(__be32) + sizeof(__be16));
if ((validate_header_size == ECRYPTFS_VALIDATE_HEADER_SIZE) if ((validate_header_size == ECRYPTFS_VALIDATE_HEADER_SIZE)
&& (crypt_stat->num_header_bytes_at_front && (crypt_stat->metadata_size
< ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE)) { < ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE)) {
rc = -EINVAL; rc = -EINVAL;
printk(KERN_WARNING "Invalid header size: [%zd]\n", printk(KERN_WARNING "Invalid header size: [%zd]\n",
crypt_stat->num_header_bytes_at_front); crypt_stat->metadata_size);
} }
return rc; return rc;
} }
...@@ -1452,8 +1449,7 @@ static int parse_header_metadata(struct ecryptfs_crypt_stat *crypt_stat, ...@@ -1452,8 +1449,7 @@ static int parse_header_metadata(struct ecryptfs_crypt_stat *crypt_stat,
*/ */
static void set_default_header_data(struct ecryptfs_crypt_stat *crypt_stat) static void set_default_header_data(struct ecryptfs_crypt_stat *crypt_stat)
{ {
crypt_stat->num_header_bytes_at_front = crypt_stat->metadata_size = ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE;
ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE;
} }
/** /**
......
...@@ -273,7 +273,7 @@ struct ecryptfs_crypt_stat { ...@@ -273,7 +273,7 @@ struct ecryptfs_crypt_stat {
u32 flags; u32 flags;
unsigned int file_version; unsigned int file_version;
size_t iv_bytes; size_t iv_bytes;
size_t num_header_bytes_at_front; size_t metadata_size;
size_t extent_size; /* Data extent size; default is 4096 */ size_t extent_size; /* Data extent size; default is 4096 */
size_t key_size; size_t key_size;
size_t extent_shift; size_t extent_shift;
...@@ -469,7 +469,7 @@ ecryptfs_lower_header_size(struct ecryptfs_crypt_stat *crypt_stat) ...@@ -469,7 +469,7 @@ ecryptfs_lower_header_size(struct ecryptfs_crypt_stat *crypt_stat)
{ {
if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR)
return 0; return 0;
return crypt_stat->num_header_bytes_at_front; return crypt_stat->metadata_size;
} }
static inline struct ecryptfs_file_info * static inline struct ecryptfs_file_info *
......
...@@ -335,7 +335,7 @@ int ecryptfs_lookup_and_interpose_lower(struct dentry *ecryptfs_dentry, ...@@ -335,7 +335,7 @@ int ecryptfs_lookup_and_interpose_lower(struct dentry *ecryptfs_dentry,
ecryptfs_dentry->d_sb)->mount_crypt_stat; ecryptfs_dentry->d_sb)->mount_crypt_stat;
if (mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED) { if (mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED) {
if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR)
file_size = (crypt_stat->num_header_bytes_at_front file_size = (crypt_stat->metadata_size
+ i_size_read(lower_dentry->d_inode)); + i_size_read(lower_dentry->d_inode));
else else
file_size = i_size_read(lower_dentry->d_inode); file_size = i_size_read(lower_dentry->d_inode);
......
...@@ -122,8 +122,7 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page, ...@@ -122,8 +122,7 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
* num_extents_per_page) * num_extents_per_page)
+ extent_num_in_page); + extent_num_in_page);
size_t num_header_extents_at_front = size_t num_header_extents_at_front =
(crypt_stat->num_header_bytes_at_front (crypt_stat->metadata_size / crypt_stat->extent_size);
/ crypt_stat->extent_size);
if (view_extent_num < num_header_extents_at_front) { if (view_extent_num < num_header_extents_at_front) {
/* This is a header extent */ /* This is a header extent */
...@@ -152,7 +151,7 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page, ...@@ -152,7 +151,7 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
/* This is an encrypted data extent */ /* This is an encrypted data extent */
loff_t lower_offset = loff_t lower_offset =
((view_extent_num * crypt_stat->extent_size) ((view_extent_num * crypt_stat->extent_size)
- crypt_stat->num_header_bytes_at_front); - crypt_stat->metadata_size);
rc = ecryptfs_read_lower_page_segment( rc = ecryptfs_read_lower_page_segment(
page, (lower_offset >> PAGE_CACHE_SHIFT), page, (lower_offset >> PAGE_CACHE_SHIFT),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment