@@ -2492,6 +2492,37 @@ static void fio_check_postmaster_impl(int out, char *buf)
2492
2492
IO_CHECK (fio_write_all (out , & hdr , sizeof (hdr )), sizeof (hdr ));
2493
2493
}
2494
2494
2495
+ /*
2496
+ * Delete file pointed by the pgFile.
2497
+ * If the pgFile points directory, the directory must be empty.
2498
+ */
2499
+ void
2500
+ fio_delete (mode_t mode , const char * fullpath , fio_location location )
2501
+ {
2502
+ if (fio_is_remote (location ))
2503
+ {
2504
+ fio_header hdr ;
2505
+
2506
+ hdr .cop = FIO_DELETE ;
2507
+ hdr .size = strlen (fullpath ) + 1 ;
2508
+ hdr .arg = mode ;
2509
+
2510
+ IO_CHECK (fio_write_all (fio_stdout , & hdr , sizeof (hdr )), sizeof (hdr ));
2511
+ IO_CHECK (fio_write_all (fio_stdout , fullpath , hdr .size ), hdr .size );
2512
+
2513
+ }
2514
+ else
2515
+ pgFileDelete (mode , fullpath );
2516
+ }
2517
+
2518
+ static void
2519
+ fio_delete_impl (mode_t mode , char * buf )
2520
+ {
2521
+ char * fullpath = (char * ) buf ;
2522
+
2523
+ pgFileDelete (mode , fullpath );
2524
+ }
2525
+
2495
2526
/* Execute commands at remote host */
2496
2527
void fio_communicate (int in , int out )
2497
2528
{
@@ -2675,6 +2706,10 @@ void fio_communicate(int in, int out)
2675
2706
/* calculate crc32 for a file */
2676
2707
fio_check_postmaster_impl (out , buf );
2677
2708
break ;
2709
+ case FIO_DELETE :
2710
+ /* delete file */
2711
+ fio_delete_impl (hdr .arg , buf );
2712
+ break ;
2678
2713
case FIO_DISCONNECT :
2679
2714
hdr .cop = FIO_DISCONNECTED ;
2680
2715
IO_CHECK (fio_write_all (out , & hdr , sizeof (hdr )), sizeof (hdr ));
0 commit comments