This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH] Adapt debug info fstat check for windows
- From: Ulf Hermann <ulf dot hermann at qt dot io>
- To: <elfutils-devel at sourceware dot org>
- Date: Thu, 4 May 2017 12:48:46 +0200
- Subject: [PATCH] Adapt debug info fstat check for windows
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=qt.io;
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qtcompany.onmicrosoft.com; s=selector1-qt-io; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=23EmCHFiZQBphN1bb9qXpBCJw8S5ZFBCsfmahKlgfb8=; b=TTbxj7iFZrB4ty6RGREADd8F99WkJPuv1YtsIN6eEwp2rc7mWuCrTA1OGoJZso9DBsgWCX1i2FGv5VZh16gSikBg4aVKXtb5iPCkTw3zHMPrWflQfL5srwP//85kcfO3bbGNk39iRUZaqL+I9yq7ol0qZjsvtUsgQNAFWQLppvU=
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
libdwfl/ChangeLog | 5 +++++
libdwfl/find-debuginfo.c | 9 +++++++++
2 files changed, 14 insertions(+)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index ee550d0..517ba21 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,5 +1,10 @@
2017-05-04 Ulf Hermann <ulf.hermann@qt.io>
+ * find-debuginfo.c: On windows, check various extra parameters of
+ struct stat to determine if two files are the same.
+
+2017-05-04 Ulf Hermann <ulf.hermann@qt.io>
+
* dwfl_build_id_find_elf.c: Don't assume unix file system conventions.
* find-debuginfo.c: Likewise.
* linux-kernel-modules.c: Likewise.
diff --git a/libdwfl/find-debuginfo.c b/libdwfl/find-debuginfo.c
index ac568d0..3a65eda 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;
--
2.1.4