@@ -1159,24 +1159,35 @@ fio_stat(char const* path, struct stat* st, bool follow_symlink, fio_location lo
11591159bool
11601160fio_is_same_file (char const * filename1 , char const * filename2 , bool follow_symlink , fio_location location )
11611161{
1162+ char * abs_name1 = make_absolute_path (filename1 );
1163+ char * abs_name2 = make_absolute_path (filename2 );
1164+ bool result = strcmp (abs_name1 , abs_name2 ) == 0 ;
1165+
11621166#ifndef WIN32
1163- struct stat stat1 , stat2 ;
1167+ if (!result )
1168+ {
1169+ struct stat stat1 , stat2 ;
11641170
1165- if (fio_stat (filename1 , & stat1 , follow_symlink , location ) < 0 )
1166- elog (ERROR , "Can't stat file \"%s\": %s" , filename1 , strerror (errno ));
1171+ if (fio_stat (filename1 , & stat1 , follow_symlink , location ) < 0 )
1172+ {
1173+ if (errno == ENOENT )
1174+ return false;
1175+ elog (ERROR , "Can't stat file \"%s\": %s" , filename1 , strerror (errno ));
1176+ }
11671177
1168- if (fio_stat (filename2 , & stat2 , follow_symlink , location ) < 0 )
1169- elog (ERROR , "Can't stat file \"%s\": %s" , filename2 , strerror (errno ));
1178+ if (fio_stat (filename2 , & stat2 , follow_symlink , location ) < 0 )
1179+ {
1180+ if (errno == ENOENT )
1181+ return false;
1182+ elog (ERROR , "Can't stat file \"%s\": %s" , filename2 , strerror (errno ));
1183+ }
11701184
1171- return stat1 .st_ino == stat2 .st_ino && stat1 .st_dev == stat2 .st_dev ;
1172- #else
1173- char * abs_name1 = make_absolute_path (filename1 );
1174- char * abs_name2 = make_absolute_path (filename2 );
1175- bool result = strcmp (abs_name1 , abs_name2 ) == 0 ;
1185+ result = (stat1 .st_ino == stat2 .st_ino && stat1 .st_dev == stat2 .st_dev );
1186+ }
1187+ #endif
11761188 free (abs_name2 );
11771189 free (abs_name1 );
11781190 return result ;
1179- #endif
11801191}
11811192
11821193/*
0 commit comments