continue;
if (ioctl(fd, FS_IOC_SETFLAGS, &new_one) < 0) {
- if (errno != EINVAL && !ERRNO_IS_NOT_SUPPORTED(errno))
+ if (!ERRNO_IS_IOCTL_NOT_SUPPORTED(errno))
return -errno;
log_full_errno(FLAGS_SET(flags, CHATTR_WARN_UNSUPPORTED_FLAGS) ? LOG_WARNING : LOG_DEBUG,
}
_DEFINE_ABS_WRAPPER(RESOURCE);
-/* Seven different errors for "operation/system call/ioctl/socket feature not supported" */
+/* Seven different errors for "operation/system call/socket feature not supported" */
static inline bool ERRNO_IS_NEG_NOT_SUPPORTED(intmax_t r) {
return IN_SET(r,
-EOPNOTSUPP,
}
_DEFINE_ABS_WRAPPER(NOT_SUPPORTED);
+/* ioctl() with unsupported command/arg might additionally return EINVAL */
+static inline bool ERRNO_IS_NEG_IOCTL_NOT_SUPPORTED(intmax_t r) {
+ return ERRNO_IS_NEG_NOT_SUPPORTED(r) || r == -EINVAL;
+}
+_DEFINE_ABS_WRAPPER(IOCTL_NOT_SUPPORTED);
+
/* Two different errors for access problems */
static inline bool ERRNO_IS_NEG_PRIVILEGE(intmax_t r) {
return IN_SET(r,
if (peer_fd >= 0)
return peer_fd;
- if (ERRNO_IS_NOT_SUPPORTED(errno) || errno == EINVAL) /* new ioctl() is not supported, return a clear error */
+ if (ERRNO_IS_IOCTL_NOT_SUPPORTED(errno)) /* new ioctl() is not supported, return a clear error */
return -EOPNOTSUPP;
if (errno != EIO)
int pidfd = sd_varlink_get_peer_pidfd(v);
if (pidfd < 0) {
- if (!ERRNO_IS_NEG_NOT_SUPPORTED(pidfd) && pidfd != -EINVAL)
+ if (!ERRNO_IS_NEG_IOCTL_NOT_SUPPORTED(pidfd))
return pidfd;
pid_t pid;
r = btrfs_subvol_set_read_only_fd(fd, true);
if (r >= 0)
return 0;
-
- if (!ERRNO_IS_NOT_SUPPORTED(r) && r != -EINVAL)
+ if (!ERRNO_IS_NEG_IOCTL_NOT_SUPPORTED(r))
return r;
}
if (!loop_configure_broken) {
if (ioctl(fd, LOOP_CONFIGURE, c) < 0) {
- /* Do fallback only if LOOP_CONFIGURE is not supported, propagate all other
- * errors. Note that the kernel is weird: non-existing ioctls currently return EINVAL
- * rather than ENOTTY on loopback block devices. They should fix that in the kernel,
- * but in the meantime we accept both here. */
- if (!ERRNO_IS_NOT_SUPPORTED(errno) && errno != EINVAL)
+ /* Do fallback only if LOOP_CONFIGURE is not supported, propagate all other errors. */
+ if (!ERRNO_IS_IOCTL_NOT_SUPPORTED(errno))
return log_device_debug_errno(dev, errno, "ioctl(LOOP_CONFIGURE) failed: %m");
loop_configure_broken = true;