aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/crypto.c
diff options
context:
space:
mode:
authorMichael Halcrow <mhalcrow@us.ibm.com>2006-10-31 01:07:19 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-31 11:07:01 -0500
commit7ff1d74f5670329ac4b5959a675f8698ba95be20 (patch)
tree1084427fcd0b979c8434315050033dd356623cf3 /fs/ecryptfs/crypto.c
parent8bba066f4e3854755a303cee37ea37bd080a46b3 (diff)
[PATCH] eCryptfs: Consolidate lower dentry_open's
Opens on lower dentry objects happen in several places in eCryptfs, and they all involve the same steps (dget, mntget, dentry_open). This patch consolidates the lower open events into a single function call. Signed-off-by: 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/crypto.c')
-rw-r--r--fs/ecryptfs/crypto.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 2a1b6aa1a4a1..f49f105394b7 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -1191,28 +1191,28 @@ int ecryptfs_cipher_code_to_string(char *str, u16 cipher_code)
1191int ecryptfs_read_header_region(char *data, struct dentry *dentry, 1191int ecryptfs_read_header_region(char *data, struct dentry *dentry,
1192 struct vfsmount *mnt) 1192 struct vfsmount *mnt)
1193{ 1193{
1194 struct file *file; 1194 struct file *lower_file;
1195 mm_segment_t oldfs; 1195 mm_segment_t oldfs;
1196 int rc; 1196 int rc;
1197 1197
1198 mnt = mntget(mnt); 1198 if ((rc = ecryptfs_open_lower_file(&lower_file, dentry, mnt,
1199 file = dentry_open(dentry, mnt, O_RDONLY); 1199 O_RDONLY))) {
1200 if (IS_ERR(file)) { 1200 printk(KERN_ERR
1201 ecryptfs_printk(KERN_DEBUG, "Error opening file to " 1201 "Error opening lower_file to read header region\n");
1202 "read header region\n");
1203 mntput(mnt);
1204 rc = PTR_ERR(file);
1205 goto out; 1202 goto out;
1206 } 1203 }
1207 file->f_pos = 0; 1204 lower_file->f_pos = 0;
1208 oldfs = get_fs(); 1205 oldfs = get_fs();
1209 set_fs(get_ds()); 1206 set_fs(get_ds());
1210 /* For releases 0.1 and 0.2, all of the header information 1207 /* For releases 0.1 and 0.2, all of the header information
1211 * fits in the first data extent-sized region. */ 1208 * fits in the first data extent-sized region. */
1212 rc = file->f_op->read(file, (char __user *)data, 1209 rc = lower_file->f_op->read(lower_file, (char __user *)data,
1213 ECRYPTFS_DEFAULT_EXTENT_SIZE, &file->f_pos); 1210 ECRYPTFS_DEFAULT_EXTENT_SIZE, &lower_file->f_pos);
1214 set_fs(oldfs); 1211 set_fs(oldfs);
1215 fput(file); 1212 if ((rc = ecryptfs_close_lower_file(lower_file))) {
1213 printk(KERN_ERR "Error closing lower_file\n");
1214 goto out;
1215 }
1216 rc = 0; 1216 rc = 0;
1217out: 1217out:
1218 return rc; 1218 return rc;