Skip to content

Commit 42fe9b3

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 8563cb9 commit 42fe9b3

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
@@ -757,17 +757,7 @@ int mingw_stat(const char *file_name, struct stat *buf)
757757
HANDLE hnd;
758758
int result;
759759

760-
/* if symlinks are disabled, use lstat() (without following links) */
761-
if (!has_symlinks) {
762-
result = lstat(file_name, buf);
763-
if (!result && S_ISLNK(buf->st_mode)) {
764-
errno = ELOOP;
765-
return -1;
766-
}
767-
return result;
768-
}
769-
770-
/* otherwise just open the file and let Windows resolve the links */
760+
/* open the file and let Windows resolve the links */
771761
if (xutftowcs_long_path(wfile_name, file_name) < 0)
772762
return -1;
773763
hnd = CreateFileW(wfile_name, 0,

0 commit comments

Comments
 (0)