Given a fd, will return if is encrypted or not.
Optionally, an enctag will be returned if set.
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
return 0;
}
+int Client::is_encrypted(int fd, UserPerm& perms, char* enctag)
+{
+ Fh *f = get_filehandle(fd);
+ if (!f) {
+ return -EBADF;
+ }
+
+ Inode *in = f->inode.get();
+ if (in->is_encrypted()) {
+ int r = ll_getxattr(in, "user.ceph.subvolume.enctag", enctag, sizeof(enctag), perms);
+ // dir can be encrypted and xattr DNE if it isn't setup via mgr subvolume
+ // this is an expected scenario
+ if (r < 0) {
+ enctag = nullptr;
+ }
+
+ return 0;
+ }
+ enctag = nullptr;
+ return -EINVAL;
+}
+
int Client::get_fscrypt_key_status(fscrypt_get_key_status_arg* arg) {
ceph_fscrypt_key_identifier kid;
int r = kid.init(arg->key_spec);
int get_inode_flags(int fd, int* file_attr_out);
int set_fscrypt_policy_v2(int fd, const struct fscrypt_policy_v2& policy);
+ int is_encrypted(int fd, UserPerm& perms, char* enctag);
int mds_command(
const std::string &mds_spec,
int ceph_set_fscrypt_policy_v2(struct ceph_mount_info *cmount,
int fd, const struct fscrypt_policy_v2 *policy);
+/**
+ * Checks to see if encryption is set on a directory.
+ *
+ * @param cmount the ceph mount handle to use.
+ * @param fd open directory file descriptor
+ * @param enctag, if set on dir, will return non-nullptr
+ * @returns zero on success, other returns a negative error code.
+ */
+int ceph_is_encrypted(struct ceph_mount_info *cmount,
+ int fd, char* enctag);
/**
* Fill file_attr_out with content of i_flags
* @param cmount the ceph mount handle to use.
return cmount->get_client()->set_fscrypt_policy_v2(fd, *policy);
}
+extern "C" int ceph_is_encrypted(struct ceph_mount_info *cmount,
+ int fd, char* enctag)
+{
+ if (!cmount->is_mounted())
+ return -ENOTCONN;
+
+ return cmount->get_client()->is_encrypted(fd, cmount->default_perms, enctag);
+}
+
// This is deprecated, use ceph_ll_register_callbacks2 instead.
extern "C" void ceph_ll_register_callbacks(class ceph_mount_info *cmount,