@@ -535,7 +535,12 @@ int fio_fstat(int fd, struct stat* st)
535
535
Assert (hdr .cop == FIO_FSTAT );
536
536
IO_CHECK (fio_read_all (fio_stdin , st , sizeof (* st )), sizeof (* st ));
537
537
538
- return hdr .arg ;
538
+ if (hdr .arg != 0 )
539
+ {
540
+ errno = hdr .arg ;
541
+ return -1 ;
542
+ }
543
+ return 0 ;
539
544
}
540
545
else
541
546
{
@@ -563,7 +568,12 @@ int fio_stat(char const* path, struct stat* st, bool follow_symlinks, fio_locati
563
568
Assert (hdr .cop == FIO_STAT );
564
569
IO_CHECK (fio_read_all (fio_stdin , st , sizeof (* st )), sizeof (* st ));
565
570
566
- return hdr .arg ;
571
+ if (hdr .arg != 0 )
572
+ {
573
+ errno = hdr .arg ;
574
+ return -1 ;
575
+ }
576
+ return 0 ;
567
577
}
568
578
else
569
579
{
@@ -589,7 +599,12 @@ int fio_access(char const* path, int mode, fio_location location)
589
599
IO_CHECK (fio_read_all (fio_stdin , & hdr , sizeof (hdr )), sizeof (hdr ));
590
600
Assert (hdr .cop == FIO_ACCESS );
591
601
592
- return hdr .arg ;
602
+ if (hdr .arg != 0 )
603
+ {
604
+ errno = hdr .arg ;
605
+ return -1 ;
606
+ }
607
+ return 0 ;
593
608
}
594
609
else
595
610
{
@@ -1074,19 +1089,20 @@ void fio_communicate(int in, int out)
1074
1089
break ;
1075
1090
case FIO_FSTAT : /* Get information about opened file */
1076
1091
hdr .size = sizeof (st );
1077
- hdr .arg = fstat (fd [hdr .handle ], & st );
1092
+ hdr .arg = fstat (fd [hdr .handle ], & st ) < 0 ? errno : 0 ;
1078
1093
IO_CHECK (fio_write_all (out , & hdr , sizeof (hdr )), sizeof (hdr ));
1079
1094
IO_CHECK (fio_write_all (out , & st , sizeof (st )), sizeof (st ));
1080
1095
break ;
1081
1096
case FIO_STAT : /* Get information about file with specified path */
1082
1097
hdr .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 ;
1084
1100
IO_CHECK (fio_write_all (out , & hdr , sizeof (hdr )), sizeof (hdr ));
1085
1101
IO_CHECK (fio_write_all (out , & st , sizeof (st )), sizeof (st ));
1086
1102
break ;
1087
1103
case FIO_ACCESS : /* Check presence of file with specified name */
1088
1104
hdr .size = 0 ;
1089
- hdr .arg = access (buf , hdr .arg );
1105
+ hdr .arg = access (buf , hdr .arg ) < 0 ? errno : 0 ;
1090
1106
IO_CHECK (fio_write_all (out , & hdr , sizeof (hdr )), sizeof (hdr ));
1091
1107
break ;
1092
1108
case FIO_RENAME : /* Rename file */
0 commit comments