bug-diffutils
[Top][All Lists]
Advanced

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

[bug-diffutils] bug#25814: Windows same_file macro is not reliable


From: Kees Dekker
Subject: [bug-diffutils] bug#25814: Windows same_file macro is not reliable
Date: Mon, 20 Feb 2017 16:01:09 +0000

Hi,

 

On file systems that do not support inodes (e.g. NTFS, because not everything is POSIX), the same_file() macro (in system.h) is incorrect as st_ino (and probably st_dev) are meaningless. See also https://msdn.microsoft.com/en- us/library/14h5k7ff.aspx. I would suggest to add an #ifdef _WIN32 macro that let return same_file() 0.

 

The same applies to same_file_attributes macro. The st_uid and st_gid fields are never set to a useful value on Windows (see MSDN URL as mentioned before).

 

The resulting suggested code would be:

 

#if _WIN32

# define same_file(s, t) 0

#else

# define same_file(s, t) \

    ((((s)->st_ino == (t)->st_ino) && ((s)->st_dev == (t)->st_dev)) \

     || same_special_file (s, t))

#endif

 

and

 

#ifndef same_file_attributes

#if _WIN32

# define same_file_attributes(s, t) 0

#else

# define same_file_attributes(s, t) \

   ((s)->st_mode == (t)->st_mode \

    && (s)->st_nlink == (t)->st_nlink \

    && (s)->st_uid == (t)->st_uid \

    && (s)->st_gid == (t)->st_gid \

    && (s)->st_size == (t)->st_size \

    && (s)->st_mtime == (t)->st_mtime \

    && (s)->st_ctime == (t)->st_ctime)

#endif

#endif

 

Since I’m unfamiliar with git, please check whether this change is feasible.

 

Regards,

Kees


reply via email to

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