Skip to content

Commit

Permalink
The stat() function should be independent of core.symlinks
Browse files Browse the repository at this point in the history
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 <loris@chiocca.ch>
  • Loading branch information
lchiocca authored and dscho committed Oct 18, 2015
1 parent 250f3b6 commit ea3e777
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,17 +757,7 @@ int mingw_stat(const char *file_name, struct stat *buf)
HANDLE hnd;
int result;

/* if symlinks are disabled, use lstat() (without following links) */
if (!has_symlinks) {
result = lstat(file_name, buf);
if (!result && S_ISLNK(buf->st_mode)) {
errno = ELOOP;
return -1;
}
return result;
}

/* otherwise just open the file and let Windows resolve the links */
/* open the file and let Windows resolve the links */
if (xutftowcs_long_path(wfile_name, file_name) < 0)
return -1;
hnd = CreateFileW(wfile_name, 0,
Expand Down

0 comments on commit ea3e777

Please sign in to comment.