diff mbox series

[RFC,v10,41/48] ceph: set encryption context on open

Message ID 20220111191608.88762-42-jlayton@kernel.org
State New
Headers show
Series ceph+fscrypt: full support | expand

Commit Message

Jeff Layton Jan. 11, 2022, 7:16 p.m. UTC
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/file.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index b74c9bf2cef1..17e26c030f5f 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -369,6 +369,12 @@  int ceph_open(struct inode *inode, struct file *file)
 	fmode = ceph_flags_to_mode(flags);
 	wanted = ceph_caps_for_mode(fmode);
 
+	if (S_ISREG(inode->i_mode)) {
+		err = fscrypt_file_open(inode, file);
+		if (err)
+			return err;
+	}
+
 	/* snapped files are read-only */
 	if (ceph_snap(inode) != CEPH_NOSNAP && (file->f_mode & FMODE_WRITE))
 		return -EROFS;