stat-util: add helper inode_type_can_hardlink()

This commit is contained in:
Lennart Poettering
2025-10-14 11:21:46 +02:00
parent b2fa6d0945
commit 90fae0b46c
+7
View File
@@ -110,3 +110,10 @@ static inline bool stat_is_set(const struct stat *st) {
static inline bool statx_is_set(const struct statx *sx) {
return sx && sx->stx_mask != 0;
}
static inline bool inode_type_can_hardlink(mode_t m) {
/* returns true for all inode types that support hardlinks on linux. Note this is effectively all
* inode types except for directories (and those weird misc fds such as eventfds() that have no inode
* type). */
return IN_SET(m & S_IFMT, S_IFSOCK, S_IFLNK, S_IFREG, S_IFBLK, S_IFCHR, S_IFIFO);
}