]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
ceph: add a new ceph.fscrypt.auth vxattr
authorJeff Layton <jlayton@kernel.org>
Wed, 19 May 2021 11:59:27 +0000 (07:59 -0400)
committerJeff Layton <jlayton@kernel.org>
Tue, 7 Dec 2021 15:32:47 +0000 (10:32 -0500)
Give the client a way to get at the xattr from userland, mostly for
future debugging purposes.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
fs/ceph/xattr.c

index 5e3522457deb54bbb3d9b1846f52c7f57bb901fc..b872673a16a944749012d7d87daf9dc8d6083c7e 100644 (file)
@@ -352,6 +352,23 @@ static ssize_t ceph_vxattrcb_auth_mds(struct ceph_inode_info *ci,
        return ret;
 }
 
+#if IS_ENABLED(CONFIG_FS_ENCRYPTION)
+static bool ceph_vxattrcb_fscrypt_auth_exists(struct ceph_inode_info *ci)
+{
+       return ci->fscrypt_auth_len;
+}
+
+static ssize_t ceph_vxattrcb_fscrypt_auth(struct ceph_inode_info *ci, char *val, size_t size)
+{
+       if (size) {
+               if (size < ci->fscrypt_auth_len)
+                       return -ERANGE;
+               memcpy(val, ci->fscrypt_auth, ci->fscrypt_auth_len);
+       }
+       return ci->fscrypt_auth_len;
+}
+#endif /* CONFIG_FS_ENCRYPTION */
+
 #define CEPH_XATTR_NAME(_type, _name)  XATTR_CEPH_PREFIX #_type "." #_name
 #define CEPH_XATTR_NAME2(_type, _name, _name2) \
        XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
@@ -492,6 +509,15 @@ static struct ceph_vxattr ceph_common_vxattrs[] = {
                .exists_cb = NULL,
                .flags = VXATTR_FLAG_READONLY,
        },
+#if IS_ENABLED(CONFIG_FS_ENCRYPTION)
+       {
+               .name = "ceph.fscrypt.auth",
+               .name_size = sizeof("ceph.fscrypt.auth"),
+               .getxattr_cb = ceph_vxattrcb_fscrypt_auth,
+               .exists_cb = ceph_vxattrcb_fscrypt_auth_exists,
+               .flags = VXATTR_FLAG_READONLY,
+       },
+#endif /* CONFIG_FS_ENCRYPTION */
        { .name = NULL, 0 }     /* Required table terminator */
 };