diff mbox series

[RFC,ONLY,09/23] fscrypt: expose a method to check whether a fscrypt_name is encrypted.

Message ID 22804364662428bb541c6829da8dfa2a7d19d5b0.1657707687.git.sweettea-kernel@dorminy.me (mailing list archive)
State New, archived
Headers show
Series btrfs: add fscrypt integration | expand

Commit Message

Sweet Tea Dorminy July 13, 2022, 10:29 a.m. UTC
Btrfs, having both encrypted and unencrypted names in the same
directory, will need to check whether a fscrypt_name to insert or search
for is encrypted, since the directory's encryption status is
insufficient for this.

Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
---
 include/linux/fscrypt.h | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h
index 6020b738c3b2..70d8a710ad39 100644
--- a/include/linux/fscrypt.h
+++ b/include/linux/fscrypt.h
@@ -55,6 +55,12 @@  struct fscrypt_name {
 #define fname_name(p)		((p)->disk_name.name)
 #define fname_len(p)		((p)->disk_name.len)
 
+static inline bool fname_encrypted(const struct fscrypt_name *fname)
+{
+	/* This buffer is only allocated if the user name is different */
+	return fname->crypto_buf.name != NULL;
+}
+
 /*
  * struct fscrypt_nokey_name - identifier for directory entry when key is absent
  *