bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

same-inode: adapt for windows-stat-inodes


From: Bruno Haible
Subject: same-inode: adapt for windows-stat-inodes
Date: Sun, 14 May 2017 18:03:05 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-75-generic; KDE/5.18.0; x86_64; ; )

With this adaptation of the 'same-inode' module, the 'stat' test
now passes on native Windows. (Well, it says "SKIP" because of missing
symbolic link support.)


2017-05-14  Bruno Haible  <address@hidden>

        same-inode: Adapt for windows-stat-inodes.
        * lib/same-inode.h: Include <sys/types.h>.
        (SAME_INODE) [_GL_WINDOWS_STAT_INODES]: Define specifically.
        * modules/same-inode (Depends-on): Add sys_types.

diff --git a/lib/same-inode.h b/lib/same-inode.h
index 7cece6d..a08bc4e 100644
--- a/lib/same-inode.h
+++ b/lib/same-inode.h
@@ -18,6 +18,8 @@
 #ifndef SAME_INODE_H
 # define SAME_INODE_H 1
 
+# include <sys/types.h>
+
 # ifdef __VMS
 #  define SAME_INODE(a, b)             \
     ((a).st_ino[0] == (b).st_ino[0]    \
@@ -25,9 +27,17 @@
      && (a).st_ino[2] == (b).st_ino[2] \
      && (a).st_dev == (b).st_dev)
 # elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-/* On MinGW, struct stat lacks necessary info, so always return 0.
-   Callers can use !a.st_ino to deduce that the information is unknown.  */
-#  define SAME_INODE(a, b) 0
+   /* Native Windows.  */
+#  if _GL_WINDOWS_STAT_INODES
+    /* stat() and fstat() set st_dev and st_ino to 0 if information about
+       the inode is not available.  */
+#   define SAME_INODE(a, b) \
+     (!((a).st_ino == 0 && (a).st_dev == 0) \
+      && (a).st_ino == (b).st_ino && (a).st_dev == (b).st_dev)
+#  else
+    /* stat() and fstat() set st_ino to 0 always.  */
+#   define SAME_INODE(a, b) 0
+#  endif
 # else
 #  define SAME_INODE(a, b)    \
     ((a).st_ino == (b).st_ino \
diff --git a/modules/same-inode b/modules/same-inode
index 27da5d2..53964d0 100644
--- a/modules/same-inode
+++ b/modules/same-inode
@@ -5,6 +5,7 @@ Files:
 lib/same-inode.h
 
 Depends-on:
+sys_types
 
 configure.ac:
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]