2025-03-24 Paul Eggert <eggert@cs.ucla.edu>
+ same-inode: don't assume memory objects have ino
+ * lib/same-inode.h (psame_inode): Do not assume shared and/or
+ typed memory objects have reliable st_dev and st_ino when given to
+ stat-like functions, as POSIX does not guarantee this.
+ I don’t know of any such platforms (QNX perhaps?) but it’s
+ easy to be safe.
+
same-inode: update now-wrong dependency
* modules/same-inode (Depends-on): Depend on sys_stat-h,
not sys_types.h.
#define SAME_INODE(a, b) PSAME_INODE (&(a), &(b))
/* True if *A and *B represent the same file. Unlike PSAME_INODE,
- args are evaluated once and must point to struct stat. */
+ args are evaluated once and must point to struct stat,
+ and this function works even on POSIX platforms where fstat etc. do
+ not return useful st_dev and st_ino values for shared memory
+ objects and typed memory objects. */
SAME_INODE_INLINE bool
psame_inode (struct stat const *a, struct stat const *b)
{
- return PSAME_INODE (a, b);
+ return (! (S_TYPEISSHM (a) | S_TYPEISTMO (a)
+ | S_TYPEISSHM (b) | S_TYPEISTMO (b))
+ && PSAME_INODE (a, b));
}