@@ -52,9 +52,10 @@ static int do_lstat(const char *file_name, struct stat *buf)
5252 buf -> st_ino = 0 ;
5353 buf -> st_gid = 0 ;
5454 buf -> st_uid = 0 ;
55+ buf -> st_nlink = 1 ;
5556 buf -> st_mode = fMode ;
5657 buf -> st_size = fdata .nFileSizeLow ; /* Can't use nFileSizeHigh, since it's not a stat64 */
57- buf -> st_dev = _getdrive () - 1 ;
58+ buf -> st_dev = buf -> st_rdev = ( _getdrive () - 1 ) ;
5859 buf -> st_atime = filetime_to_time_t (& (fdata .ftLastAccessTime ));
5960 buf -> st_mtime = filetime_to_time_t (& (fdata .ftLastWriteTime ));
6061 buf -> st_ctime = filetime_to_time_t (& (fdata .ftCreationTime ));
@@ -88,7 +89,7 @@ static int do_lstat(const char *file_name, struct stat *buf)
8889 * complete. Note that Git stat()s are redirected to mingw_lstat()
8990 * too, since Windows doesn't really handle symlinks that well.
9091 */
91- int mingw_lstat (const char * file_name , struct mingw_stat * buf )
92+ int mingw_lstat (const char * file_name , struct stat * buf )
9293{
9394 int namelen ;
9495 static char alt_name [PATH_MAX ];
@@ -116,8 +117,7 @@ int mingw_lstat(const char *file_name, struct mingw_stat *buf)
116117}
117118
118119#undef fstat
119- #undef stat
120- int mingw_fstat (int fd , struct mingw_stat * buf )
120+ int mingw_fstat (int fd , struct stat * buf )
121121{
122122 HANDLE fh = (HANDLE )_get_osfhandle (fd );
123123 BY_HANDLE_FILE_INFORMATION fdata ;
@@ -127,21 +127,8 @@ int mingw_fstat(int fd, struct mingw_stat *buf)
127127 return -1 ;
128128 }
129129 /* direct non-file handles to MS's fstat() */
130- if (GetFileType (fh ) != FILE_TYPE_DISK ) {
131- struct stat st ;
132- if (fstat (fd , & st ))
133- return -1 ;
134- buf -> st_ino = st .st_ino ;
135- buf -> st_gid = st .st_gid ;
136- buf -> st_uid = st .st_uid ;
137- buf -> st_mode = st .st_mode ;
138- buf -> st_size = st .st_size ;
139- buf -> st_dev = st .st_dev ;
140- buf -> st_atime = st .st_atime ;
141- buf -> st_mtime = st .st_mtime ;
142- buf -> st_ctime = st .st_ctime ;
143- return 0 ;
144- }
130+ if (GetFileType (fh ) != FILE_TYPE_DISK )
131+ return fstat (fd , buf );
145132
146133 if (GetFileInformationByHandle (fh , & fdata )) {
147134 int fMode = S_IREAD ;
@@ -155,9 +142,10 @@ int mingw_fstat(int fd, struct mingw_stat *buf)
155142 buf -> st_ino = 0 ;
156143 buf -> st_gid = 0 ;
157144 buf -> st_uid = 0 ;
145+ buf -> st_nlink = 1 ;
158146 buf -> st_mode = fMode ;
159147 buf -> st_size = fdata .nFileSizeLow ; /* Can't use nFileSizeHigh, since it's not a stat64 */
160- buf -> st_dev = _getdrive () - 1 ;
148+ buf -> st_dev = buf -> st_rdev = ( _getdrive () - 1 ) ;
161149 buf -> st_atime = filetime_to_time_t (& (fdata .ftLastAccessTime ));
162150 buf -> st_mtime = filetime_to_time_t (& (fdata .ftLastWriteTime ));
163151 buf -> st_ctime = filetime_to_time_t (& (fdata .ftCreationTime ));
0 commit comments