It may be outdated code, the value is never 2. sys_types_h.m4 sets it to 0 or via gl_WINDOWS_STAT_INODES. gl_WINDOWS_STAT_INODES sets it to 1 if compiled via mingw* and 0 otherwise. --- lib/stat-w32.c | 107 +++------------------------------------------ lib/stat.c | 9 ---- lib/sys_types.in.h | 25 ----------- 3 files changed, 6 insertions(+), 135 deletions(-)
diff --git a/lib/stat-w32.c b/lib/stat-w32.c index 6900dfcf5..2cbcdca8b 100644 --- a/lib/stat-w32.c +++ b/lib/stat-w32.c @@ -42,14 +42,6 @@ #define GetProcAddress \ (void *) GetProcAddress -#if _GL_WINDOWS_STAT_INODES == 2 -/* GetFileInformationByHandleEx was introduced only in Windows Vista. */ -typedef DWORD (WINAPI * GetFileInformationByHandleExFuncType) (HANDLE hFile, - FILE_INFO_BY_HANDLE_CLASS fiClass, - LPVOID lpBuffer, - DWORD dwBufferSize); -static GetFileInformationByHandleExFuncType GetFileInformationByHandleExFunc = NULL; -#endif /* GetFinalPathNameByHandle was introduced only in Windows Vista. */ typedef DWORD (WINAPI * GetFinalPathNameByHandleFuncType) (HANDLE hFile, LPSTR lpFilePath, @@ -63,9 +55,6 @@ initialize (void) { #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) /* LoadLibrary not allowed but the functions are available with the windows runtime */ -#if _GL_WINDOWS_STAT_INODES == 2 - GetFileInformationByHandleExFunc = GetFileInformationByHandleEx; -#endif #if _WIN32_WINNT >= 0x0A00 /* _WIN32_WINNT_WIN10 */ GetFinalPathNameByHandleFunc = GetFinalPathNameByHandleA; #endif @@ -73,10 +62,6 @@ initialize (void) HMODULE kernel32 = LoadLibrary ("kernel32.dll"); if (kernel32 != NULL) { -#if _GL_WINDOWS_STAT_INODES == 2 - GetFileInformationByHandleExFunc = - (GetFileInformationByHandleExFuncType) GetProcAddress (kernel32, "GetFileInformationByHandleEx"); -#endif GetFinalPathNameByHandleFunc = (GetFinalPathNameByHandleFuncType) GetProcAddress (kernel32, "GetFinalPathNameByHandleA"); } @@ -152,12 +137,7 @@ _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf) or through GetFileInformationByHandle <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle> - <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information> - or through - GetFileInformationByHandleEx with argument FileBasicInfo - <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex> - <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_basic_info> - The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */ + <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information> */ BY_HANDLE_FILE_INFORMATION info; if (! GetFileInformationByHandle (h, &info)) goto failed; @@ -174,60 +154,9 @@ _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf) GetFileInformationByHandle <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle> <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information> - as 64 bits, or through - GetFileInformationByHandleEx with argument FileIdInfo - <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex> - <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_id_info> - as 128 bits. - The latter requires -D_WIN32_WINNT=_WIN32_WINNT_WIN8 or higher. */ - /* Experiments show that GetFileInformationByHandleEx does not provide - much more information than GetFileInformationByHandle: - * The dwVolumeSerialNumber from GetFileInformationByHandle is equal - to the low 32 bits of the 64-bit VolumeSerialNumber from - GetFileInformationByHandleEx, and is apparently sufficient for - identifying the device. - * The nFileIndex from GetFileInformationByHandle is equal to the low - 64 bits of the 128-bit FileId from GetFileInformationByHandleEx, - and the high 64 bits of this 128-bit FileId are zero. - * On a FAT file system, GetFileInformationByHandleEx fails with error - ERROR_INVALID_PARAMETER, whereas GetFileInformationByHandle - succeeds. - * On a CIFS/SMB file system, GetFileInformationByHandleEx fails with - error ERROR_INVALID_LEVEL, whereas GetFileInformationByHandle - succeeds. */ -# if _GL_WINDOWS_STAT_INODES == 2 - if (GetFileInformationByHandleExFunc != NULL) - { - FILE_ID_INFO id; - if (GetFileInformationByHandleExFunc (h, FileIdInfo, &id, sizeof (id))) - { - buf->st_dev = id.VolumeSerialNumber; - verify (sizeof (ino_t) == sizeof (id.FileId)); - memcpy (&buf->st_ino, &id.FileId, sizeof (ino_t)); - goto ino_done; - } - else - { - switch (GetLastError ()) - { - case ERROR_INVALID_PARAMETER: /* older Windows version, or FAT */ - case ERROR_INVALID_LEVEL: /* CIFS/SMB file system */ - goto fallback; - default: - goto failed; - } - } - } - fallback: ; - /* Fallback for older Windows versions. */ - buf->st_dev = info.dwVolumeSerialNumber; - buf->st_ino._gl_ino[0] = ((ULONGLONG) info.nFileIndexHigh << 32) | (ULONGLONG) info.nFileIndexLow; - buf->st_ino._gl_ino[1] = 0; - ino_done: ; -# else /* _GL_WINDOWS_STAT_INODES == 1 */ + as 64 bits. */ buf->st_dev = info.dwVolumeSerialNumber; buf->st_ino = ((ULONGLONG) info.nFileIndexHigh << 32) | (ULONGLONG) info.nFileIndexLow; -# endif #else /* st_ino is not wide enough for identifying a file on a device. Without st_ino, st_dev is pointless. */ @@ -248,12 +177,7 @@ _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf) If the file name is already known, use it. Otherwise, for non-empty files, it can be determined through GetFinalPathNameByHandle - <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfinalpathnamebyhandlea> - or through - GetFileInformationByHandleEx with argument FileNameInfo - <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex> - <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_name_info> - Both require -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */ + <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfinalpathnamebyhandlea>. */ if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0) { char fpath[PATH_MAX]; @@ -288,12 +212,7 @@ _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf) /* st_nlink can be determined through GetFileInformationByHandle <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle> - <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information> - or through - GetFileInformationByHandleEx with argument FileStandardInfo - <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex> - <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_standard_info> - The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */ + <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information>. */ buf->st_nlink = (info.nNumberOfLinks > SHRT_MAX ? SHRT_MAX : info.nNumberOfLinks); /* There's no easy way to map the Windows SID concept to an integer. */ @@ -313,12 +232,7 @@ _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf) or through GetFileInformationByHandle <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle> - <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information> - or through - GetFileInformationByHandleEx with argument FileStandardInfo - <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex> - <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_standard_info> - The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */ + <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information>. */ if (sizeof (buf->st_size) <= 4) /* Range check already done above. */ buf->st_size = info.nFileSizeLow; @@ -335,12 +249,7 @@ _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf) or through GetFileInformationByHandle <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfileinformationbyhandle> - <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information> - or through - GetFileInformationByHandleEx with argument FileBasicInfo - <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-getfileinformationbyhandleex> - <https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_file_basic_info> - The latter requires -D_WIN32_WINNT=_WIN32_WINNT_VISTA or higher. */ + <https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/ns-fileapi-_by_handle_file_information>. */ #if _GL_WINDOWS_STAT_TIMESPEC buf->st_atim = _gl_convert_FILETIME_to_timespec (&info.ftLastAccessTime); buf->st_mtim = _gl_convert_FILETIME_to_timespec (&info.ftLastWriteTime); @@ -356,11 +265,7 @@ _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf) else if (type == FILE_TYPE_CHAR || type == FILE_TYPE_PIPE) { buf->st_dev = 0; -#if _GL_WINDOWS_STAT_INODES == 2 - buf->st_ino._gl_ino[0] = buf->st_ino._gl_ino[1] = 0; -#else buf->st_ino = 0; -#endif buf->st_mode = (type == FILE_TYPE_PIPE ? _S_IFIFO : _S_IFCHR); buf->st_nlink = 1; buf->st_uid = 0; diff --git a/lib/stat.c b/lib/stat.c index e074e6a0a..183358ce8 100644 --- a/lib/stat.c +++ b/lib/stat.c @@ -258,19 +258,10 @@ rpl_stat (char const *name, struct stat *buf) return -1; } -# if _GL_WINDOWS_STAT_INODES - buf->st_dev = 0; -# if _GL_WINDOWS_STAT_INODES == 2 - buf->st_ino._gl_ino[0] = buf->st_ino._gl_ino[1] = 0; -# else /* _GL_WINDOWS_STAT_INODES == 1 */ - buf->st_ino = 0; -# endif -# else /* st_ino is not wide enough for identifying a file on a device. Without st_ino, st_dev is pointless. */ buf->st_dev = 0; buf->st_ino = 0; -# endif /* st_mode. */ unsigned int mode = diff --git a/lib/sys_types.in.h b/lib/sys_types.in.h index e48ef40b5..420cc8121 100644 --- a/lib/sys_types.in.h +++ b/lib/sys_types.in.h @@ -57,29 +57,6 @@ on native Windows. */ #if @WINDOWS_STAT_INODES@ -# if @WINDOWS_STAT_INODES@ == 2 -/* Experimental, not useful in Windows 10. */ - -/* Define dev_t to a 64-bit type. */ -# if !defined GNULIB_defined_dev_t -typedef unsigned long long int rpl_dev_t; -# undef dev_t -# define dev_t rpl_dev_t -# define GNULIB_defined_dev_t 1 -# endif - -/* Define ino_t to a 128-bit type. */ -# if !defined GNULIB_defined_ino_t -/* MSVC does not have a 128-bit integer type. - GCC has a 128-bit integer type __int128, but only on 64-bit targets. */ -typedef struct { unsigned long long int _gl_ino[2]; } rpl_ino_t; -# undef ino_t -# define ino_t rpl_ino_t -# define GNULIB_defined_ino_t 1 -# endif - -# else /* @WINDOWS_STAT_INODES@ == 1 */ - /* Define ino_t to a 64-bit type. */ # if !defined GNULIB_defined_ino_t typedef unsigned long long int rpl_ino_t; @@ -88,8 +65,6 @@ typedef unsigned long long int rpl_ino_t; # define GNULIB_defined_ino_t 1 # endif -# endif - /* Indicator, for gnulib internal purposes. */ # define _GL_WINDOWS_STAT_INODES @WINDOWS_STAT_INODES@ -- 2.26.2