aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/inode.c
diff options
context:
space:
mode:
authorJosef "Jeff" Sipek <jsipek@cs.sunysb.edu>2006-12-08 05:36:31 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 11:28:40 -0500
commit0cc72dc7f050188d8d7344b1dd688cbc68d3cd30 (patch)
tree80a43eb49ca7b720050b7da1eb1d7175b6eaa091 /fs/ecryptfs/inode.c
parent42cf11939becc717bd125d121a1a23415106a099 (diff)
[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: Josef "Jeff" Sipek <jsipek@cs.sunysb.edu> Cc: Michael Halcrow <mhalcrow@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ecryptfs/inode.c')
-rw-r--r--fs/ecryptfs/inode.c75
1 files changed, 19 insertions, 56 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 8a1945a84c36..c07a937b21ac 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -30,6 +30,7 @@
30#include <linux/namei.h> 30#include <linux/namei.h>
31#include <linux/mount.h> 31#include <linux/mount.h>
32#include <linux/crypto.h> 32#include <linux/crypto.h>
33#include <linux/fs_stack.h>
33#include "ecryptfs_kernel.h" 34#include "ecryptfs_kernel.h"
34 35
35static struct dentry *lock_parent(struct dentry *dentry) 36static struct dentry *lock_parent(struct dentry *dentry)
@@ -53,48 +54,6 @@ static void unlock_dir(struct dentry *dir)
53 dput(dir); 54 dput(dir);
54} 55}
55 56
56void ecryptfs_copy_inode_size(struct inode *dst, const struct inode *src)
57{
58 i_size_write(dst, i_size_read((struct inode *)src));
59 dst->i_blocks = src->i_blocks;
60}
61
62void ecryptfs_copy_attr_atime(struct inode *dest, const struct inode *src)
63{
64 dest->i_atime = src->i_atime;
65}
66
67static void ecryptfs_copy_attr_times(struct inode *dest,
68 const struct inode *src)
69{
70 dest->i_atime = src->i_atime;
71 dest->i_mtime = src->i_mtime;
72 dest->i_ctime = src->i_ctime;
73}
74
75static void ecryptfs_copy_attr_timesizes(struct inode *dest,
76 const struct inode *src)
77{
78 dest->i_atime = src->i_atime;
79 dest->i_mtime = src->i_mtime;
80 dest->i_ctime = src->i_ctime;
81 ecryptfs_copy_inode_size(dest, src);
82}
83
84void ecryptfs_copy_attr_all(struct inode *dest, const struct inode *src)
85{
86 dest->i_mode = src->i_mode;
87 dest->i_nlink = src->i_nlink;
88 dest->i_uid = src->i_uid;
89 dest->i_gid = src->i_gid;
90 dest->i_rdev = src->i_rdev;
91 dest->i_atime = src->i_atime;
92 dest->i_mtime = src->i_mtime;
93 dest->i_ctime = src->i_ctime;
94 dest->i_blkbits = src->i_blkbits;
95 dest->i_flags = src->i_flags;
96}
97
98/** 57/**
99 * ecryptfs_create_underlying_file 58 * ecryptfs_create_underlying_file
100 * @lower_dir_inode: inode of the parent in the lower fs of the new file 59 * @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 ecryptfs_printk(KERN_ERR, "Failure in ecryptfs_interpose\n"); 130 ecryptfs_printk(KERN_ERR, "Failure in ecryptfs_interpose\n");
172 goto out_lock; 131 goto out_lock;
173 } 132 }
174 ecryptfs_copy_attr_timesizes(directory_inode, 133 fsstack_copy_attr_times(directory_inode, lower_dir_dentry->d_inode);
175 lower_dir_dentry->d_inode); 134 fsstack_copy_inode_size(directory_inode, lower_dir_dentry->d_inode);
176out_lock: 135out_lock:
177 unlock_dir(lower_dir_dentry); 136 unlock_dir(lower_dir_dentry);
178out: 137out:
@@ -365,7 +324,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
365 "d_name.name = [%s]\n", lower_dentry, 324 "d_name.name = [%s]\n", lower_dentry,
366 lower_dentry->d_name.name); 325 lower_dentry->d_name.name);
367 lower_inode = lower_dentry->d_inode; 326 lower_inode = lower_dentry->d_inode;
368 ecryptfs_copy_attr_atime(dir, lower_dir_dentry->d_inode); 327 fsstack_copy_attr_atime(dir, lower_dir_dentry->d_inode);
369 BUG_ON(!atomic_read(&lower_dentry->d_count)); 328 BUG_ON(!atomic_read(&lower_dentry->d_count));
370 ecryptfs_set_dentry_private(dentry, 329 ecryptfs_set_dentry_private(dentry,
371 kmem_cache_alloc(ecryptfs_dentry_info_cache, 330 kmem_cache_alloc(ecryptfs_dentry_info_cache,
@@ -462,7 +421,8 @@ static int ecryptfs_link(struct dentry *old_dentry, struct inode *dir,
462 rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb, 0); 421 rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb, 0);
463 if (rc) 422 if (rc)
464 goto out_lock; 423 goto out_lock;
465 ecryptfs_copy_attr_timesizes(dir, lower_new_dentry->d_inode); 424 fsstack_copy_attr_times(dir, lower_new_dentry->d_inode);
425 fsstack_copy_inode_size(dir, lower_new_dentry->d_inode);
466 old_dentry->d_inode->i_nlink = 426 old_dentry->d_inode->i_nlink =
467 ecryptfs_inode_to_lower(old_dentry->d_inode)->i_nlink; 427 ecryptfs_inode_to_lower(old_dentry->d_inode)->i_nlink;
468 i_size_write(new_dentry->d_inode, file_size_save); 428 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 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc); 448 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
489 goto out_unlock; 449 goto out_unlock;
490 } 450 }
491 ecryptfs_copy_attr_times(dir, lower_dir_inode); 451 fsstack_copy_attr_times(dir, lower_dir_inode);
492 dentry->d_inode->i_nlink = 452 dentry->d_inode->i_nlink =
493 ecryptfs_inode_to_lower(dentry->d_inode)->i_nlink; 453 ecryptfs_inode_to_lower(dentry->d_inode)->i_nlink;
494 dentry->d_inode->i_ctime = dir->i_ctime; 454 dentry->d_inode->i_ctime = dir->i_ctime;
@@ -527,7 +487,8 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
527 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0); 487 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
528 if (rc) 488 if (rc)
529 goto out_lock; 489 goto out_lock;
530 ecryptfs_copy_attr_timesizes(dir, lower_dir_dentry->d_inode); 490 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
491 fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode);
531out_lock: 492out_lock:
532 unlock_dir(lower_dir_dentry); 493 unlock_dir(lower_dir_dentry);
533 dput(lower_dentry); 494 dput(lower_dentry);
@@ -550,7 +511,8 @@ static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
550 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0); 511 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
551 if (rc) 512 if (rc)
552 goto out; 513 goto out;
553 ecryptfs_copy_attr_timesizes(dir, lower_dir_dentry->d_inode); 514 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
515 fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode);
554 dir->i_nlink = lower_dir_dentry->d_inode->i_nlink; 516 dir->i_nlink = lower_dir_dentry->d_inode->i_nlink;
555out: 517out:
556 unlock_dir(lower_dir_dentry); 518 unlock_dir(lower_dir_dentry);
@@ -573,7 +535,7 @@ static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
573 dput(lower_dentry); 535 dput(lower_dentry);
574 if (!rc) 536 if (!rc)
575 d_delete(lower_dentry); 537 d_delete(lower_dentry);
576 ecryptfs_copy_attr_times(dir, lower_dir_dentry->d_inode); 538 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
577 dir->i_nlink = lower_dir_dentry->d_inode->i_nlink; 539 dir->i_nlink = lower_dir_dentry->d_inode->i_nlink;
578 unlock_dir(lower_dir_dentry); 540 unlock_dir(lower_dir_dentry);
579 if (!rc) 541 if (!rc)
@@ -597,7 +559,8 @@ ecryptfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
597 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0); 559 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
598 if (rc) 560 if (rc)
599 goto out; 561 goto out;
600 ecryptfs_copy_attr_timesizes(dir, lower_dir_dentry->d_inode); 562 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
563 fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode);
601out: 564out:
602 unlock_dir(lower_dir_dentry); 565 unlock_dir(lower_dir_dentry);
603 if (!dentry->d_inode) 566 if (!dentry->d_inode)
@@ -626,9 +589,9 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
626 lower_new_dir_dentry->d_inode, lower_new_dentry); 589 lower_new_dir_dentry->d_inode, lower_new_dentry);
627 if (rc) 590 if (rc)
628 goto out_lock; 591 goto out_lock;
629 ecryptfs_copy_attr_all(new_dir, lower_new_dir_dentry->d_inode); 592 fsstack_copy_attr_all(new_dir, lower_new_dir_dentry->d_inode, NULL);
630 if (new_dir != old_dir) 593 if (new_dir != old_dir)
631 ecryptfs_copy_attr_all(old_dir, lower_old_dir_dentry->d_inode); 594 fsstack_copy_attr_all(old_dir, lower_old_dir_dentry->d_inode, NULL);
632out_lock: 595out_lock:
633 unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry); 596 unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
634 dput(lower_new_dentry->d_parent); 597 dput(lower_new_dentry->d_parent);
@@ -684,8 +647,8 @@ ecryptfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz)
684 rc = -EFAULT; 647 rc = -EFAULT;
685 } 648 }
686 kfree(decoded_name); 649 kfree(decoded_name);
687 ecryptfs_copy_attr_atime(dentry->d_inode, 650 fsstack_copy_attr_atime(dentry->d_inode,
688 lower_dentry->d_inode); 651 lower_dentry->d_inode);
689 } 652 }
690out_free_lower_buf: 653out_free_lower_buf:
691 kfree(lower_buf); 654 kfree(lower_buf);
@@ -915,7 +878,7 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
915 } 878 }
916 rc = notify_change(lower_dentry, ia); 879 rc = notify_change(lower_dentry, ia);
917out: 880out:
918 ecryptfs_copy_attr_all(inode, lower_inode); 881 fsstack_copy_attr_all(inode, lower_inode, NULL);
919 return rc; 882 return rc;
920} 883}
921 884