Skip to content

Commit

Permalink
Merge pull request #2673 from dscho/also-handle-fscache-addon-for-#2637
Browse files Browse the repository at this point in the history
Fix `lstat()`'s `st_size` computation for symbolic links when FSCache is in effect
  • Loading branch information
dscho authored and Git for Windows Build Agent committed Jul 7, 2020
2 parents faaa857 + 2fa7675 commit d4bdc88
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions compat/win32/fscache.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,18 @@ int fscache_lstat(const char *filename, struct stat *st)
if (!fse)
return -1;

/*
* Special case symbolic links: FindFirstFile()/FindNextFile() did not
* provide us with the length of the target path.
*/
if (fse->u.s.st_size == MAX_LONG_PATH && S_ISLNK(fse->st_mode)) {
char buf[MAX_LONG_PATH];
int len = readlink(filename, buf, sizeof(buf) - 1);

if (len > 0)
fse->u.s.st_size = len;
}

/* copy stat data */
st->st_ino = 0;
st->st_gid = 0;
Expand Down

0 comments on commit d4bdc88

Please sign in to comment.