summaryrefslogtreecommitdiff
path: root/tests/same-inode.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/same-inode.h')
-rw-r--r--tests/same-inode.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/same-inode.h b/tests/same-inode.h
index 13ae24b7..70f17b03 100644
--- a/tests/same-inode.h
+++ b/tests/same-inode.h
@@ -1,6 +1,6 @@
/* Determine whether two stat buffers are known to refer to the same file.
- Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2009-2025 Free Software Foundation, Inc.
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -77,12 +77,17 @@ extern "C" {
#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));
}