From: Lennart Poettering Date: Thu, 21 Aug 2025 12:27:05 +0000 (+0200) Subject: stat-util: add helper inode_type_can_hardlink() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=90fae0b46cd28bc43aa04874c16f12b230f8cd79;p=thirdparty%2Fsystemd.git stat-util: add helper inode_type_can_hardlink() --- diff --git a/src/basic/stat-util.h b/src/basic/stat-util.h index 347d885a19f..17e712200a2 100644 --- a/src/basic/stat-util.h +++ b/src/basic/stat-util.h @@ -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); +}