Skip to content

Commit

Permalink
Update fs/ to use sg helpers
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
Jens Axboe committed Oct 22, 2007
1 parent 45711f1 commit 60c74f8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
16 changes: 11 additions & 5 deletions fs/ecryptfs/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg,
pg = virt_to_page(addr);
offset = offset_in_page(addr);
if (sg) {
sg[i].page = pg;
sg_set_page(&sg[i], pg);
sg[i].offset = offset;
}
remainder_of_page = PAGE_CACHE_SIZE - offset;
Expand Down Expand Up @@ -713,10 +713,13 @@ ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat,
{
struct scatterlist src_sg, dst_sg;

src_sg.page = src_page;
sg_init_table(&src_sg, 1);
sg_init_table(&dst_sg, 1);

sg_set_page(&src_sg, src_page);
src_sg.offset = src_offset;
src_sg.length = size;
dst_sg.page = dst_page;
sg_set_page(&dst_sg, dst_page);
dst_sg.offset = dst_offset;
dst_sg.length = size;
return encrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv);
Expand All @@ -742,10 +745,13 @@ ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat,
{
struct scatterlist src_sg, dst_sg;

src_sg.page = src_page;
sg_init_table(&src_sg, 1);
sg_init_table(&dst_sg, 1);

sg_set_page(&src_sg, src_page);
src_sg.offset = src_offset;
src_sg.length = size;
dst_sg.page = dst_page;
sg_set_page(&dst_sg, dst_page);
dst_sg.offset = dst_offset;
dst_sg.length = size;
return decrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv);
Expand Down
3 changes: 3 additions & 0 deletions fs/ecryptfs/keystore.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,9 @@ decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
};
int rc = 0;

sg_init_table(&dst_sg, 1);
sg_init_table(&src_sg, 1);

if (unlikely(ecryptfs_verbosity > 0)) {
ecryptfs_printk(
KERN_DEBUG, "Session key encryption key (size [%d]):\n",
Expand Down
8 changes: 3 additions & 5 deletions fs/nfsd/nfs4recover.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ nfs4_make_rec_clidname(char *dname, struct xdr_netobj *clname)
{
struct xdr_netobj cksum;
struct hash_desc desc;
struct scatterlist sg[1];
struct scatterlist sg;
__be32 status = nfserr_resource;

dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n",
Expand All @@ -102,11 +102,9 @@ nfs4_make_rec_clidname(char *dname, struct xdr_netobj *clname)
if (cksum.data == NULL)
goto out;

sg[0].page = virt_to_page(clname->data);
sg[0].offset = offset_in_page(clname->data);
sg[0].length = clname->len;
sg_init_one(&sg, clname->data, clname->len);

if (crypto_hash_digest(&desc, sg, sg->length, cksum.data))
if (crypto_hash_digest(&desc, &sg, sg.length, cksum.data))
goto out;

md5_to_hex(dname, cksum.data);
Expand Down

0 comments on commit 60c74f8

Please sign in to comment.