@@ -548,7 +548,15 @@ int fio_pread(FILE* f, void* buf, off_t offs)
548
548
return hdr .arg ;
549
549
}
550
550
else
551
- return pread (fileno (f ), buf , BLCKSZ , offs );
551
+ {
552
+ int rc ;
553
+ rc = fseek (f , offs , SEEK_SET );
554
+
555
+ if (rc < 0 )
556
+ return rc ;
557
+
558
+ return fread (buf , 1 , BLCKSZ , f );
559
+ }
552
560
}
553
561
554
562
/* Set position in stdio file */
@@ -898,6 +906,28 @@ int fio_sync(char const* path, fio_location location)
898
906
}
899
907
}
900
908
909
+ /* Get crc32 of file */
910
+ pg_crc32 fio_get_crc32 (const char * file_path , fio_location location )
911
+ {
912
+ if (fio_is_remote (location ))
913
+ {
914
+ fio_header hdr ;
915
+ size_t path_len = strlen (file_path ) + 1 ;
916
+ pg_crc32 crc = 0 ;
917
+ hdr .cop = FIO_GET_CRC32 ;
918
+ hdr .handle = -1 ;
919
+ hdr .size = path_len ;
920
+
921
+ IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
922
+ IO_CHECK (fio_write_all (fio_stdout , file_path , path_len ), path_len );
923
+ IO_CHECK (fio_read_all (fio_stdin , & crc , sizeof (crc )), sizeof (crc ));
924
+
925
+ return crc ;
926
+ }
927
+ else
928
+ return pgFileGetCRCnew (file_path , true, true);
929
+ }
930
+
901
931
/* Remove file */
902
932
int fio_unlink (char const * path , fio_location location )
903
933
{
@@ -1403,7 +1433,11 @@ static void fio_send_pages_impl(int fd, int out, fio_send_request* req)
1403
1433
return ;
1404
1434
}
1405
1435
}
1406
- /* horizonLsn is not 0 for delta backup. As far as unsigned number are always greater or equal than zero, there is no sense to add more checks */
1436
+ /*
1437
+ * horizonLsn is not 0 for delta backup.
1438
+ * As far as unsigned number are always greater or equal than zero,
1439
+ * there is no sense to add more checks.
1440
+ */
1407
1441
if (page_lsn >= req -> horizonLsn || page_lsn == InvalidXLogRecPtr )
1408
1442
{
1409
1443
char write_buffer [BLCKSZ * 2 ];
@@ -1450,6 +1484,7 @@ void fio_communicate(int in, int out)
1450
1484
struct stat st ;
1451
1485
int rc ;
1452
1486
int tmp_fd ;
1487
+ pg_crc32 crc ;
1453
1488
1454
1489
#ifdef WIN32
1455
1490
SYS_CHECK (setmode (in , _O_BINARY ));
@@ -1591,6 +1626,11 @@ void fio_communicate(int in, int out)
1591
1626
1592
1627
IO_CHECK (fio_write_all (out , & hdr , sizeof (hdr )), sizeof (hdr ));
1593
1628
break ;
1629
+ case FIO_GET_CRC32 :
1630
+ /* calculate crc32 for a file */
1631
+ crc = pgFileGetCRCnew (buf , true, true);
1632
+ IO_CHECK (fio_write_all (out , & crc , sizeof (crc )), sizeof (crc ));
1633
+ break ;
1594
1634
default :
1595
1635
Assert (false);
1596
1636
}
0 commit comments