aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ecryptfs/inode.c')
-rw-r--r--fs/ecryptfs/inode.c164
1 files changed, 82 insertions, 82 deletions
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index b08b5187f662..fc850b55db67 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -41,13 +41,13 @@ static struct dentry *lock_parent(struct dentry *dentry)
41 struct dentry *dir; 41 struct dentry *dir;
42 42
43 dir = dget_parent(dentry); 43 dir = dget_parent(dentry);
44 mutex_lock_nested(&(dir->d_inode->i_mutex), I_MUTEX_PARENT); 44 mutex_lock_nested(&(d_inode(dir)->i_mutex), I_MUTEX_PARENT);
45 return dir; 45 return dir;
46} 46}
47 47
48static void unlock_dir(struct dentry *dir) 48static void unlock_dir(struct dentry *dir)
49{ 49{
50 mutex_unlock(&dir->d_inode->i_mutex); 50 mutex_unlock(&d_inode(dir)->i_mutex);
51 dput(dir); 51 dput(dir);
52} 52}
53 53
@@ -131,7 +131,7 @@ struct inode *ecryptfs_get_inode(struct inode *lower_inode,
131static int ecryptfs_interpose(struct dentry *lower_dentry, 131static int ecryptfs_interpose(struct dentry *lower_dentry,
132 struct dentry *dentry, struct super_block *sb) 132 struct dentry *dentry, struct super_block *sb)
133{ 133{
134 struct inode *inode = ecryptfs_get_inode(lower_dentry->d_inode, sb); 134 struct inode *inode = ecryptfs_get_inode(d_inode(lower_dentry), sb);
135 135
136 if (IS_ERR(inode)) 136 if (IS_ERR(inode))
137 return PTR_ERR(inode); 137 return PTR_ERR(inode);
@@ -189,21 +189,21 @@ ecryptfs_do_create(struct inode *directory_inode,
189 189
190 lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry); 190 lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry);
191 lower_dir_dentry = lock_parent(lower_dentry); 191 lower_dir_dentry = lock_parent(lower_dentry);
192 rc = vfs_create(lower_dir_dentry->d_inode, lower_dentry, mode, true); 192 rc = vfs_create(d_inode(lower_dir_dentry), lower_dentry, mode, true);
193 if (rc) { 193 if (rc) {
194 printk(KERN_ERR "%s: Failure to create dentry in lower fs; " 194 printk(KERN_ERR "%s: Failure to create dentry in lower fs; "
195 "rc = [%d]\n", __func__, rc); 195 "rc = [%d]\n", __func__, rc);
196 inode = ERR_PTR(rc); 196 inode = ERR_PTR(rc);
197 goto out_lock; 197 goto out_lock;
198 } 198 }
199 inode = __ecryptfs_get_inode(lower_dentry->d_inode, 199 inode = __ecryptfs_get_inode(d_inode(lower_dentry),
200 directory_inode->i_sb); 200 directory_inode->i_sb);
201 if (IS_ERR(inode)) { 201 if (IS_ERR(inode)) {
202 vfs_unlink(lower_dir_dentry->d_inode, lower_dentry, NULL); 202 vfs_unlink(d_inode(lower_dir_dentry), lower_dentry, NULL);
203 goto out_lock; 203 goto out_lock;
204 } 204 }
205 fsstack_copy_attr_times(directory_inode, lower_dir_dentry->d_inode); 205 fsstack_copy_attr_times(directory_inode, d_inode(lower_dir_dentry));
206 fsstack_copy_inode_size(directory_inode, lower_dir_dentry->d_inode); 206 fsstack_copy_inode_size(directory_inode, d_inode(lower_dir_dentry));
207out_lock: 207out_lock:
208 unlock_dir(lower_dir_dentry); 208 unlock_dir(lower_dir_dentry);
209 return inode; 209 return inode;
@@ -332,7 +332,7 @@ static int ecryptfs_lookup_interpose(struct dentry *dentry,
332 struct dentry *lower_dentry, 332 struct dentry *lower_dentry,
333 struct inode *dir_inode) 333 struct inode *dir_inode)
334{ 334{
335 struct inode *inode, *lower_inode = lower_dentry->d_inode; 335 struct inode *inode, *lower_inode = d_inode(lower_dentry);
336 struct ecryptfs_dentry_info *dentry_info; 336 struct ecryptfs_dentry_info *dentry_info;
337 struct vfsmount *lower_mnt; 337 struct vfsmount *lower_mnt;
338 int rc = 0; 338 int rc = 0;
@@ -347,14 +347,14 @@ static int ecryptfs_lookup_interpose(struct dentry *dentry,
347 } 347 }
348 348
349 lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(dentry->d_parent)); 349 lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(dentry->d_parent));
350 fsstack_copy_attr_atime(dir_inode, lower_dentry->d_parent->d_inode); 350 fsstack_copy_attr_atime(dir_inode, d_inode(lower_dentry->d_parent));
351 BUG_ON(!d_count(lower_dentry)); 351 BUG_ON(!d_count(lower_dentry));
352 352
353 ecryptfs_set_dentry_private(dentry, dentry_info); 353 ecryptfs_set_dentry_private(dentry, dentry_info);
354 dentry_info->lower_path.mnt = lower_mnt; 354 dentry_info->lower_path.mnt = lower_mnt;
355 dentry_info->lower_path.dentry = lower_dentry; 355 dentry_info->lower_path.dentry = lower_dentry;
356 356
357 if (!lower_dentry->d_inode) { 357 if (d_really_is_negative(lower_dentry)) {
358 /* We want to add because we couldn't find in lower */ 358 /* We want to add because we couldn't find in lower */
359 d_add(dentry, NULL); 359 d_add(dentry, NULL);
360 return 0; 360 return 0;
@@ -400,11 +400,11 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
400 int rc = 0; 400 int rc = 0;
401 401
402 lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent); 402 lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent);
403 mutex_lock(&lower_dir_dentry->d_inode->i_mutex); 403 mutex_lock(&d_inode(lower_dir_dentry)->i_mutex);
404 lower_dentry = lookup_one_len(ecryptfs_dentry->d_name.name, 404 lower_dentry = lookup_one_len(ecryptfs_dentry->d_name.name,
405 lower_dir_dentry, 405 lower_dir_dentry,
406 ecryptfs_dentry->d_name.len); 406 ecryptfs_dentry->d_name.len);
407 mutex_unlock(&lower_dir_dentry->d_inode->i_mutex); 407 mutex_unlock(&d_inode(lower_dir_dentry)->i_mutex);
408 if (IS_ERR(lower_dentry)) { 408 if (IS_ERR(lower_dentry)) {
409 rc = PTR_ERR(lower_dentry); 409 rc = PTR_ERR(lower_dentry);
410 ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " 410 ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
@@ -412,7 +412,7 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
412 ecryptfs_dentry); 412 ecryptfs_dentry);
413 goto out; 413 goto out;
414 } 414 }
415 if (lower_dentry->d_inode) 415 if (d_really_is_positive(lower_dentry))
416 goto interpose; 416 goto interpose;
417 mount_crypt_stat = &ecryptfs_superblock_to_private( 417 mount_crypt_stat = &ecryptfs_superblock_to_private(
418 ecryptfs_dentry->d_sb)->mount_crypt_stat; 418 ecryptfs_dentry->d_sb)->mount_crypt_stat;
@@ -429,11 +429,11 @@ static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
429 "filename; rc = [%d]\n", __func__, rc); 429 "filename; rc = [%d]\n", __func__, rc);
430 goto out; 430 goto out;
431 } 431 }
432 mutex_lock(&lower_dir_dentry->d_inode->i_mutex); 432 mutex_lock(&d_inode(lower_dir_dentry)->i_mutex);
433 lower_dentry = lookup_one_len(encrypted_and_encoded_name, 433 lower_dentry = lookup_one_len(encrypted_and_encoded_name,
434 lower_dir_dentry, 434 lower_dir_dentry,
435 encrypted_and_encoded_name_size); 435 encrypted_and_encoded_name_size);
436 mutex_unlock(&lower_dir_dentry->d_inode->i_mutex); 436 mutex_unlock(&d_inode(lower_dir_dentry)->i_mutex);
437 if (IS_ERR(lower_dentry)) { 437 if (IS_ERR(lower_dentry)) {
438 rc = PTR_ERR(lower_dentry); 438 rc = PTR_ERR(lower_dentry);
439 ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " 439 ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
@@ -458,24 +458,24 @@ static int ecryptfs_link(struct dentry *old_dentry, struct inode *dir,
458 u64 file_size_save; 458 u64 file_size_save;
459 int rc; 459 int rc;
460 460
461 file_size_save = i_size_read(old_dentry->d_inode); 461 file_size_save = i_size_read(d_inode(old_dentry));
462 lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry); 462 lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry);
463 lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry); 463 lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry);
464 dget(lower_old_dentry); 464 dget(lower_old_dentry);
465 dget(lower_new_dentry); 465 dget(lower_new_dentry);
466 lower_dir_dentry = lock_parent(lower_new_dentry); 466 lower_dir_dentry = lock_parent(lower_new_dentry);
467 rc = vfs_link(lower_old_dentry, lower_dir_dentry->d_inode, 467 rc = vfs_link(lower_old_dentry, d_inode(lower_dir_dentry),
468 lower_new_dentry, NULL); 468 lower_new_dentry, NULL);
469 if (rc || !lower_new_dentry->d_inode) 469 if (rc || d_really_is_negative(lower_new_dentry))
470 goto out_lock; 470 goto out_lock;
471 rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb); 471 rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb);
472 if (rc) 472 if (rc)
473 goto out_lock; 473 goto out_lock;
474 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode); 474 fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
475 fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode); 475 fsstack_copy_inode_size(dir, d_inode(lower_dir_dentry));
476 set_nlink(old_dentry->d_inode, 476 set_nlink(d_inode(old_dentry),
477 ecryptfs_inode_to_lower(old_dentry->d_inode)->i_nlink); 477 ecryptfs_inode_to_lower(d_inode(old_dentry))->i_nlink);
478 i_size_write(new_dentry->d_inode, file_size_save); 478 i_size_write(d_inode(new_dentry), file_size_save);
479out_lock: 479out_lock:
480 unlock_dir(lower_dir_dentry); 480 unlock_dir(lower_dir_dentry);
481 dput(lower_new_dentry); 481 dput(lower_new_dentry);
@@ -485,7 +485,7 @@ out_lock:
485 485
486static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry) 486static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
487{ 487{
488 return ecryptfs_do_unlink(dir, dentry, dentry->d_inode); 488 return ecryptfs_do_unlink(dir, dentry, d_inode(dentry));
489} 489}
490 490
491static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry, 491static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
@@ -510,20 +510,20 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
510 strlen(symname)); 510 strlen(symname));
511 if (rc) 511 if (rc)
512 goto out_lock; 512 goto out_lock;
513 rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry, 513 rc = vfs_symlink(d_inode(lower_dir_dentry), lower_dentry,
514 encoded_symname); 514 encoded_symname);
515 kfree(encoded_symname); 515 kfree(encoded_symname);
516 if (rc || !lower_dentry->d_inode) 516 if (rc || d_really_is_negative(lower_dentry))
517 goto out_lock; 517 goto out_lock;
518 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb); 518 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb);
519 if (rc) 519 if (rc)
520 goto out_lock; 520 goto out_lock;
521 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode); 521 fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
522 fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode); 522 fsstack_copy_inode_size(dir, d_inode(lower_dir_dentry));
523out_lock: 523out_lock:
524 unlock_dir(lower_dir_dentry); 524 unlock_dir(lower_dir_dentry);
525 dput(lower_dentry); 525 dput(lower_dentry);
526 if (!dentry->d_inode) 526 if (d_really_is_negative(dentry))
527 d_drop(dentry); 527 d_drop(dentry);
528 return rc; 528 return rc;
529} 529}
@@ -536,18 +536,18 @@ static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
536 536
537 lower_dentry = ecryptfs_dentry_to_lower(dentry); 537 lower_dentry = ecryptfs_dentry_to_lower(dentry);
538 lower_dir_dentry = lock_parent(lower_dentry); 538 lower_dir_dentry = lock_parent(lower_dentry);
539 rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode); 539 rc = vfs_mkdir(d_inode(lower_dir_dentry), lower_dentry, mode);
540 if (rc || !lower_dentry->d_inode) 540 if (rc || d_really_is_negative(lower_dentry))
541 goto out; 541 goto out;
542 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb); 542 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb);
543 if (rc) 543 if (rc)
544 goto out; 544 goto out;
545 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode); 545 fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
546 fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode); 546 fsstack_copy_inode_size(dir, d_inode(lower_dir_dentry));
547 set_nlink(dir, lower_dir_dentry->d_inode->i_nlink); 547 set_nlink(dir, d_inode(lower_dir_dentry)->i_nlink);
548out: 548out:
549 unlock_dir(lower_dir_dentry); 549 unlock_dir(lower_dir_dentry);
550 if (!dentry->d_inode) 550 if (d_really_is_negative(dentry))
551 d_drop(dentry); 551 d_drop(dentry);
552 return rc; 552 return rc;
553} 553}
@@ -562,12 +562,12 @@ static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
562 dget(dentry); 562 dget(dentry);
563 lower_dir_dentry = lock_parent(lower_dentry); 563 lower_dir_dentry = lock_parent(lower_dentry);
564 dget(lower_dentry); 564 dget(lower_dentry);
565 rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry); 565 rc = vfs_rmdir(d_inode(lower_dir_dentry), lower_dentry);
566 dput(lower_dentry); 566 dput(lower_dentry);
567 if (!rc && dentry->d_inode) 567 if (!rc && d_really_is_positive(dentry))
568 clear_nlink(dentry->d_inode); 568 clear_nlink(d_inode(dentry));
569 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode); 569 fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
570 set_nlink(dir, lower_dir_dentry->d_inode->i_nlink); 570 set_nlink(dir, d_inode(lower_dir_dentry)->i_nlink);
571 unlock_dir(lower_dir_dentry); 571 unlock_dir(lower_dir_dentry);
572 if (!rc) 572 if (!rc)
573 d_drop(dentry); 573 d_drop(dentry);
@@ -584,17 +584,17 @@ ecryptfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev
584 584
585 lower_dentry = ecryptfs_dentry_to_lower(dentry); 585 lower_dentry = ecryptfs_dentry_to_lower(dentry);
586 lower_dir_dentry = lock_parent(lower_dentry); 586 lower_dir_dentry = lock_parent(lower_dentry);
587 rc = vfs_mknod(lower_dir_dentry->d_inode, lower_dentry, mode, dev); 587 rc = vfs_mknod(d_inode(lower_dir_dentry), lower_dentry, mode, dev);
588 if (rc || !lower_dentry->d_inode) 588 if (rc || d_really_is_negative(lower_dentry))
589 goto out; 589 goto out;
590 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb); 590 rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb);
591 if (rc) 591 if (rc)
592 goto out; 592 goto out;
593 fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode); 593 fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
594 fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode); 594 fsstack_copy_inode_size(dir, d_inode(lower_dir_dentry));
595out: 595out:
596 unlock_dir(lower_dir_dentry); 596 unlock_dir(lower_dir_dentry);
597 if (!dentry->d_inode) 597 if (d_really_is_negative(dentry))
598 d_drop(dentry); 598 d_drop(dentry);
599 return rc; 599 return rc;
600} 600}
@@ -617,7 +617,7 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
617 dget(lower_new_dentry); 617 dget(lower_new_dentry);
618 lower_old_dir_dentry = dget_parent(lower_old_dentry); 618 lower_old_dir_dentry = dget_parent(lower_old_dentry);
619 lower_new_dir_dentry = dget_parent(lower_new_dentry); 619 lower_new_dir_dentry = dget_parent(lower_new_dentry);
620 target_inode = new_dentry->d_inode; 620 target_inode = d_inode(new_dentry);
621 trap = lock_rename(lower_old_dir_dentry, lower_new_dir_dentry); 621 trap = lock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
622 /* source should not be ancestor of target */ 622 /* source should not be ancestor of target */
623 if (trap == lower_old_dentry) { 623 if (trap == lower_old_dentry) {
@@ -629,17 +629,17 @@ ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
629 rc = -ENOTEMPTY; 629 rc = -ENOTEMPTY;
630 goto out_lock; 630 goto out_lock;
631 } 631 }
632 rc = vfs_rename(lower_old_dir_dentry->d_inode, lower_old_dentry, 632 rc = vfs_rename(d_inode(lower_old_dir_dentry), lower_old_dentry,
633 lower_new_dir_dentry->d_inode, lower_new_dentry, 633 d_inode(lower_new_dir_dentry), lower_new_dentry,
634 NULL, 0); 634 NULL, 0);
635 if (rc) 635 if (rc)
636 goto out_lock; 636 goto out_lock;
637 if (target_inode) 637 if (target_inode)
638 fsstack_copy_attr_all(target_inode, 638 fsstack_copy_attr_all(target_inode,
639 ecryptfs_inode_to_lower(target_inode)); 639 ecryptfs_inode_to_lower(target_inode));
640 fsstack_copy_attr_all(new_dir, lower_new_dir_dentry->d_inode); 640 fsstack_copy_attr_all(new_dir, d_inode(lower_new_dir_dentry));
641 if (new_dir != old_dir) 641 if (new_dir != old_dir)
642 fsstack_copy_attr_all(old_dir, lower_old_dir_dentry->d_inode); 642 fsstack_copy_attr_all(old_dir, d_inode(lower_old_dir_dentry));
643out_lock: 643out_lock:
644 unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry); 644 unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
645 dput(lower_new_dir_dentry); 645 dput(lower_new_dir_dentry);
@@ -662,7 +662,7 @@ static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz)
662 return ERR_PTR(-ENOMEM); 662 return ERR_PTR(-ENOMEM);
663 old_fs = get_fs(); 663 old_fs = get_fs();
664 set_fs(get_ds()); 664 set_fs(get_ds());
665 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry, 665 rc = d_inode(lower_dentry)->i_op->readlink(lower_dentry,
666 (char __user *)lower_buf, 666 (char __user *)lower_buf,
667 PATH_MAX); 667 PATH_MAX);
668 set_fs(old_fs); 668 set_fs(old_fs);
@@ -681,8 +681,8 @@ static void *ecryptfs_follow_link(struct dentry *dentry, struct nameidata *nd)
681 char *buf = ecryptfs_readlink_lower(dentry, &len); 681 char *buf = ecryptfs_readlink_lower(dentry, &len);
682 if (IS_ERR(buf)) 682 if (IS_ERR(buf))
683 goto out; 683 goto out;
684 fsstack_copy_attr_atime(dentry->d_inode, 684 fsstack_copy_attr_atime(d_inode(dentry),
685 ecryptfs_dentry_to_lower(dentry)->d_inode); 685 d_inode(ecryptfs_dentry_to_lower(dentry)));
686 buf[len] = '\0'; 686 buf[len] = '\0';
687out: 687out:
688 nd_set_link(nd, buf); 688 nd_set_link(nd, buf);
@@ -738,7 +738,7 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
738 struct iattr *lower_ia) 738 struct iattr *lower_ia)
739{ 739{
740 int rc = 0; 740 int rc = 0;
741 struct inode *inode = dentry->d_inode; 741 struct inode *inode = d_inode(dentry);
742 struct ecryptfs_crypt_stat *crypt_stat; 742 struct ecryptfs_crypt_stat *crypt_stat;
743 loff_t i_size = i_size_read(inode); 743 loff_t i_size = i_size_read(inode);
744 loff_t lower_size_before_truncate; 744 loff_t lower_size_before_truncate;
@@ -751,7 +751,7 @@ static int truncate_upper(struct dentry *dentry, struct iattr *ia,
751 rc = ecryptfs_get_lower_file(dentry, inode); 751 rc = ecryptfs_get_lower_file(dentry, inode);
752 if (rc) 752 if (rc)
753 return rc; 753 return rc;
754 crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat; 754 crypt_stat = &ecryptfs_inode_to_private(d_inode(dentry))->crypt_stat;
755 /* Switch on growing or shrinking file */ 755 /* Switch on growing or shrinking file */
756 if (ia->ia_size > i_size) { 756 if (ia->ia_size > i_size) {
757 char zero[] = { 0x00 }; 757 char zero[] = { 0x00 };
@@ -858,7 +858,7 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
858 struct iattr lower_ia = { .ia_valid = 0 }; 858 struct iattr lower_ia = { .ia_valid = 0 };
859 int rc; 859 int rc;
860 860
861 rc = ecryptfs_inode_newsize_ok(dentry->d_inode, new_length); 861 rc = ecryptfs_inode_newsize_ok(d_inode(dentry), new_length);
862 if (rc) 862 if (rc)
863 return rc; 863 return rc;
864 864
@@ -866,9 +866,9 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
866 if (!rc && lower_ia.ia_valid & ATTR_SIZE) { 866 if (!rc && lower_ia.ia_valid & ATTR_SIZE) {
867 struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); 867 struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
868 868
869 mutex_lock(&lower_dentry->d_inode->i_mutex); 869 mutex_lock(&d_inode(lower_dentry)->i_mutex);
870 rc = notify_change(lower_dentry, &lower_ia, NULL); 870 rc = notify_change(lower_dentry, &lower_ia, NULL);
871 mutex_unlock(&lower_dentry->d_inode->i_mutex); 871 mutex_unlock(&d_inode(lower_dentry)->i_mutex);
872 } 872 }
873 return rc; 873 return rc;
874} 874}
@@ -900,10 +900,10 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
900 struct inode *lower_inode; 900 struct inode *lower_inode;
901 struct ecryptfs_crypt_stat *crypt_stat; 901 struct ecryptfs_crypt_stat *crypt_stat;
902 902
903 crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat; 903 crypt_stat = &ecryptfs_inode_to_private(d_inode(dentry))->crypt_stat;
904 if (!(crypt_stat->flags & ECRYPTFS_STRUCT_INITIALIZED)) 904 if (!(crypt_stat->flags & ECRYPTFS_STRUCT_INITIALIZED))
905 ecryptfs_init_crypt_stat(crypt_stat); 905 ecryptfs_init_crypt_stat(crypt_stat);
906 inode = dentry->d_inode; 906 inode = d_inode(dentry);
907 lower_inode = ecryptfs_inode_to_lower(inode); 907 lower_inode = ecryptfs_inode_to_lower(inode);
908 lower_dentry = ecryptfs_dentry_to_lower(dentry); 908 lower_dentry = ecryptfs_dentry_to_lower(dentry);
909 mutex_lock(&crypt_stat->cs_mutex); 909 mutex_lock(&crypt_stat->cs_mutex);
@@ -967,9 +967,9 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
967 if (lower_ia.ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID)) 967 if (lower_ia.ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID))
968 lower_ia.ia_valid &= ~ATTR_MODE; 968 lower_ia.ia_valid &= ~ATTR_MODE;
969 969
970 mutex_lock(&lower_dentry->d_inode->i_mutex); 970 mutex_lock(&d_inode(lower_dentry)->i_mutex);
971 rc = notify_change(lower_dentry, &lower_ia, NULL); 971 rc = notify_change(lower_dentry, &lower_ia, NULL);
972 mutex_unlock(&lower_dentry->d_inode->i_mutex); 972 mutex_unlock(&d_inode(lower_dentry)->i_mutex);
973out: 973out:
974 fsstack_copy_attr_all(inode, lower_inode); 974 fsstack_copy_attr_all(inode, lower_inode);
975 return rc; 975 return rc;
@@ -983,7 +983,7 @@ static int ecryptfs_getattr_link(struct vfsmount *mnt, struct dentry *dentry,
983 983
984 mount_crypt_stat = &ecryptfs_superblock_to_private( 984 mount_crypt_stat = &ecryptfs_superblock_to_private(
985 dentry->d_sb)->mount_crypt_stat; 985 dentry->d_sb)->mount_crypt_stat;
986 generic_fillattr(dentry->d_inode, stat); 986 generic_fillattr(d_inode(dentry), stat);
987 if (mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES) { 987 if (mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES) {
988 char *target; 988 char *target;
989 size_t targetsiz; 989 size_t targetsiz;
@@ -1007,9 +1007,9 @@ static int ecryptfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
1007 1007
1008 rc = vfs_getattr(ecryptfs_dentry_to_lower_path(dentry), &lower_stat); 1008 rc = vfs_getattr(ecryptfs_dentry_to_lower_path(dentry), &lower_stat);
1009 if (!rc) { 1009 if (!rc) {
1010 fsstack_copy_attr_all(dentry->d_inode, 1010 fsstack_copy_attr_all(d_inode(dentry),
1011 ecryptfs_inode_to_lower(dentry->d_inode)); 1011 ecryptfs_inode_to_lower(d_inode(dentry)));
1012 generic_fillattr(dentry->d_inode, stat); 1012 generic_fillattr(d_inode(dentry), stat);
1013 stat->blocks = lower_stat.blocks; 1013 stat->blocks = lower_stat.blocks;
1014 } 1014 }
1015 return rc; 1015 return rc;
@@ -1023,14 +1023,14 @@ ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value,
1023 struct dentry *lower_dentry; 1023 struct dentry *lower_dentry;
1024 1024
1025 lower_dentry = ecryptfs_dentry_to_lower(dentry); 1025 lower_dentry = ecryptfs_dentry_to_lower(dentry);
1026 if (!lower_dentry->d_inode->i_op->setxattr) { 1026 if (!d_inode(lower_dentry)->i_op->setxattr) {
1027 rc = -EOPNOTSUPP; 1027 rc = -EOPNOTSUPP;
1028 goto out; 1028 goto out;
1029 } 1029 }
1030 1030
1031 rc = vfs_setxattr(lower_dentry, name, value, size, flags); 1031 rc = vfs_setxattr(lower_dentry, name, value, size, flags);
1032 if (!rc && dentry->d_inode) 1032 if (!rc && d_really_is_positive(dentry))
1033 fsstack_copy_attr_all(dentry->d_inode, lower_dentry->d_inode); 1033 fsstack_copy_attr_all(d_inode(dentry), d_inode(lower_dentry));
1034out: 1034out:
1035 return rc; 1035 return rc;
1036} 1036}
@@ -1041,14 +1041,14 @@ ecryptfs_getxattr_lower(struct dentry *lower_dentry, const char *name,
1041{ 1041{
1042 int rc = 0; 1042 int rc = 0;
1043 1043
1044 if (!lower_dentry->d_inode->i_op->getxattr) { 1044 if (!d_inode(lower_dentry)->i_op->getxattr) {
1045 rc = -EOPNOTSUPP; 1045 rc = -EOPNOTSUPP;
1046 goto out; 1046 goto out;
1047 } 1047 }
1048 mutex_lock(&lower_dentry->d_inode->i_mutex); 1048 mutex_lock(&d_inode(lower_dentry)->i_mutex);
1049 rc = lower_dentry->d_inode->i_op->getxattr(lower_dentry, name, value, 1049 rc = d_inode(lower_dentry)->i_op->getxattr(lower_dentry, name, value,
1050 size); 1050 size);
1051 mutex_unlock(&lower_dentry->d_inode->i_mutex); 1051 mutex_unlock(&d_inode(lower_dentry)->i_mutex);
1052out: 1052out:
1053 return rc; 1053 return rc;
1054} 1054}
@@ -1068,13 +1068,13 @@ ecryptfs_listxattr(struct dentry *dentry, char *list, size_t size)
1068 struct dentry *lower_dentry; 1068 struct dentry *lower_dentry;
1069 1069
1070 lower_dentry = ecryptfs_dentry_to_lower(dentry); 1070 lower_dentry = ecryptfs_dentry_to_lower(dentry);
1071 if (!lower_dentry->d_inode->i_op->listxattr) { 1071 if (!d_inode(lower_dentry)->i_op->listxattr) {
1072 rc = -EOPNOTSUPP; 1072 rc = -EOPNOTSUPP;
1073 goto out; 1073 goto out;
1074 } 1074 }
1075 mutex_lock(&lower_dentry->d_inode->i_mutex); 1075 mutex_lock(&d_inode(lower_dentry)->i_mutex);
1076 rc = lower_dentry->d_inode->i_op->listxattr(lower_dentry, list, size); 1076 rc = d_inode(lower_dentry)->i_op->listxattr(lower_dentry, list, size);
1077 mutex_unlock(&lower_dentry->d_inode->i_mutex); 1077 mutex_unlock(&d_inode(lower_dentry)->i_mutex);
1078out: 1078out:
1079 return rc; 1079 return rc;
1080} 1080}
@@ -1085,13 +1085,13 @@ static int ecryptfs_removexattr(struct dentry *dentry, const char *name)
1085 struct dentry *lower_dentry; 1085 struct dentry *lower_dentry;
1086 1086
1087 lower_dentry = ecryptfs_dentry_to_lower(dentry); 1087 lower_dentry = ecryptfs_dentry_to_lower(dentry);
1088 if (!lower_dentry->d_inode->i_op->removexattr) { 1088 if (!d_inode(lower_dentry)->i_op->removexattr) {
1089 rc = -EOPNOTSUPP; 1089 rc = -EOPNOTSUPP;
1090 goto out; 1090 goto out;
1091 } 1091 }
1092 mutex_lock(&lower_dentry->d_inode->i_mutex); 1092 mutex_lock(&d_inode(lower_dentry)->i_mutex);
1093 rc = lower_dentry->d_inode->i_op->removexattr(lower_dentry, name); 1093 rc = d_inode(lower_dentry)->i_op->removexattr(lower_dentry, name);
1094 mutex_unlock(&lower_dentry->d_inode->i_mutex); 1094 mutex_unlock(&d_inode(lower_dentry)->i_mutex);
1095out: 1095out:
1096 return rc; 1096 return rc;
1097} 1097}