]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - fs/ecryptfs/inode.c
ecryptfs: inode.c mmap.c use unaligned byteorder helpers
[mv-sheeva.git] / fs / ecryptfs / inode.c
index 0a1397335a8eb49a245e81b1826607a5158a2685..7315547193ea7e832f9de89f29d6545a1ec720ee 100644 (file)
 #include <linux/mount.h>
 #include <linux/crypto.h>
 #include <linux/fs_stack.h>
+#include <asm/unaligned.h>
 #include "ecryptfs_kernel.h"
 
 static struct dentry *lock_parent(struct dentry *dentry)
 {
        struct dentry *dir;
 
-       dir = dget(dentry->d_parent);
+       dir = dget_parent(dentry);
        mutex_lock_nested(&(dir->d_inode->i_mutex), I_MUTEX_PARENT);
        return dir;
 }
 
-static void unlock_parent(struct dentry *dentry)
-{
-       mutex_unlock(&(dentry->d_parent->d_inode->i_mutex));
-       dput(dentry->d_parent);
-}
-
 static void unlock_dir(struct dentry *dir)
 {
        mutex_unlock(&dir->d_inode->i_mutex);
@@ -370,8 +365,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
                else
                        file_size = i_size_read(lower_dentry->d_inode);
        } else {
-               memcpy(&file_size, page_virt, sizeof(file_size));
-               file_size = be64_to_cpu(file_size);
+               file_size = get_unaligned_be64(page_virt);
        }
        i_size_write(dentry->d_inode, (loff_t)file_size);
        kmem_cache_free(ecryptfs_header_cache_2, page_virt);
@@ -426,8 +420,9 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
        int rc = 0;
        struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
        struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir);
+       struct dentry *lower_dir_dentry;
 
-       lock_parent(lower_dentry);
+       lower_dir_dentry = lock_parent(lower_dentry);
        rc = vfs_unlink(lower_dir_inode, lower_dentry);
        if (rc) {
                printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
@@ -439,7 +434,7 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
        dentry->d_inode->i_ctime = dir->i_ctime;
        d_drop(dentry);
 out_unlock:
-       unlock_parent(lower_dentry);
+       unlock_dir(lower_dir_dentry);
        return rc;
 }