tree-wide: port various places over to new stat_inode_same() helper

This commit is contained in:
Lennart Poettering
2022-02-14 17:27:14 +01:00
parent 38db6211b5
commit a9dac7a6dd
10 changed files with 20 additions and 37 deletions
+3 -8
View File
@@ -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;