tree-wide: port various places over to new stat_inode_same() helper
This commit is contained in:
+3
-8
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user