@@ -1681,6 +1681,7 @@ static int FIO_compressFilename_dstFile(FIO_ctx_t* const fCtx,
1681
1681
int result ;
1682
1682
int transferStat = 0 ;
1683
1683
FILE * dstFile ;
1684
+ int dstFd = -1 ;
1684
1685
1685
1686
assert (AIO_ReadPool_getFile (ress .readCtx ) != NULL );
1686
1687
if (AIO_WritePool_getFile (ress .writeCtx ) == NULL ) {
@@ -1696,6 +1697,7 @@ static int FIO_compressFilename_dstFile(FIO_ctx_t* const fCtx,
1696
1697
DISPLAYLEVEL (6 , "FIO_compressFilename_dstFile: opening dst: %s \n" , dstFileName );
1697
1698
dstFile = FIO_openDstFile (fCtx , prefs , srcFileName , dstFileName , dstFileInitialPermissions );
1698
1699
if (dstFile == NULL ) return 1 ; /* could not open dstFileName */
1700
+ dstFd = fileno (dstFile );
1699
1701
AIO_WritePool_setFile (ress .writeCtx , dstFile );
1700
1702
/* Must only be added after FIO_openDstFile() succeeds.
1701
1703
* Otherwise we may delete the destination file if it already exists,
@@ -1709,14 +1711,20 @@ static int FIO_compressFilename_dstFile(FIO_ctx_t* const fCtx,
1709
1711
if (closeDstFile ) {
1710
1712
clearHandler ();
1711
1713
1714
+ if (transferStat ) {
1715
+ UTIL_setFDStat (dstFd , dstFileName , srcFileStat );
1716
+ }
1717
+
1712
1718
DISPLAYLEVEL (6 , "FIO_compressFilename_dstFile: closing dst: %s \n" , dstFileName );
1713
1719
if (AIO_WritePool_closeFile (ress .writeCtx )) { /* error closing file */
1714
1720
DISPLAYLEVEL (1 , "zstd: %s: %s \n" , dstFileName , strerror (errno ));
1715
1721
result = 1 ;
1716
1722
}
1723
+
1717
1724
if (transferStat ) {
1718
- UTIL_setFileStat (dstFileName , srcFileStat );
1725
+ UTIL_utime (dstFileName , srcFileStat );
1719
1726
}
1727
+
1720
1728
if ( (result != 0 ) /* operation failure */
1721
1729
&& strcmp (dstFileName , stdoutmark ) /* special case : don't remove() stdout */
1722
1730
) {
@@ -2540,6 +2548,7 @@ static int FIO_decompressDstFile(FIO_ctx_t* const fCtx,
2540
2548
int result ;
2541
2549
int releaseDstFile = 0 ;
2542
2550
int transferStat = 0 ;
2551
+ int dstFd = 0 ;
2543
2552
2544
2553
if ((AIO_WritePool_getFile (ress .writeCtx ) == NULL ) && (prefs -> testMode == 0 )) {
2545
2554
FILE * dstFile ;
@@ -2555,6 +2564,7 @@ static int FIO_decompressDstFile(FIO_ctx_t* const fCtx,
2555
2564
2556
2565
dstFile = FIO_openDstFile (fCtx , prefs , srcFileName , dstFileName , dstFilePermissions );
2557
2566
if (dstFile == NULL ) return 1 ;
2567
+ dstFd = fileno (dstFile );
2558
2568
AIO_WritePool_setFile (ress .writeCtx , dstFile );
2559
2569
2560
2570
/* Must only be added after FIO_openDstFile() succeeds.
@@ -2568,13 +2578,18 @@ static int FIO_decompressDstFile(FIO_ctx_t* const fCtx,
2568
2578
2569
2579
if (releaseDstFile ) {
2570
2580
clearHandler ();
2581
+
2582
+ if (transferStat ) {
2583
+ UTIL_setFDStat (dstFd , dstFileName , srcFileStat );
2584
+ }
2585
+
2571
2586
if (AIO_WritePool_closeFile (ress .writeCtx )) {
2572
2587
DISPLAYLEVEL (1 , "zstd: %s: %s \n" , dstFileName , strerror (errno ));
2573
2588
result = 1 ;
2574
2589
}
2575
2590
2576
2591
if (transferStat ) {
2577
- UTIL_setFileStat (dstFileName , srcFileStat );
2592
+ UTIL_utime (dstFileName , srcFileStat );
2578
2593
}
2579
2594
2580
2595
if ( (result != 0 ) /* operation failure */
0 commit comments