summaryrefslogtreecommitdiff
path: root/src/basic/fd-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-02-14 17:21:41 +0100
committerLennart Poettering <lennart@poettering.net>2022-02-14 17:27:14 +0100
commita9dac7a6dd31225dbe9633061dcade12c0c90a32 (patch)
tree9fdf4d4480ecc18aa7306f8eddce2d9f5a8649d3 /src/basic/fd-util.c
parent38db6211b5aa6e2fb65883ae3353914e82f5bef1 (diff)
downloadsystemd-a9dac7a6dd31225dbe9633061dcade12c0c90a32.tar.gz
tree-wide: port various places over to new stat_inode_same() helper
Diffstat (limited to 'src/basic/fd-util.c')
-rw-r--r--src/basic/fd-util.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c
index 3866e87675..a0836aabd1 100644
--- a/src/basic/fd-util.c
+++ b/src/basic/fd-util.c
@@ -446,7 +446,7 @@ int same_fd(int a, int b) {
if (fstat(b, &stb) < 0)
return -errno;
- if ((sta.st_mode & S_IFMT) != (stb.st_mode & S_IFMT))
+ if (!stat_inode_same(&sta, &stb))
return false;
/* We consider all device fds different, since two device fds
@@ -456,13 +456,8 @@ int same_fd(int a, int b) {
if (S_ISCHR(sta.st_mode) || S_ISBLK(sta.st_mode))
return false;
- if (sta.st_dev != stb.st_dev || sta.st_ino != stb.st_ino)
- return false;
-
- /* The fds refer to the same inode on disk, let's also check
- * if they have the same fd flags. This is useful to
- * distinguish the read and write side of a pipe created with
- * pipe(). */
+ /* The fds refer to the same inode on disk, let's also check if they have the same fd flags. This is
+ * useful to distinguish the read and write side of a pipe created with pipe(). */
fa = fcntl(a, F_GETFL);
if (fa < 0)
return -errno;