All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Alejandro Colomar <alx@kernel.org>, linux-man@vger.kernel.org
Subject: Improving inode number documentation
Date: Sun, 25 May 2025 12:33:44 +0200	[thread overview]
Message-ID: <20250525103344.fe27ugiytfyoadz5@pali> (raw)

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

             reply	other threads:[~2025-05-25 10:33 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-25 10:33 Pali Rohár [this message]
2025-05-25 23:30 ` Improving inode number documentation 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250525103344.fe27ugiytfyoadz5@pali \
    --to=pali@kernel.org \
    --cc=alx@kernel.org \
    --cc=linux-man@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.