aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/namei.c')
-rw-r--r--fs/namei.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/namei.c b/fs/namei.c
index 0dc4cbf21f37..22eb5484774c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2656,6 +2656,7 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
2656 int acc_mode; 2656 int acc_mode;
2657 int create_error = 0; 2657 int create_error = 0;
2658 struct dentry *const DENTRY_NOT_SET = (void *) -1UL; 2658 struct dentry *const DENTRY_NOT_SET = (void *) -1UL;
2659 bool excl;
2659 2660
2660 BUG_ON(dentry->d_inode); 2661 BUG_ON(dentry->d_inode);
2661 2662
@@ -2669,10 +2670,9 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
2669 if ((open_flag & O_CREAT) && !IS_POSIXACL(dir)) 2670 if ((open_flag & O_CREAT) && !IS_POSIXACL(dir))
2670 mode &= ~current_umask(); 2671 mode &= ~current_umask();
2671 2672
2672 if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) { 2673 excl = (open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT);
2674 if (excl)
2673 open_flag &= ~O_TRUNC; 2675 open_flag &= ~O_TRUNC;
2674 *opened |= FILE_CREATED;
2675 }
2676 2676
2677 /* 2677 /*
2678 * Checking write permission is tricky, bacuse we don't know if we are 2678 * Checking write permission is tricky, bacuse we don't know if we are
@@ -2726,7 +2726,11 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
2726 } 2726 }
2727 2727
2728 acc_mode = op->acc_mode; 2728 acc_mode = op->acc_mode;
2729 if (WARN_ON(excl && !(*opened & FILE_CREATED)))
2730 *opened |= FILE_CREATED;
2731
2729 if (*opened & FILE_CREATED) { 2732 if (*opened & FILE_CREATED) {
2733 WARN_ON(!(open_flag & O_CREAT));
2730 fsnotify_create(dir, dentry); 2734 fsnotify_create(dir, dentry);
2731 acc_mode = MAY_OPEN; 2735 acc_mode = MAY_OPEN;
2732 } 2736 }
@@ -2740,6 +2744,7 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
2740 dput(dentry); 2744 dput(dentry);
2741 dentry = file->f_path.dentry; 2745 dentry = file->f_path.dentry;
2742 } 2746 }
2747 WARN_ON(!dentry->d_inode && (*opened & FILE_CREATED));
2743 if (create_error && dentry->d_inode == NULL) { 2748 if (create_error && dentry->d_inode == NULL) {
2744 error = create_error; 2749 error = create_error;
2745 goto out; 2750 goto out;