Skip to content

Commit 0cc72dc

Browse files
Josef "Jeff" SipekLinus Torvalds
authored andcommitted
[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>
1 parent 42cf119 commit 0cc72dc

5 files changed

Lines changed: 27 additions & 63 deletions

File tree

‎fs/ecryptfs/dentry.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/dcache.h>
2626
#include <linux/namei.h>
2727
#include <linux/mount.h>
28+
#include <linux/fs_stack.h>
2829
#include "ecryptfs_kernel.h"
2930

3031
/**
@@ -61,7 +62,7 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
6162
struct inode *lower_inode =
6263
ecryptfs_inode_to_lower(dentry->d_inode);
6364

64-
ecryptfs_copy_attr_all(dentry->d_inode, lower_inode);
65+
fsstack_copy_attr_all(dentry->d_inode, lower_inode, NULL);
6566
}
6667
out:
6768
return rc;

‎fs/ecryptfs/ecryptfs_kernel.h‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include <keys/user-type.h>
3030
#include <linux/fs.h>
31+
#include <linux/fs_stack.h>
3132
#include <linux/scatterlist.h>
3233

3334
/* Version verification for shared data structures w/ userspace */
@@ -413,9 +414,6 @@ int ecryptfs_encode_filename(struct ecryptfs_crypt_stat *crypt_stat,
413414
const char *name, int length,
414415
char **encoded_name);
415416
struct dentry *ecryptfs_lower_dentry(struct dentry *this_dentry);
416-
void ecryptfs_copy_attr_atime(struct inode *dest, const struct inode *src);
417-
void ecryptfs_copy_attr_all(struct inode *dest, const struct inode *src);
418-
void ecryptfs_copy_inode_size(struct inode *dst, const struct inode *src);
419417
void ecryptfs_dump_hex(char *data, int bytes);
420418
int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg,
421419
int sg_size);

‎fs/ecryptfs/file.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/security.h>
3131
#include <linux/smp_lock.h>
3232
#include <linux/compat.h>
33+
#include <linux/fs_stack.h>
3334
#include "ecryptfs_kernel.h"
3435

