@@ -207,10 +207,13 @@ static struct fsentry *fseentry_create_entry(struct fscache *cache,
207
207
fdata -> FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT ?
208
208
fdata -> EaSize : 0 ;
209
209
210
- fse -> st_mode = file_attr_to_st_mode (fdata -> FileAttributes );
211
- fse -> dirent .d_type = S_ISDIR (fse -> st_mode ) ? DT_DIR : DT_REG ;
212
- fse -> u .s .st_size = fdata -> EndOfFile .LowPart |
213
- (((off_t )fdata -> EndOfFile .HighPart ) << 32 );
210
+ fse -> st_mode = file_attr_to_st_mode (fdata -> FileAttributes ,
211
+ fdata -> EaSize );
212
+ fse -> dirent .d_type = S_ISREG (fse -> st_mode ) ? DT_REG :
213
+ S_ISDIR (fse -> st_mode ) ? DT_DIR : DT_LNK ;
214
+ fse -> u .s .st_size = S_ISLNK (fse -> st_mode ) ? MAX_LONG_PATH :
215
+ fdata -> EndOfFile .LowPart |
216
+ (((off_t )fdata -> EndOfFile .HighPart ) << 32 );
214
217
filetime_to_timespec ((FILETIME * )& (fdata -> LastAccessTime ),
215
218
& (fse -> u .s .st_atim ));
216
219
filetime_to_timespec ((FILETIME * )& (fdata -> LastWriteTime ),
@@ -591,6 +594,18 @@ int fscache_lstat(const char *filename, struct stat *st)
591
594
return -1 ;
592
595
}
593
596
597
+ /*
598
+ * Special case symbolic links: FindFirstFile()/FindNextFile() did not
599
+ * provide us with the length of the target path.
600
+ */
601
+ if (fse -> u .s .st_size == MAX_LONG_PATH && S_ISLNK (fse -> st_mode )) {
602
+ char buf [MAX_LONG_PATH ];
603
+ int len = readlink (filename , buf , sizeof (buf ) - 1 );
604
+
605
+ if (len > 0 )
606
+ fse -> u .s .st_size = len ;
607
+ }
608
+
594
609
/* copy stat data */
595
610
st -> st_ino = 0 ;
596
611
st -> st_gid = 0 ;
0 commit comments