summaryrefslogtreecommitdiff
path: root/fs/ubifs/ioctl.c
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2016-10-20 16:47:56 +0200
committerRichard Weinberger <richard@nod.at>2016-12-12 23:07:38 +0100
commitd475a507457b5cafa428871a473d0dcc828c5f68 (patch)
tree7f6608195cfc421e6d3d7975cc8b916a55e4a914 /fs/ubifs/ioctl.c
parent6a5e98ab7d8665d2faddbd91a8a2bf9addb79aff (diff)
ubifs: Add skeleton for fscrypto
This is the first building block to provide file level encryption on UBIFS. Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'fs/ubifs/ioctl.c')
-rw-r--r--fs/ubifs/ioctl.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
index 3c7b29de0ca7..6bb5b35050de 100644
--- a/fs/ubifs/ioctl.c
+++ b/fs/ubifs/ioctl.c
@@ -181,6 +181,41 @@ long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
mnt_drop_write_file(file);
return err;
}
+ case FS_IOC_SET_ENCRYPTION_POLICY: {
+#ifdef CONFIG_UBIFS_FS_ENCRYPTION
+ struct fscrypt_policy policy;
+
+ if (copy_from_user(&policy,
+ (struct fscrypt_policy __user *)arg,
+ sizeof(policy)))
+ return -EFAULT;
+
+ err = fscrypt_process_policy(file, &policy);
+
+ return err;
+#else
+ return -EOPNOTSUPP;
+#endif
+ }
+ case FS_IOC_GET_ENCRYPTION_POLICY: {
+#ifdef CONFIG_UBIFS_FS_ENCRYPTION
+ struct fscrypt_policy policy;
+
+ if (!ubifs_crypt_is_encrypted(inode))
+ return -ENOENT;
+
+ err = fscrypt_get_policy(inode, &policy);
+ if (err)
+ return err;
+
+ if (copy_to_user((void __user *)arg, &policy, sizeof(policy)))
+ return -EFAULT;
+
+ return 0;
+#else
+ return -EOPNOTSUPP;
+#endif
+ }
default:
return -ENOTTY;