3536
/**
@@ -192,7 +193,7 @@ static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir)
192193
goto retry;
193194
file->f_pos = lower_file->f_pos;
194195
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);
196197
return rc;
197198
}
198199

‎fs/ecryptfs/inode.c‎

Lines changed: 19 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/namei.h>
3131
#include <linux/mount.h>
3232
#include <linux/crypto.h>
33+
#include <linux/fs_stack.h>
3334
#include "ecryptfs_kernel.h"
3435

3536
static struct dentry *lock_parent(struct dentry *dentry)
@@ -53,48 +54,6 @@ static void unlock_dir(struct dentry *dir)
5354
dput(dir);
5455
}
5556

56-
void 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-
62-
void ecryptfs_copy_attr_atime(struct inode *dest, const struct inode *src)
63-
{
64-
dest->i_atime = src->i_atime;
65-
}
66-
67-
static 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-
75-
static 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-
84-
void 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-
9857
/**
9958
* ecryptfs_create_underlying_file
10059
* @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,
171130
ecryptfs_printk(KERN_ERR, "Failure in ecryptfs_interpose\n");
172131
goto out_lock;
173132
}
174-
ecryptfs_copy_attr_timesizes(directory_inode,
175-
lower_dir_dentry->d_inode);
133+
fsstack_copy_attr_times(directory_inode, lower_dir_dentry->d_inode);
134+
fsstack_copy_inode_size(directory_inode, lower_dir_dentry->d_inode);
176135
out_lock:
177136
unlock_dir(lower_dir_dentry);
178137
out:
@@ -365,7 +324,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
365324
"d_name.name = [%s]\n", lower_dentry,
366325
lower_dentry->d_name.name);
367326
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);
369328
BUG_ON(!atomic_read(&lower_dentry->d_count));
370329
ecryptfs_set_dentry_private(dentry,
371330
kmem_cache_alloc(ecryptfs_dentry_info_cache,
@@ -462,7 +421,8 @@ static int ecryptfs_link(struct dentry *old_dentry, struct inode *dir,
462421
rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb, 0);
463422
if (rc)
464423
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);
466426
old_dentry->d_inode->i_nlink =
467427
ecryptfs_inode_to_lower(old_dentry->d_inode)->i_nlink;
468428
i_size_write(new_dentry->d_inode, file_size_save);
@@ -488,7 +448,7 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
488448
printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
489449
goto out_unlock;
490450
}
491-
ecryptfs_copy_attr_times(dir, lower_dir_inode);
451+
fsstack_copy_attr_times(dir, lower_dir_inode);
492452
dentry->d_inode->i_nlink =
493453
ecryptfs_inode_to_lower(dentry->d_inode)->i_nlink;
494454
dentry->d_inode->i_ctime = dir->i_ctime;
@@ -527,7 +487,8 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
527487
rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
528488
if (rc)
529489
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);
531492
out_lock:
532493
unlock_dir(lower_dir_dentry);
533494
dput(lower_dentry);
@@ -550,7 +511,8 @@ static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
550511
rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
551512
if (rc)
552513
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);
554516
dir->i_nlink = lower_dir_dentry->d_inode->i_nlink;
555517
out:
556518
unlock_dir(lower_dir_dentry);
@@ -573,7 +535,7 @@ static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
573535
dput(lower_dentry);
574536
if (!rc)
575537
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);
577539
dir->i_nlink = lower_dir_dentry->d_inode->i_nlink;
578540
unlock_dir(lower_dir_dentry);
579541
if (!rc)
@@ -597,7 +559,8 @@ ecryptfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
597559
rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
598560
if (rc)
599561
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);
601564
out:
602565
unlock_dir(lower_dir_dentry);
603566
if (!dentry->d_inode)
@@ -626,9 +589,9 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
626589
lower_new_dir_dentry->d_inode, lower_new_dentry);
627590
if (rc)
628591
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);
630593
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);
632595
out_lock:
633596
unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
634597
dput(lower_new_dentry->d_parent);
@@ -684,8 +647,8 @@ ecryptfs_readlink(struct dentry *dentry, char __user * buf, int bufsiz)
684647
rc = -EFAULT;
685648
}
686649
kfree(decoded_name);
687-
ecryptfs_copy_attr_atime(dentry->d_inode,
688-
lower_dentry->d_inode);
650+
fsstack_copy_attr_atime(dentry->d_inode,
651+
lower_dentry->d_inode);
689652
}
690653
out_free_lower_buf:
691654
kfree(lower_buf);
@@ -915,7 +878,7 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
915878
}
916879
rc = notify_change(lower_dentry, ia);
917880
out:
918-
ecryptfs_copy_attr_all(inode, lower_inode);
881+
fsstack_copy_attr_all(inode, lower_inode, NULL);
919882
return rc;
920883
}
921884

‎fs/ecryptfs/main.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/pagemap.h>
3636
#include <linux/key.h>
3737
#include <linux/parser.h>
38+
#include <linux/fs_stack.h>
3839
#include "ecryptfs_kernel.h"
3940

4041
/**
@@ -112,10 +113,10 @@ int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry,
112113
d_add(dentry, inode);
113114
else
114115
d_instantiate(dentry, inode);
115-
ecryptfs_copy_attr_all(inode, lower_inode);
116+
fsstack_copy_attr_all(inode, lower_inode, NULL);
116117
/* This size will be overwritten for real files w/ headers and
117118
* other metadata */
118-
ecryptfs_copy_inode_size(inode, lower_inode);
119+
fsstack_copy_inode_size(inode, lower_inode);
119120
out:
120121
return rc;
121122
}

0 commit comments

Comments
 (0)