diff options
Diffstat (limited to 'fs/ecryptfs/file.c')
| -rw-r--r-- | fs/ecryptfs/file.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 24749bf0668f..9244d653743e 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
| @@ -192,6 +192,23 @@ static int ecryptfs_open(struct inode *inode, struct file *file) | |||
| 192 | | ECRYPTFS_ENCRYPTED); | 192 | | ECRYPTFS_ENCRYPTED); |
| 193 | } | 193 | } |
| 194 | mutex_unlock(&crypt_stat->cs_mutex); | 194 | mutex_unlock(&crypt_stat->cs_mutex); |
| 195 | if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_RDONLY) | ||
| 196 | && !(file->f_flags & O_RDONLY)) { | ||
| 197 | rc = -EPERM; | ||
| 198 | printk(KERN_WARNING "%s: Lower persistent file is RO; eCryptfs " | ||
| 199 | "file must hence be opened RO\n", __func__); | ||
| 200 | goto out; | ||
| 201 | } | ||
| 202 | if (!ecryptfs_inode_to_private(inode)->lower_file) { | ||
| 203 | rc = ecryptfs_init_persistent_file(ecryptfs_dentry); | ||
| 204 | if (rc) { | ||
| 205 | printk(KERN_ERR "%s: Error attempting to initialize " | ||
| 206 | "the persistent file for the dentry with name " | ||
| 207 | "[%s]; rc = [%d]\n", __func__, | ||
| 208 | ecryptfs_dentry->d_name.name, rc); | ||
| 209 | goto out; | ||
| 210 | } | ||
| 211 | } | ||
| 195 | ecryptfs_set_file_lower( | 212 | ecryptfs_set_file_lower( |
| 196 | file, ecryptfs_inode_to_private(inode)->lower_file); | 213 | file, ecryptfs_inode_to_private(inode)->lower_file); |
| 197 | if (S_ISDIR(ecryptfs_dentry->d_inode->i_mode)) { | 214 | if (S_ISDIR(ecryptfs_dentry->d_inode->i_mode)) { |
