public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* Improving inode number documentation
@ 2025-05-25 10:33 Pali Rohár
  2025-05-25 23:30 ` Alejandro Colomar
  0 siblings, 1 reply; 24+ messages in thread
From: Pali Rohár @ 2025-05-25 10:33 UTC (permalink / raw)
  To: Alejandro Colomar, linux-man

Hello Alex,

I would like to ask you, could you improve documentation about inode
numbers returned by readdir()/getdents() and stat()/statx() functions?

https://man7.org/linux/man-pages/man3/readdir.3.html
https://man7.org/linux/man-pages/man2/readdir.2.html
https://man7.org/linux/man-pages/man2/getdents.2.html
https://man7.org/linux/man-pages/man2/stat.2.html
https://man7.org/linux/man-pages/man2/statx.2.html
https://man7.org/linux/man-pages/man3/stat.3type.html
https://man7.org/linux/man-pages/man7/inode.7.html

The missing information in those documentations is the fact that the
dirent.d_ino does not have to be same as stat.st_ino/statx.stx_ino for
the same file or dir.

stat.st_ino number belongs to the stat.st_dev but dirent.d_ino belongs
to the st_dev of the directory on which was called opendir().

So for the mount points these two numbers are different. readdir()
returns the inode number of the underlying directory (which belongs to
the parent filesystem), but the stat() returns the inode number of the
root directory of the upper/mounted filesystem.

And I think same applies for mount-binded files, not just for mounted
directories.

Note that this Linux behavior (when readdir and stat returns different
inode numbers) is in POSIX readdir() specification called "historical"
and is described in RATIONALE section of POSIX readdir:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/readdir.html

Therefore it would be nice to mention the fact in Linux readdir(3)
documentation, that Linux conforms to POSIX "historical implementation".

Pali

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

end of thread, other threads:[~2025-11-22  0:53 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-25 10:33 Improving inode number documentation Pali Rohár
2025-05-25 23:30 ` Alejandro Colomar
2025-05-28 18:25   ` Pali Rohár
2025-05-28 19:03     ` Alejandro Colomar
2025-05-28 19:41       ` Pali Rohár
2025-05-28 19:59         ` Alejandro Colomar
2025-05-28 21:31           ` [RFC v1] man/man3/readdir.3, man/man3type/stat.3type: Improve documentation about .d_ino and .st_ino Alejandro Colomar
2025-05-28 22:54             ` G. Branden Robinson
2025-10-28 23:15           ` [PATCH v2] " Alejandro Colomar
2025-10-28 23:53             ` Pali Rohár
2025-10-29  7:00               ` G. Branden Robinson
2025-10-29 19:34                 ` Pali Rohár
2025-11-21 21:10                   ` Pali Rohár
2025-11-21 23:39                     ` G. Branden Robinson
2025-11-22  0:53                       ` Pali Rohár
2025-10-30 11:58             ` Jan Kara
2025-10-31 10:44           ` [PATCH v3] " Alejandro Colomar
2025-10-31 10:56             ` Jan Kara
2025-10-31 11:31               ` Alejandro Colomar
2025-10-31 17:10                 ` Pali Rohár
2025-10-31 15:25             ` Darrick J. Wong
2025-11-02 21:17               ` Alejandro Colomar
2025-11-03 11:28                 ` Jan Kara
2025-11-09 12:07                   ` Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox