aboutsummaryrefslogtreecommitdiffstats
path: root/fs
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
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')
-rw-r--r--fs/ecryptfs/dentry.c3
-rw-r--r--fs/ecryptfs/ecryptfs_kernel.h4
-rw-r--r--fs/ecryptfs/file.c3
-rw-r--r--fs/ecryptfs/inode.c75
-rw-r--r--fs/ecryptfs/main.c5
5 files changed, 27 insertions, 63 deletions
diff --git a/fs/ecryptfs/dentry.c b/fs/ecryptfs/dentry.c
index 52d1e36dc746..329efcd3d8c9 100644
--- a/fs/ecryptfs/dentry.c
+++ b/fs/ecryptfs/dentry.c
@@ -25,6 +25,7 @@
25#include <linux/dcache.h> 25#include <linux/dcache.h>
26#include <linux/namei.h> 26#include <linux/namei.h>
27#include <linux/mount.h> 27#include <linux/mount.h>
28#include <linux/fs_stack.h>
28#include "ecryptfs_kernel.h" 29#include "ecryptfs_kernel.h"
29 30
30/** 31/**
@@ -61,7 +62,7 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
61 struct inode *lower_inode = 62 struct inode *lower_inode =
62 ecryptfs_inode_to_lower(dentry->d_inode); 63 ecryptfs_inode_to_lower(dentry->d_inode);
63 64
64 ecryptfs_copy_attr_all(dentry->d_inode, lower_inode); 65 fsstack_copy_attr_all(dentry->d_inode, lower_inode, NULL);
65 } 66 }
66out: 67out:
67 return rc; 68 return rc;
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index f992533d1692..424137fb5898 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -28,6 +28,7 @@
28 28
29#include <keys/user-type.h> 29#include <keys/user-type.h>
30#include <linux/fs.h> 30#include <linux/fs.h>
31#include <linux/fs_stack.h>
31#include <linux/scatterlist.h> 32#include <linux/scatterlist.h>
32 33
33/* Version verification for shared data structures w/ userspace */ 34/* Version verification for shared data structures w/ userspace */
@@ -413,9 +414,6 @@ int ecryptfs_encode_filename(struct ecryptfs_crypt_stat *crypt_stat,
413 const char *name, int length, 414 const char *name, int length,
414 char **encoded_name); 415 char **encoded_name);
415struct dentry *ecryptfs_lower_dentry(struct dentry *this_dentry); 416struct dentry *ecryptfs_lower_dentry(struct dentry *this_dentry);
416void ecryptfs_copy_attr_atime(struct inode *dest, const struct inode *src);
417void ecryptfs_copy_attr_all(struct inode *dest, const struct inode *src);
418void ecryptfs_copy_inode_size(struct inode *dst, const struct inode *src);
419void ecryptfs_dump_hex(char *data, int bytes); 417void ecryptfs_dump_hex(char *data, int bytes);
420int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg, 418int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg,
421 int sg_size); 419 int sg_size);
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index 42099e779a56..c48e4590b110 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -30,6 +30,7 @@
30#include <linux/security.h> 30#include <linux/security.h>
31#include <linux/smp_lock.h> 31#include <linux/smp_lock.h>
32#include <linux/compat.h> 32#include <linux/compat.h>
33#include <linux/fs_stack.h>
33#include "ecryptfs_kernel.h" 34#include "ecryptfs_kernel.h"
34 35
35/** 36/**
@@ -192,7 +193,7 @@ retry:
192 goto retry; 193 goto retry;
193 file->f_pos = lower_file->f_pos; 194 file->f_pos = lower_file->f_pos;
194 if (rc >= 0) 195 if (rc >= 0)
195 ecryptfs_copy_attr_atime(inode, lower_file->f_dentry->d_inode); 196 fsstack_copy_attr_atime(inode, lower_file->f_dentry->d_inode);
196 return rc; 197 return rc;
197} 198}
198 199
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
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 3ede12b25933..d0541ae8faba 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -35,6 +35,7 @@
35#include <linux/pagemap.h> 35#include <linux/pagemap.h>
36#include <linux/key.h> 36#include <linux/key.h>
37#include <linux/parser.h> 37#include <linux/parser.h>
38#include <linux/fs_stack.h>
38#include "ecryptfs_kernel.h" 39#include "ecryptfs_kernel.h"
39 40
40/** 41/**
@@ -112,10 +113,10 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry,
112 d_add(dentry, inode); 113 d_add(dentry, inode);
113 else 114 else
114 d_instantiate(dentry, inode); 115 d_instantiate(dentry, inode);
115 ecryptfs_copy_attr_all(inode, lower_inode); 116 fsstack_copy_attr_all(inode, lower_inode, NULL);
116 /* This size will be overwritten for real files w/ headers and 117 /* This size will be overwritten for real files w/ headers and
117 * other metadata */ 118 * other metadata */
118 ecryptfs_copy_inode_size(inode, lower_inode); 119 fsstack_copy_inode_size(inode, lower_inode);
119out: 120out:
120 return rc; 121 return rc;
121} 122}