eCryptfs: Collapse crypt_page_offset() into crypt_extent()
crypt_page_offset() simply initialized the two scatterlists and called crypt_scatterlist() so it is simple enough to move into the only function that calls it. Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
This commit is contained in:
parent
d78de61896
commit
406c93df09
1 changed files with 14 additions and 36 deletions
|
@ -40,10 +40,6 @@
|
||||||
#define DECRYPT 0
|
#define DECRYPT 0
|
||||||
#define ENCRYPT 1
|
#define ENCRYPT 1
|
||||||
|
|
||||||
static int crypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat,
|
|
||||||
struct page *dst_page, struct page *src_page,
|
|
||||||
int offset, int size, unsigned char *iv, int op);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ecryptfs_to_hex
|
* ecryptfs_to_hex
|
||||||
* @dst: Buffer to take hex character representation of contents of
|
* @dst: Buffer to take hex character representation of contents of
|
||||||
|
@ -436,10 +432,11 @@ static int crypt_extent(struct page *dst_page,
|
||||||
pgoff_t page_index = op == ENCRYPT ? src_page->index : dst_page->index;
|
pgoff_t page_index = op == ENCRYPT ? src_page->index : dst_page->index;
|
||||||
loff_t extent_base;
|
loff_t extent_base;
|
||||||
char extent_iv[ECRYPTFS_MAX_IV_BYTES];
|
char extent_iv[ECRYPTFS_MAX_IV_BYTES];
|
||||||
|
struct scatterlist src_sg, dst_sg;
|
||||||
|
size_t extent_size = crypt_stat->extent_size;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
extent_base = (((loff_t)page_index)
|
extent_base = (((loff_t)page_index) * (PAGE_CACHE_SIZE / extent_size));
|
||||||
* (PAGE_CACHE_SIZE / crypt_stat->extent_size));
|
|
||||||
rc = ecryptfs_derive_iv(extent_iv, crypt_stat,
|
rc = ecryptfs_derive_iv(extent_iv, crypt_stat,
|
||||||
(extent_base + extent_offset));
|
(extent_base + extent_offset));
|
||||||
if (rc) {
|
if (rc) {
|
||||||
|
@ -448,9 +445,17 @@ static int crypt_extent(struct page *dst_page,
|
||||||
(unsigned long long)(extent_base + extent_offset), rc);
|
(unsigned long long)(extent_base + extent_offset), rc);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
rc = crypt_page_offset(crypt_stat, dst_page, src_page,
|
|
||||||
(extent_offset * crypt_stat->extent_size),
|
sg_init_table(&src_sg, 1);
|
||||||
crypt_stat->extent_size, extent_iv, op);
|
sg_init_table(&dst_sg, 1);
|
||||||
|
|
||||||
|
sg_set_page(&src_sg, src_page, extent_size,
|
||||||
|
extent_offset * extent_size);
|
||||||
|
sg_set_page(&dst_sg, dst_page, extent_size,
|
||||||
|
extent_offset * extent_size);
|
||||||
|
|
||||||
|
rc = crypt_scatterlist(crypt_stat, &dst_sg, &src_sg, extent_size,
|
||||||
|
extent_iv, op);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
printk(KERN_ERR "%s: Error attempting to crypt page with "
|
printk(KERN_ERR "%s: Error attempting to crypt page with "
|
||||||
"page_index = [%ld], extent_offset = [%ld]; "
|
"page_index = [%ld], extent_offset = [%ld]; "
|
||||||
|
@ -588,33 +593,6 @@ out:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* crypt_page_offset
|
|
||||||
* @crypt_stat: The cryptographic context
|
|
||||||
* @dst_page: The page to write the result into
|
|
||||||
* @src_page: The page to read from
|
|
||||||
* @offset: The byte offset into the dst_page and src_page
|
|
||||||
* @size: The number of bytes of data
|
|
||||||
* @iv: The initialization vector to use for the crypto operation
|
|
||||||
* @op: ENCRYPT or DECRYPT to indicate the desired operation
|
|
||||||
*
|
|
||||||
* Returns the number of bytes encrypted or decrypted
|
|
||||||
*/
|
|
||||||
static int crypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat,
|
|
||||||
struct page *dst_page, struct page *src_page,
|
|
||||||
int offset, int size, unsigned char *iv, int op)
|
|
||||||
{
|
|
||||||
struct scatterlist src_sg, dst_sg;
|
|
||||||
|
|
||||||
sg_init_table(&src_sg, 1);
|
|
||||||
sg_init_table(&dst_sg, 1);
|
|
||||||
|
|
||||||
sg_set_page(&src_sg, src_page, size, offset);
|
|
||||||
sg_set_page(&dst_sg, dst_page, size, offset);
|
|
||||||
|
|
||||||
return crypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv, op);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define ECRYPTFS_MAX_SCATTERLIST_LEN 4
|
#define ECRYPTFS_MAX_SCATTERLIST_LEN 4
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue