From 6f5ebc54927419cb5f954a6595e4f6eecab6b36c Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 8 Jul 2022 16:14:40 +0100 Subject: [PATCH] Handle ENOTTY with the correct error code for ioctl calls Fixes half of https://github.com/fwupd/fwupd/discussions/4810 --- libfwupdplugin/fu-udev-device.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libfwupdplugin/fu-udev-device.c b/libfwupdplugin/fu-udev-device.c index 989fa7708..c8daf65e3 100644 --- a/libfwupdplugin/fu-udev-device.c +++ b/libfwupdplugin/fu-udev-device.c @@ -1534,11 +1534,19 @@ fu_udev_device_ioctl(FuUdevDevice *self, "permission denied"); return FALSE; } + if (errno == ENOTTY) { + g_set_error_literal(error, + FWUPD_ERROR, + FWUPD_ERROR_NOT_SUPPORTED, + "permission denied"); + return FALSE; + } g_set_error(error, FWUPD_ERROR, FWUPD_ERROR_INTERNAL, - "ioctl error: %s", - strerror(errno)); + "ioctl error: %s [%i]", + strerror(errno), + errno); #else g_set_error(error, FWUPD_ERROR, FWUPD_ERROR_INTERNAL, "unspecified ioctl error"); #endif