@@ -535,7 +535,12 @@ int fio_fstat(int fd, struct stat* st)
535535Assert (hdr .cop == FIO_FSTAT );
536536IO_CHECK (fio_read_all (fio_stdin ,st ,sizeof (* st )),sizeof (* st ));
537537
538- return hdr .arg ;
538+ if (hdr .arg != 0 )
539+ {
540+ errno = hdr .arg ;
541+ return -1 ;
542+ }
543+ return 0 ;
539544}
540545else
541546{
@@ -563,7 +568,12 @@ int fio_stat(char const* path, struct stat* st, bool follow_symlinks, fio_locati
563568Assert (hdr .cop == FIO_STAT );
564569IO_CHECK (fio_read_all (fio_stdin ,st ,sizeof (* st )),sizeof (* st ));
565570
566- return hdr .arg ;
571+ if (hdr .arg != 0 )
572+ {
573+ errno = hdr .arg ;
574+ return -1 ;
575+ }
576+ return 0 ;
567577}
568578else
569579{
@@ -589,7 +599,12 @@ int fio_access(char const* path, int mode, fio_location location)
589599IO_CHECK (fio_read_all (fio_stdin ,& hdr ,sizeof (hdr )),sizeof (hdr ));
590600Assert (hdr .cop == FIO_ACCESS );
591601
592- return hdr .arg ;
602+ if (hdr .arg != 0 )
603+ {
604+ errno = hdr .arg ;
605+ return -1 ;
606+ }
607+ return 0 ;
593608}
594609else
595610{
@@ -1074,19 +1089,20 @@ void fio_communicate(int in, int out)
10741089break ;
10751090case FIO_FSTAT :/* Get information about opened file */
10761091hdr .size = sizeof (st );
1077- hdr .arg = fstat (fd [hdr .handle ],& st );
1092+ hdr .arg = fstat (fd [hdr .handle ],& st )< 0 ? errno : 0 ;
10781093IO_CHECK (fio_write_all (out ,& hdr ,sizeof (hdr )),sizeof (hdr ));
10791094IO_CHECK (fio_write_all (out ,& st ,sizeof (st )),sizeof (st ));
10801095break ;
10811096case FIO_STAT :/* Get information about file with specified path */
10821097hdr .size = sizeof (st );
1083- hdr .arg = hdr .arg ?stat (buf ,& st ) :lstat (buf ,& st );
1098+ rc = hdr .arg ?stat (buf ,& st ) :lstat (buf ,& st );
1099+ hdr .arg = rc < 0 ?errno :0 ;
10841100IO_CHECK (fio_write_all (out ,& hdr ,sizeof (hdr )),sizeof (hdr ));
10851101IO_CHECK (fio_write_all (out ,& st ,sizeof (st )),sizeof (st ));
10861102break ;
10871103case FIO_ACCESS :/* Check presence of file with specified name */
10881104hdr .size = 0 ;
1089- hdr .arg = access (buf ,hdr .arg );
1105+ hdr .arg = access (buf ,hdr .arg )< 0 ? errno : 0 ;
10901106IO_CHECK (fio_write_all (out ,& hdr ,sizeof (hdr )),sizeof (hdr ));
10911107break ;
10921108case FIO_RENAME :/* Rename file */