diff options
Diffstat (limited to 'fs/ecryptfs/mmap.c')
-rw-r--r-- | fs/ecryptfs/mmap.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c index 2b6fe1e6e8ba..245c2dc02d5c 100644 --- a/fs/ecryptfs/mmap.c +++ b/fs/ecryptfs/mmap.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/file.h> | 32 | #include <linux/file.h> |
33 | #include <linux/crypto.h> | 33 | #include <linux/crypto.h> |
34 | #include <linux/scatterlist.h> | 34 | #include <linux/scatterlist.h> |
35 | #include <asm/unaligned.h> | ||
35 | #include "ecryptfs_kernel.h" | 36 | #include "ecryptfs_kernel.h" |
36 | 37 | ||
37 | /** | 38 | /** |
@@ -372,7 +373,6 @@ out: | |||
372 | */ | 373 | */ |
373 | static int ecryptfs_write_inode_size_to_header(struct inode *ecryptfs_inode) | 374 | static int ecryptfs_write_inode_size_to_header(struct inode *ecryptfs_inode) |
374 | { | 375 | { |
375 | u64 file_size; | ||
376 | char *file_size_virt; | 376 | char *file_size_virt; |
377 | int rc; | 377 | int rc; |
378 | 378 | ||
@@ -381,9 +381,7 @@ static int ecryptfs_write_inode_size_to_header(struct inode *ecryptfs_inode) | |||
381 | rc = -ENOMEM; | 381 | rc = -ENOMEM; |
382 | goto out; | 382 | goto out; |
383 | } | 383 | } |
384 | file_size = (u64)i_size_read(ecryptfs_inode); | 384 | put_unaligned_be64(i_size_read(ecryptfs_inode), file_size_virt); |
385 | file_size = cpu_to_be64(file_size); | ||
386 | memcpy(file_size_virt, &file_size, sizeof(u64)); | ||
387 | rc = ecryptfs_write_lower(ecryptfs_inode, file_size_virt, 0, | 385 | rc = ecryptfs_write_lower(ecryptfs_inode, file_size_virt, 0, |
388 | sizeof(u64)); | 386 | sizeof(u64)); |
389 | kfree(file_size_virt); | 387 | kfree(file_size_virt); |
@@ -403,7 +401,6 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode) | |||
403 | struct dentry *lower_dentry = | 401 | struct dentry *lower_dentry = |
404 | ecryptfs_inode_to_private(ecryptfs_inode)->lower_file->f_dentry; | 402 | ecryptfs_inode_to_private(ecryptfs_inode)->lower_file->f_dentry; |
405 | struct inode *lower_inode = lower_dentry->d_inode; | 403 | struct inode *lower_inode = lower_dentry->d_inode; |
406 | u64 file_size; | ||
407 | int rc; | 404 | int rc; |
408 | 405 | ||
409 | if (!lower_inode->i_op->getxattr || !lower_inode->i_op->setxattr) { | 406 | if (!lower_inode->i_op->getxattr || !lower_inode->i_op->setxattr) { |
@@ -424,9 +421,7 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode) | |||
424 | xattr_virt, PAGE_CACHE_SIZE); | 421 | xattr_virt, PAGE_CACHE_SIZE); |
425 | if (size < 0) | 422 | if (size < 0) |
426 | size = 8; | 423 | size = 8; |
427 | file_size = (u64)i_size_read(ecryptfs_inode); | 424 | put_unaligned_be64(i_size_read(ecryptfs_inode), xattr_virt); |
428 | file_size = cpu_to_be64(file_size); | ||
429 | memcpy(xattr_virt, &file_size, sizeof(u64)); | ||
430 | rc = lower_inode->i_op->setxattr(lower_dentry, ECRYPTFS_XATTR_NAME, | 425 | rc = lower_inode->i_op->setxattr(lower_dentry, ECRYPTFS_XATTR_NAME, |
431 | xattr_virt, size, 0); | 426 | xattr_virt, size, 0); |
432 | mutex_unlock(&lower_inode->i_mutex); | 427 | mutex_unlock(&lower_inode->i_mutex); |