summaryrefslogtreecommitdiffstats
path: root/libdwfl/find-debuginfo.c
diff options
context:
space:
mode:
authorUlf Hermann <[email protected]>2017-04-06 19:11:34 +0200
committerUlf Hermann <[email protected]>2017-05-08 09:45:46 +0000
commit9f59b055f56ccebaa3d272d153c74fb889958a8a (patch)
tree8407114b4fc6f03dccfda236afb0d6e44ab86302 /libdwfl/find-debuginfo.c
parente5cde7378c246a32d7dbc3bff8db15befad8b1a9 (diff)
Adapt debug info fstat check for windows
On windows the resulting ino and dev entries are always 0, so the file would always be discarded. We apply a heuristic instead: If the ctime, mtime, mode and size of the two files are all equal then we consider them to be the same. It's exceedingly unlikely to produce two different files for which that holds by chance. Change-Id: I491c95ab8b90fc3c1b786cceae242e142b5a491f Reviewed-by: Christian Kandeler <[email protected]>
Diffstat (limited to 'libdwfl/find-debuginfo.c')
-rw-r--r--libdwfl/find-debuginfo.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c
index ac568d08..3a65eda0 100644
--- a/libdwfl/find-debuginfo.c
+++ b/libdwfl/find-debuginfo.c
@@ -63,10 +63,19 @@ try_open (const struct stat *main_stat,
if (fd < 0)
free (fname);
else if (fstat (fd, &st) == 0
+#if defined _WIN32 || defined __WIN32__
+ /* On windows, st_ino and st_dev are not unique, so we apply a heuristic */
+ && st.st_size == main_stat->st_size
+ && st.st_mode == main_stat->st_mode
+ && st.st_mtime == main_stat->st_mtime
+ && st.st_ctime == main_stat->st_ctime
+#endif
&& st.st_ino == main_stat->st_ino
&& st.st_dev == main_stat->st_dev)
{
/* This is the main file by another name. Don't look at it again. */
+ /* This doesn't happen on windows as windows doesn't have proper links. However, on windows
+ st_ino and st_dev is always 0. */
free (fname);
close (fd);
errno = ENOENT;