@@ -202,10 +202,13 @@ static struct fsentry *fseentry_create_entry(struct fscache *cache,
202202 fdata -> FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT ?
203203 fdata -> EaSize : 0 ;
204204
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 );
209212 filetime_to_timespec ((FILETIME * )& (fdata -> LastAccessTime ),
210213 & (fse -> u .s .st_atim ));
211214 filetime_to_timespec ((FILETIME * )& (fdata -> LastWriteTime ),
@@ -581,6 +584,18 @@ int fscache_lstat(const char *filename, struct stat *st)
581584 return -1 ;
582585 }
583586
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+
584599 /* copy stat data */
585600 st -> st_ino = 0 ;
586601 st -> st_gid = 0 ;
0 commit comments