@@ -202,10 +202,13 @@ static struct fsentry *fseentry_create_entry(struct fscache *cache,
202
202
fdata -> FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT ?
203
203
fdata -> EaSize : 0 ;
204
204
205
- fse -> st_mode = file_attr_to_st_mode (fdata -> FileAttributes );
206
- fse -> dirent .d_type = S_ISDIR (fse -> st_mode ) ? DT_DIR : DT_REG ;
207
- fse -> u .s .st_size = fdata -> EndOfFile .LowPart |
208
- (((off_t )fdata -> EndOfFile .HighPart ) << 32 );
205
+ fse -> st_mode = file_attr_to_st_mode (fdata -> FileAttributes ,
206
+ fdata -> EaSize );
207
+ fse -> dirent .d_type = S_ISREG (fse -> st_mode ) ? DT_REG :
208
+ S_ISDIR (fse -> st_mode ) ? DT_DIR : DT_LNK ;
209
+ fse -> u .s .st_size = S_ISLNK (fse -> st_mode ) ? MAX_LONG_PATH :
210
+ fdata -> EndOfFile .LowPart |
211
+ (((off_t )fdata -> EndOfFile .HighPart ) << 32 );
209
212
filetime_to_timespec ((FILETIME * )& (fdata -> LastAccessTime ),
210
213
& (fse -> u .s .st_atim ));
211
214
filetime_to_timespec ((FILETIME * )& (fdata -> LastWriteTime ),
@@ -581,6 +584,18 @@ int fscache_lstat(const char *filename, struct stat *st)
581
584
return -1 ;
582
585
}
583
586
587
+ /*
588
+ * Special case symbolic links: FindFirstFile()/FindNextFile() did not
589
+ * provide us with the length of the target path.
590
+ */
591
+ if (fse -> u .s .st_size == MAX_LONG_PATH && S_ISLNK (fse -> st_mode )) {
592
+ char buf [MAX_LONG_PATH ];
593
+ int len = readlink (filename , buf , sizeof (buf ) - 1 );
594
+
595
+ if (len > 0 )
596
+ fse -> u .s .st_size = len ;
597
+ }
598
+
584
599
/* copy stat data */
585
600
st -> st_ino = 0 ;
586
601
st -> st_gid = 0 ;
0 commit comments