Commit 0cc72dc7 authored by Josef "Jeff" Sipek's avatar Josef "Jeff" Sipek Committed by Linus Torvalds

[PATCH] eCryptfs: Use fsstack's generic copy inode attr functions

Replace eCryptfs specific code & calls with the more generic fsstack
equivalents and remove the eCryptfs specific functions.
Signed-off-by: default avatarJosef "Jeff" Sipek <jsipek@cs.sunysb.edu>
Cc: Michael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 42cf1193
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/dcache.h> #include <linux/dcache.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/fs_stack.h>
#include "ecryptfs_kernel.h" #include "ecryptfs_kernel.h"
/** /**
...@@ -61,7 +62,7 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, struct nameidata *nd) ...@@ -61,7 +62,7 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
struct inode *lower_inode = struct inode *lower_inode =
ecryptfs_inode_to_lower(dentry->d_inode); ecryptfs_inode_to_lower(dentry->d_inode);
ecryptfs_copy_attr_all(dentry->d_inode, lower_inode); fsstack_copy_attr_all(dentry->d_inode, lower_inode, NULL);
} }
out: out:
return rc; return rc;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <keys/user-type.h> #include <keys/user-type.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/fs_stack.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
/* Version verification for shared data structures w/ userspace */ /* Version verification for shared data structures w/ userspace */
...@@ -413,9 +414,6 @@ int ecryptfs_encode_filename(struct ecryptfs_crypt_stat *crypt_stat, ...@@ -413,9 +414,6 @@ int ecryptfs_encode_filename(struct ecryptfs_crypt_stat *crypt_stat,
const char *name, int length, const char *name, int length,
char **encoded_name); char **encoded_name);
struct dentry *ecryptfs_lower_dentry(struct dentry *this_dentry); struct dentry *ecryptfs_lower_dentry(struct dentry *this_dentry);
void ecryptfs_copy_attr_atime(struct inode *dest, const struct inode *src);
void ecryptfs_copy_attr_all(struct inode *dest, const struct inode *src);
void ecryptfs_copy_inode_size(struct inode *dst, const struct inode *src);
void ecryptfs_dump_hex(char *data, int bytes); void ecryptfs_dump_hex(char *data, int bytes);
int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg, int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg,
int sg_size); int sg_size);
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/security.h> #include <linux/security.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/fs_stack.h>
#include "ecryptfs_kernel.h" #include "ecryptfs_kernel.h"
/** /**
...@@ -192,7 +193,7 @@ static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir) ...@@ -192,7 +193,7 @@ static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir)
goto retry; goto retry;
file->f_pos = lower_file->f_pos; file->f_pos = lower_file->f_pos;
if (rc >= 0) if (rc >= 0)
ecryptfs_copy_attr_atime(inode, lower_file->f_dentry->d_inode); fsstack_copy_attr_atime(inode, lower_file->f_dentry->d_inode);
return rc; return rc;
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/fs_stack.h>
#include "ecryptfs_kernel.h" #include "ecryptfs_kernel.h"
static struct dentry *lock_parent(struct dentry *dentry) static struct dentry *lock_parent(struct dentry *dentry)
...@@ -53,48 +54,6 @@ static void unlock_dir(struct dentry *dir) ...@@ -53,48 +54,6 @@ static void unlock_dir(struct dentry *dir)
dput(dir); dput(dir);
} }
void ecryptfs_copy_inode_size(struct inode *dst, const struct inode *src)
{
i_size_write(dst, i_size_read((struct inode *)src));
dst->i_blocks = src->i_blocks;
}
void ecryptfs_copy_attr_atime(struct inode *dest, const struct inode *src)
{
dest->i_atime = src->i_atime;
}
static void ecryptfs_copy_attr_times(struct inode *dest,
const struct inode *src)
{
dest->i_atime = src->i_atime;
dest->i_mtime = src->i_mtime;
dest->i_ctime = src->i_ctime;
}
static void ecryptfs_copy_attr_timesizes(struct inode *dest,
const struct inode *src)
{
dest->i_atime = src->i_atime;
dest->i_mtime = src->i_mtime;
dest->i_ctime = src->i_ctime;
ecryptfs_copy_inode_size(dest, src);
}
void ecryptfs_copy_attr_all(struct inode *dest, const struct inode *src)
{
dest->i_mode = src->i_mode;
dest->i_nlink = src->i_nlink;
dest->i_uid = src->i_uid;
dest->i_gid = src->i_gid;
dest->i_rdev = src->i_rdev;
dest->i_atime = src->i_atime;
dest->i_mtime = src->i_mtime;
dest->i_ctime = src->i_ctime;
dest->i_blkbits = src->i_blkbits;
dest->i_flags = src->i_flags;
}
/** /**
* ecryptfs_create_underlying_file * ecryptfs_create_underlying_file
* @lower_dir_inode: inode of the parent in the lower fs of the new file * @lower_dir_inode: inode of the parent in the lower fs of the new file
...@@ -171,8 +130,8 @@ ecryptfs_do_create(struct inode *directory_inode, ...@@ -171,8 +130,8 @@ ecryptfs_do_create(struct inode *directory_inode,
ecryptfs_printk(KERN_ERR, "Failure in ecryptfs_interpose\n"); ecryptfs_printk(KERN_ERR, "Failure in ecryptfs_interpose\n");
goto out_lock; goto out_lock;
} }
ecryptfs_copy_attr_timesizes(directory_inode, fsstack_copy_attr_times(directory_inode, lower_dir_dentry->d_inode);
lower_dir_dentry->d_inode); fsstack_copy_inode_size(directory_inode, lower_dir_dentry->d_inode);
out_lock: out_lock:
unlock_dir(lower_dir_dentry); unlock_dir(lower_dir_dentry);
out: out:
...@@ -365,7 +324,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -365,7 +324,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
"d_name.name = [%s]\n", lower_dentry, "d_name.name = [%s]\n", lower_dentry,
lower_dentry->d_name.name); lower_dentry->d_name.name);
lower_inode = lower_dentry->d_inode; lower_inode = lower_dentry->d_inode;
ecryptfs_copy_attr_atime(dir, lower_dir_dentry->d_inode); fsstack_copy_attr_atime(dir, lower_dir_dentry->d_inode);
BUG_ON(!atomic_read(&lower_dentry->d_count)); BUG_ON(!atomic_read(&lower_dentry->d_count));
ecryptfs_set_dentry_private(dentry, ecryptfs_set_dentry_private(dentry,
kmem_cache_alloc(ecryptfs_dentry_info_cache, kmem_cache_alloc(ecryptfs_dentry_info_cache,
...@@ -462,7 +421,8 @@ static int ecryptfs_link(struct dentry *old_dentry, struct inode *dir, ...@@ -462,7 +421,8 @@ static int ecryptfs_link(struct dentry *old_dentry, struct inode *dir,
rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb, 0); rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb, 0);
if (rc) if (rc)
goto out_lock; goto out_lock;
ecryptfs_copy_attr_timesizes(dir, lower_new_dentry->d_inode); fsstack_copy_attr_times(dir, lower_new_dentry->d_inode);
fsstack_copy_inode_size(dir, lower_new_dentry->d_inode);
old_dentry->d_inode->i_nlink = old_dentry->d_inode->i_nlink =
ecryptfs_inode_to_lower(old_dentry->d_inode)->i_nlink; ecryptfs_inode_to_lower(old_dentry->d_inode)->i_nlink;
i_size_write(new_dentry->d_inode, file_size_save); i_size_write(new_dentry->d_inode, file_size_save);
...@@ -488,7 +448,7 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -488,7 +448,7 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc); printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
goto out_unlock; goto out_unlock;
} }
ecryptfs_copy_attr_times(dir, lower_dir_inode); fsstack_copy_attr_times(dir, lower_dir_inode);
dentry->d_inode->i_nlink = dentry->d_inode->i_nlink =
ecryptfs_inode_to_lower(dentry->d_inode)->i_nlink; ecryptfs_inode_to_lower(dentry->d_inode)->i_nlink;
dentry->d_inode->i_ctime = dir->i_ctime; dentry->d_inode->i_ctime = dir->i_ctime;
...@@ -527,7 +487,8 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry, ...@@ -527,7 +487,8 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0); rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
if (rc) if (rc)
goto out_lock; goto out_lock;
ecryptfs_copy_attr_timesizes(dir, lower_dir_dentry->d_inode); fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode);
out_lock: out_lock:
unlock_dir(lower_dir_dentry); unlock_dir(lower_dir_dentry);
dput(lower_dentry); dput(lower_dentry);
...@@ -550,7 +511,8 @@ static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -550,7 +511,8 @@ static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0); rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
if (rc) if (rc)
goto out; goto out;
ecryptfs_copy_attr_timesizes(dir, lower_dir_dentry->d_inode); fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode);
dir->i_nlink = lower_dir_dentry->d_inode->i_nlink; dir->i_nlink = lower_dir_dentry->d_inode->i_nlink;
out: out:
unlock_dir(lower_dir_dentry); unlock_dir(lower_dir_dentry);
...@@ -573,7 +535,7 @@ static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -573,7 +535,7 @@ static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
dput(lower_dentry); dput(lower_dentry);
if (!rc) if (!rc)
d_delete(lower_dentry); d_delete(lower_dentry);
ecryptfs_copy_attr_times(dir, lower_dir_dentry->d_inode); fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
dir->i_nlink = lower_dir_dentry->d_inode->i_nlink; dir->i_nlink = lower_dir_dentry->d_inode->i_nlink;
unlock_dir(lower_dir_dentry); unlock_dir(lower_dir_dentry);
if (!rc) if (!rc)
...@@ -597,7 +559,8 @@ ecryptfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) ...@@ -597,7 +559,8 @@ ecryptfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0); rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
if (rc) if (rc)
goto out; goto out;
ecryptfs_copy_attr_timesizes(dir, lower_dir_dentry->d_inode); fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode);
out: out:
unlock_dir(lower_dir_dentry); unlock_dir(lower_dir_dentry);
if (!dentry->d_inode) if (!dentry->d_inode)
...@@ -626,9 +589,9 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -626,9 +589,9 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
lower_new_dir_dentry->d_inode, lower_new_dentry); lower_new_dir_dentry->d_inode, lower_new_dentry);
if (rc) if (rc)
goto out_lock; goto out_lock;
ecryptfs_copy_attr_all(new_dir, lower_new_dir_dentry->d_inode); fsstack_copy_attr_all(new_dir, lower_new_dir_dentry->d_inode, NULL);
if (new_dir != old_dir) if (new_dir != old_dir)
ecryptfs_copy_attr_all(old_dir, lower_old_dir_dentry->d_inode); fsstack_copy_attr_all(old_dir, lower_old_dir_dentry->d_inode, NULL);
out_lock: out_lock:
unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry); unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
dput(lower_new_dentry->d_parent); dput(lower_new_dentry->d_parent);
...@@ -684,8 +647,8 @@ ecryptfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz) ...@@ -684,8 +647,8 @@ ecryptfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz)
rc = -EFAULT; rc = -EFAULT;
} }
kfree(decoded_name); kfree(decoded_name);
ecryptfs_copy_attr_atime(dentry->d_inode, fsstack_copy_attr_atime(dentry->d_inode,
lower_dentry->d_inode); lower_dentry->d_inode);
} }
out_free_lower_buf: out_free_lower_buf:
kfree(lower_buf); kfree(lower_buf);
...@@ -915,7 +878,7 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia) ...@@ -915,7 +878,7 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
} }
rc = notify_change(lower_dentry, ia); rc = notify_change(lower_dentry, ia);
out: out:
ecryptfs_copy_attr_all(inode, lower_inode); fsstack_copy_attr_all(inode, lower_inode, NULL);
return rc; return rc;
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/key.h> #include <linux/key.h>
#include <linux/parser.h> #include <linux/parser.h>
#include <linux/fs_stack.h>
#include "ecryptfs_kernel.h" #include "ecryptfs_kernel.h"
/** /**
...@@ -112,10 +113,10 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry, ...@@ -112,10 +113,10 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry,
d_add(dentry, inode); d_add(dentry, inode);
else else
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
ecryptfs_copy_attr_all(inode, lower_inode); fsstack_copy_attr_all(inode, lower_inode, NULL);
/* This size will be overwritten for real files w/ headers and /* This size will be overwritten for real files w/ headers and
* other metadata */ * other metadata */
ecryptfs_copy_inode_size(inode, lower_inode); fsstack_copy_inode_size(inode, lower_inode);
out: out:
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment