* drivers, where the ioctl might have different effects. Notably, DRM is using the same
* ioctl() number. */
- if (!S_ISDIR(st.st_mode) && !S_ISREG(st.st_mode))
+ if (!inode_type_can_chattr(st.st_mode))
return -ENOTTY;
if (mask == 0 && !ret_previous && !ret_final)
if (fstat(fd, &st) < 0)
return -errno;
- if (!S_ISDIR(st.st_mode) && !S_ISREG(st.st_mode))
+ if (!inode_type_can_chattr(st.st_mode))
return -ENOTTY;
_cleanup_close_ int fd_close = -EBADF;
set_proj_id_cb,
UINT32_TO_PTR(proj_id));
}
+
+bool inode_type_can_chattr(mode_t mode) {
+ return IN_SET(mode & S_IFMT, S_IFREG, S_IFDIR);
+}
static inline int chattr_secret(int fd, ChattrApplyFlags flags) {
return chattr_full(fd, NULL, CHATTR_SECRET_FLAGS, CHATTR_SECRET_FLAGS, NULL, NULL, flags|CHATTR_FALLBACK_BITWISE);
}
+
+bool inode_type_can_chattr(mode_t mode);