Revert "Windows: Use a customized struct stat that also has the st_blocks member."
This reverts commit fc2ded5b08e071beed974117c0148781b1acc94a. As we do not need the member in struct stat, we do not need to have a custom "struct mingw_stat" anymore. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Sixt committed
Aug 18, 2008 at 22:01 UTC
180964f0b98344f3127d6b8167cec8a07ef663ad
2 files changed
+11
-32
compat/mingw.c
+8
-20
@@ -52,9 +52,10 @@ static int do_lstat(const char *file_name, struct stat *buf)
52
buf->st_ino = 0;
53
buf->st_gid = 0;
54
buf->st_uid = 0;
55
+ buf->st_nlink = 1;
56
buf->st_mode = fMode;
57
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);
59
buf->st_atime = filetime_to_time_t(&(fdata.ftLastAccessTime));
60
buf->st_mtime = filetime_to_time_t(&(fdata.ftLastWriteTime));
61
buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime));
@@ -88,7 +89,7 @@ static int do_lstat(const char *file_name, struct stat *buf)
89
* complete. Note that Git stat()s are redirected to mingw_lstat()
90
* too, since Windows doesn't really handle symlinks that well.
91
*/
91
-int mingw_lstat(const char *file_name, struct mingw_stat *buf)
92
+int mingw_lstat(const char *file_name, struct stat *buf)
93
{
94
int namelen;
95
static char alt_name[PATH_MAX];
@@ -116,8 +117,7 @@ int mingw_lstat(const char *file_name, struct mingw_stat *buf)
117
}
118
119
#undef fstat
119
-#undef stat
120
-int mingw_fstat(int fd, struct mingw_stat *buf)
120
+int mingw_fstat(int fd, struct stat *buf)
121
{
122
HANDLE fh = (HANDLE)_get_osfhandle(fd);
123
BY_HANDLE_FILE_INFORMATION fdata;
@@ -127,21 +127,8 @@ int mingw_fstat(int fd, struct mingw_stat *buf)
127
return -1;
128
}
129
/* 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);
132
133
if (GetFileInformationByHandle(fh, &fdata)) {
134
int fMode = S_IREAD;
@@ -155,9 +142,10 @@ int mingw_fstat(int fd, struct mingw_stat *buf)
142
buf->st_ino = 0;
143
buf->st_gid = 0;
144
buf->st_uid = 0;
145
+ buf->st_nlink = 1;
146
buf->st_mode = fMode;
147
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);
149
buf->st_atime = filetime_to_time_t(&(fdata.ftLastAccessTime));
150
buf->st_mtime = filetime_to_time_t(&(fdata.ftLastWriteTime));
151
buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime));
compat/mingw.h
+3
-12
@@ -162,21 +162,12 @@ int mingw_rename(const char*, const char*);
162
163
/* Use mingw_lstat() instead of lstat()/stat() and
164
* mingw_fstat() instead of fstat() on Windows.
165
- * struct stat is redefined because it lacks the st_blocks member.
165
*/
167
-struct mingw_stat {
168
- unsigned st_mode;
169
- time_t st_mtime, st_atime, st_ctime;
170
- unsigned st_dev, st_ino, st_uid, st_gid;
171
- size_t st_size;
172
-};
173
-int mingw_lstat(const char *file_name, struct mingw_stat *buf);
174
-int mingw_fstat(int fd, struct mingw_stat *buf);
166
+int mingw_lstat(const char *file_name, struct stat *buf);
167
+int mingw_fstat(int fd, struct stat *buf);
168
#define fstat mingw_fstat
169
#define lstat mingw_lstat
177
-#define stat mingw_stat
178
-static inline int mingw_stat(const char *file_name, struct mingw_stat *buf)
179
-{ return mingw_lstat(file_name, buf); }
170
+#define stat(x,y) mingw_lstat(x,y)
171
172
int mingw_utime(const char *file_name, const struct utimbuf *times);
173
#define utime mingw_utime