linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Testing if two open descriptors refer to the same inode
@ 2024-07-29  6:55 Florian Weimer
  2024-07-29  9:09 ` Aleksa Sarai
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Florian Weimer @ 2024-07-29  6:55 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel, linux-api; +Cc: Dave Chinner

It was pointed out to me that inode numbers on Linux are no longer
expected to be unique per file system, even for local file systems.
Applications sometimes need to check if two (open) files are the same.
For example, a program may want to use a temporary file if is invoked
with input and output files referring to the same file.

How can we check for this?  The POSIX way is to compare st_ino and
st_dev in stat output, but if inode numbers are not unique, that will
result in files falsely being reported as identical.  It's harmless in
the temporary file case, but it in other scenarios, it may result in
data loss.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2024-07-31 18:07 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-29  6:55 Testing if two open descriptors refer to the same inode Florian Weimer
2024-07-29  9:09 ` Aleksa Sarai
2024-07-29  9:29   ` Florian Weimer
2024-07-29 10:18 ` Mateusz Guzik
2024-07-29 10:40   ` Florian Weimer
2024-07-29 10:50     ` Mateusz Guzik
2024-07-29 10:56       ` Mateusz Guzik
2024-07-29 10:57       ` Florian Weimer
2024-07-29 11:06         ` Mateusz Guzik
2024-07-29 11:36           ` Florian Weimer
2024-07-29 12:00             ` Mateusz Guzik
2024-07-29 11:40           ` Aleksa Sarai
2024-07-31 18:07             ` David Sterba
2024-07-29 11:47           ` Aleksa Sarai
2024-07-29 12:12             ` Mateusz Guzik
2024-07-29 23:19               ` Dave Chinner
2024-07-29 23:08         ` Dave Chinner
2024-07-29 12:26   ` Christian Brauner
2024-07-29 13:36   ` Theodore Ts'o
2024-07-30  2:31     ` Dave Chinner
2024-07-30  4:19       ` Theodore Ts'o
2024-07-30 15:38       ` Christoph Hellwig
2024-07-29 15:24 ` Jeff Layton
2024-07-29 15:39   ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).