Skip to content

Commit 8c74ac4

Browse files
lchioccadscho
authored andcommitted
The stat() function should be independent of core.symlinks
The contract for the stat() and lstat() function is: > stat(): stats the file pointed to by path and fills in buf. > lstat(): is identical to stat(), except that if path is a symbolic link, > then the link itself is stat-ed, not the file that it refers to. stat() should always return the statistics of the file or directory a symbolic link is pointing to. The lstat() function is used to get the stats for the symlink. Hence the check should not be there. Signed-off-by: Loris Chiocca <[email protected]>
1 parent 0e78f5c commit 8c74ac4

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

compat/mingw.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -877,17 +877,7 @@ int mingw_stat(const char *file_name, struct stat *buf)
877877
HANDLE hnd;
878878
int result;
879879

880-
/* if symlinks are disabled, use lstat() (without following links) */
881-
if (!has_symlinks) {
882-
result = lstat(file_name, buf);
883-
if (!result && S_ISLNK(buf->st_mode)) {
884-
errno = ELOOP;
885-
return -1;
886-
}
887-
return result;
888-
}
889-
890-
/* otherwise just open the file and let Windows resolve the links */
880+
/* open the file and let Windows resolve the links */
891881
if (xutftowcs_long_path(wfile_name, file_name) < 0)
892882
return -1;
893883
hnd = CreateFileW(wfile_name, 0,

0 commit comments

Comments
 (0)