diff options
| -rw-r--r-- | fs/overlayfs/overlayfs.h | 9 | ||||
| -rw-r--r-- | fs/overlayfs/ovl_entry.h | 1 | ||||
| -rw-r--r-- | fs/overlayfs/super.c | 10 |
3 files changed, 20 insertions, 0 deletions
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 8af450b0e57a..3822a909ce1f 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h | |||
| @@ -127,6 +127,15 @@ static inline int ovl_do_whiteout(struct inode *dir, struct dentry *dentry) | |||
| 127 | return err; | 127 | return err; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | static inline struct dentry *ovl_do_tmpfile(struct dentry *dentry, umode_t mode) | ||
| 131 | { | ||
| 132 | struct dentry *ret = vfs_tmpfile(dentry, mode, 0); | ||
| 133 | int err = IS_ERR(ret) ? PTR_ERR(ret) : 0; | ||
| 134 | |||
| 135 | pr_debug("tmpfile(%pd2, 0%o) = %i\n", dentry, mode, err); | ||
| 136 | return ret; | ||
| 137 | } | ||
| 138 | |||
| 130 | static inline struct inode *ovl_inode_real(struct inode *inode, bool *is_upper) | 139 | static inline struct inode *ovl_inode_real(struct inode *inode, bool *is_upper) |
| 131 | { | 140 | { |
| 132 | unsigned long x = (unsigned long) READ_ONCE(inode->i_private); | 141 | unsigned long x = (unsigned long) READ_ONCE(inode->i_private); |
diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h index d14bca1850d9..65f240001aa6 100644 --- a/fs/overlayfs/ovl_entry.h +++ b/fs/overlayfs/ovl_entry.h | |||
| @@ -27,6 +27,7 @@ struct ovl_fs { | |||
| 27 | struct ovl_config config; | 27 | struct ovl_config config; |
| 28 | /* creds of process who forced instantiation of super block */ | 28 | /* creds of process who forced instantiation of super block */ |
| 29 | const struct cred *creator_cred; | 29 | const struct cred *creator_cred; |
| 30 | bool tmpfile; | ||
| 30 | }; | 31 | }; |
| 31 | 32 | ||
| 32 | /* private information held for every overlayfs dentry */ | 33 | /* private information held for every overlayfs dentry */ |
diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 20f48abbb82f..ff05065b510f 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c | |||
| @@ -825,6 +825,8 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) | |||
| 825 | * creation of workdir in previous step. | 825 | * creation of workdir in previous step. |
| 826 | */ | 826 | */ |
| 827 | if (ufs->workdir) { | 827 | if (ufs->workdir) { |
| 828 | struct dentry *temp; | ||
| 829 | |||
| 828 | err = ovl_check_d_type_supported(&workpath); | 830 | err = ovl_check_d_type_supported(&workpath); |
| 829 | if (err < 0) | 831 | if (err < 0) |
| 830 | goto out_put_workdir; | 832 | goto out_put_workdir; |
| @@ -836,6 +838,14 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) | |||
| 836 | */ | 838 | */ |
| 837 | if (!err) | 839 | if (!err) |
| 838 | pr_warn("overlayfs: upper fs needs to support d_type.\n"); | 840 | pr_warn("overlayfs: upper fs needs to support d_type.\n"); |
| 841 | |||
| 842 | /* Check if upper/work fs supports O_TMPFILE */ | ||
| 843 | temp = ovl_do_tmpfile(ufs->workdir, S_IFREG | 0); | ||
| 844 | ufs->tmpfile = !IS_ERR(temp); | ||
| 845 | if (ufs->tmpfile) | ||
| 846 | dput(temp); | ||
| 847 | else | ||
| 848 | pr_warn("overlayfs: upper fs does not support tmpfile.\n"); | ||
| 839 | } | 849 | } |
| 840 | } | 850 | } |
| 841 | 851 | ||
