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