]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/ecryptfs/mmap.c
Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-leds
[linux-2.6-omap-h63xx.git] / fs / ecryptfs / mmap.c
index 6df1debdccce14aabbf0e63193b66ec0c8366d3e..245c2dc02d5cfa96d1fe60818ae849555ef5e991 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/file.h>
 #include <linux/crypto.h>
 #include <linux/scatterlist.h>
+#include <asm/unaligned.h>
 #include "ecryptfs_kernel.h"
 
 /**
@@ -153,7 +154,7 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
                        flush_dcache_page(page);
                        if (rc) {
                                printk(KERN_ERR "%s: Error reading xattr "
-                                      "region; rc = [%d]\n", __FUNCTION__, rc);
+                                      "region; rc = [%d]\n", __func__, rc);
                                goto out;
                        }
                } else {
@@ -169,7 +170,7 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
                        if (rc) {
                                printk(KERN_ERR "%s: Error attempting to read "
                                       "extent at offset [%lld] in the lower "
-                                      "file; rc = [%d]\n", __FUNCTION__,
+                                      "file; rc = [%d]\n", __func__,
                                       lower_offset, rc);
                                goto out;
                        }
@@ -212,7 +213,7 @@ static int ecryptfs_readpage(struct file *file, struct page *page)
                                       "the encrypted content from the lower "
                                       "file whilst inserting the metadata "
                                       "from the xattr into the header; rc = "
-                                      "[%d]\n", __FUNCTION__, rc);
+                                      "[%d]\n", __func__, rc);
                                goto out;
                        }
 
@@ -293,7 +294,7 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page,
                        if (rc) {
                                printk(KERN_ERR "%s: Error attemping to read "
                                       "lower page segment; rc = [%d]\n",
-                                      __FUNCTION__, rc);
+                                      __func__, rc);
                                ClearPageUptodate(page);
                                goto out;
                        } else
@@ -308,7 +309,7 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page,
                                               "from the lower file whilst "
                                               "inserting the metadata from "
                                               "the xattr into the header; rc "
-                                              "= [%d]\n", __FUNCTION__, rc);
+                                              "= [%d]\n", __func__, rc);
                                        ClearPageUptodate(page);
                                        goto out;
                                }
@@ -320,7 +321,7 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page,
                                if (rc) {
                                        printk(KERN_ERR "%s: Error reading "
                                               "page; rc = [%d]\n",
-                                              __FUNCTION__, rc);
+                                              __func__, rc);
                                        ClearPageUptodate(page);
                                        goto out;
                                }
@@ -331,7 +332,7 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page,
                        if (rc) {
                                printk(KERN_ERR "%s: Error decrypting page "
                                       "at index [%ld]; rc = [%d]\n",
-                                      __FUNCTION__, page->index, rc);
+                                      __func__, page->index, rc);
                                ClearPageUptodate(page);
                                goto out;
                        }
@@ -348,7 +349,7 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page,
                        if (rc) {
                                printk(KERN_ERR "%s: Error on attempt to "
                                       "truncate to (higher) offset [%lld];"
-                                      " rc = [%d]\n", __FUNCTION__,
+                                      " rc = [%d]\n", __func__,
                                       prev_page_end_size, rc);
                                goto out;
                        }
@@ -372,7 +373,6 @@ out:
  */
 static int ecryptfs_write_inode_size_to_header(struct inode *ecryptfs_inode)
 {
-       u64 file_size;
        char *file_size_virt;
        int rc;
 
@@ -381,15 +381,13 @@ static int ecryptfs_write_inode_size_to_header(struct inode *ecryptfs_inode)
                rc = -ENOMEM;
                goto out;
        }
-       file_size = (u64)i_size_read(ecryptfs_inode);
-       file_size = cpu_to_be64(file_size);
-       memcpy(file_size_virt, &file_size, sizeof(u64));
+       put_unaligned_be64(i_size_read(ecryptfs_inode), file_size_virt);
        rc = ecryptfs_write_lower(ecryptfs_inode, file_size_virt, 0,
                                  sizeof(u64));
        kfree(file_size_virt);
        if (rc)
                printk(KERN_ERR "%s: Error writing file size to header; "
-                      "rc = [%d]\n", __FUNCTION__, rc);
+                      "rc = [%d]\n", __func__, rc);
 out:
        return rc;
 }
@@ -403,7 +401,6 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode)
        struct dentry *lower_dentry =
                ecryptfs_inode_to_private(ecryptfs_inode)->lower_file->f_dentry;
        struct inode *lower_inode = lower_dentry->d_inode;
-       u64 file_size;
        int rc;
 
        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)
                                           xattr_virt, PAGE_CACHE_SIZE);
        if (size < 0)
                size = 8;
-       file_size = (u64)i_size_read(ecryptfs_inode);
-       file_size = cpu_to_be64(file_size);
-       memcpy(xattr_virt, &file_size, sizeof(u64));
+       put_unaligned_be64(i_size_read(ecryptfs_inode), xattr_virt);
        rc = lower_inode->i_op->setxattr(lower_dentry, ECRYPTFS_XATTR_NAME,
                                         xattr_virt, size, 0);
        mutex_unlock(&lower_inode->i_mutex);