diff options
Diffstat (limited to 'fs/ecryptfs/inode.c')
-rw-r--r-- | fs/ecryptfs/inode.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index ffa2be57804d..c3ca12c33ca2 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -318,21 +318,20 @@ static int ecryptfs_lookup_interpose(struct dentry *dentry, | |||
318 | struct vfsmount *lower_mnt; | 318 | struct vfsmount *lower_mnt; |
319 | int rc = 0; | 319 | int rc = 0; |
320 | 320 | ||
321 | lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(dentry->d_parent)); | ||
322 | fsstack_copy_attr_atime(dir_inode, lower_dentry->d_parent->d_inode); | ||
323 | BUG_ON(!lower_dentry->d_count); | ||
324 | |||
325 | dentry_info = kmem_cache_alloc(ecryptfs_dentry_info_cache, GFP_KERNEL); | 321 | dentry_info = kmem_cache_alloc(ecryptfs_dentry_info_cache, GFP_KERNEL); |
326 | ecryptfs_set_dentry_private(dentry, dentry_info); | ||
327 | if (!dentry_info) { | 322 | if (!dentry_info) { |
328 | printk(KERN_ERR "%s: Out of memory whilst attempting " | 323 | printk(KERN_ERR "%s: Out of memory whilst attempting " |
329 | "to allocate ecryptfs_dentry_info struct\n", | 324 | "to allocate ecryptfs_dentry_info struct\n", |
330 | __func__); | 325 | __func__); |
331 | dput(lower_dentry); | 326 | dput(lower_dentry); |
332 | mntput(lower_mnt); | ||
333 | d_drop(dentry); | ||
334 | return -ENOMEM; | 327 | return -ENOMEM; |
335 | } | 328 | } |
329 | |||
330 | lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(dentry->d_parent)); | ||
331 | fsstack_copy_attr_atime(dir_inode, lower_dentry->d_parent->d_inode); | ||
332 | BUG_ON(!lower_dentry->d_count); | ||
333 | |||
334 | ecryptfs_set_dentry_private(dentry, dentry_info); | ||
336 | ecryptfs_set_dentry_lower(dentry, lower_dentry); | 335 | ecryptfs_set_dentry_lower(dentry, lower_dentry); |
337 | ecryptfs_set_dentry_lower_mnt(dentry, lower_mnt); | 336 | ecryptfs_set_dentry_lower_mnt(dentry, lower_mnt); |
338 | 337 | ||
@@ -381,12 +380,6 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode, | |||
381 | struct dentry *lower_dir_dentry, *lower_dentry; | 380 | struct dentry *lower_dir_dentry, *lower_dentry; |
382 | int rc = 0; | 381 | int rc = 0; |
383 | 382 | ||
384 | if ((ecryptfs_dentry->d_name.len == 1 | ||
385 | && !strcmp(ecryptfs_dentry->d_name.name, ".")) | ||
386 | || (ecryptfs_dentry->d_name.len == 2 | ||
387 | && !strcmp(ecryptfs_dentry->d_name.name, ".."))) { | ||
388 | goto out_d_drop; | ||
389 | } | ||
390 | lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent); | 383 | lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent); |
391 | mutex_lock(&lower_dir_dentry->d_inode->i_mutex); | 384 | mutex_lock(&lower_dir_dentry->d_inode->i_mutex); |
392 | lower_dentry = lookup_one_len(ecryptfs_dentry->d_name.name, | 385 | lower_dentry = lookup_one_len(ecryptfs_dentry->d_name.name, |
@@ -397,8 +390,8 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode, | |||
397 | rc = PTR_ERR(lower_dentry); | 390 | rc = PTR_ERR(lower_dentry); |
398 | ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " | 391 | ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " |
399 | "[%d] on lower_dentry = [%s]\n", __func__, rc, | 392 | "[%d] on lower_dentry = [%s]\n", __func__, rc, |
400 | encrypted_and_encoded_name); | 393 | ecryptfs_dentry->d_name.name); |
401 | goto out_d_drop; | 394 | goto out; |
402 | } | 395 | } |
403 | if (lower_dentry->d_inode) | 396 | if (lower_dentry->d_inode) |
404 | goto interpose; | 397 | goto interpose; |
@@ -415,7 +408,7 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode, | |||
415 | if (rc) { | 408 | if (rc) { |
416 | printk(KERN_ERR "%s: Error attempting to encrypt and encode " | 409 | printk(KERN_ERR "%s: Error attempting to encrypt and encode " |
417 | "filename; rc = [%d]\n", __func__, rc); | 410 | "filename; rc = [%d]\n", __func__, rc); |
418 | goto out_d_drop; | 411 | goto out; |
419 | } | 412 | } |
420 | mutex_lock(&lower_dir_dentry->d_inode->i_mutex); | 413 | mutex_lock(&lower_dir_dentry->d_inode->i_mutex); |
421 | lower_dentry = lookup_one_len(encrypted_and_encoded_name, | 414 | lower_dentry = lookup_one_len(encrypted_and_encoded_name, |
@@ -427,14 +420,11 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode, | |||
427 | ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " | 420 | ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " |
428 | "[%d] on lower_dentry = [%s]\n", __func__, rc, | 421 | "[%d] on lower_dentry = [%s]\n", __func__, rc, |
429 | encrypted_and_encoded_name); | 422 | encrypted_and_encoded_name); |
430 | goto out_d_drop; | 423 | goto out; |
431 | } | 424 | } |
432 | interpose: | 425 | interpose: |
433 | rc = ecryptfs_lookup_interpose(ecryptfs_dentry, lower_dentry, | 426 | rc = ecryptfs_lookup_interpose(ecryptfs_dentry, lower_dentry, |
434 | ecryptfs_dir_inode); | 427 | ecryptfs_dir_inode); |
435 | goto out; | ||
436 | out_d_drop: | ||
437 | d_drop(ecryptfs_dentry); | ||
438 | out: | 428 | out: |
439 | kfree(encrypted_and_encoded_name); | 429 | kfree(encrypted_and_encoded_name); |
440 | return ERR_PTR(rc); | 430 | return ERR_PTR(rc); |