From: Igor Golikov Date: Wed, 25 Dec 2024 12:40:34 +0000 (+0000) Subject: return EINVAL instead of ENOTTY to fix ceph support X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=eaae97d27ebaca199bcdb8af916f1ef14fbc06bc;p=fscrypt.git return EINVAL instead of ENOTTY to fix ceph support Signed-off-by: Igor Golikov --- diff --git a/metadata/policy.go b/metadata/policy.go index 148df4c..6b6536b 100644 --- a/metadata/policy.go +++ b/metadata/policy.go @@ -128,6 +128,13 @@ func setPolicy(file *os.File, arg unsafe.Pointer) error { log.Printf("FS_IOC_SET_ENCRYPTION_KEY_RESTRICTED"); _, _, errno = unix.Syscall(unix.SYS_IOCTL, file.Fd(), uintptr(C.fs_ioc_set_encryption_policy_restricted), uintptr(arg)) } + // there is some code (e.g. CheckSupport) that calls this function with assumption that it will fail + // and return EINVAL. + // as a temp solution, we will return EINVAL if the restricted policy fails (and returns ENOTTY) + if errno == unix.ENOTTY { + log.Printf("returning EINVAL instead of ENOTTY") + return unix.EINVAL + } if errno != 0 { return errno }