refactor(cli): move compression metadata policy to Rust
Keep the private stat_t probe, destination opening, metadata syscalls, and format callbacks in C, but route the regular-source plus stdin/stdout exception policy through the Rust fileio preference layer. The Rust ABI bridge normalizes the scalar consumed by the existing destination lifecycle, with compile-time value assertions and focused tests covering regular, non-regular, stdin, stdout, and nonzero scalar inputs. Test Plan: Not run by request; cargo, make, native tests, and heavy commands were intentionally avoided. Lightweight git diff --check passed.
This commit is contained in:
+19
-6
@@ -334,6 +334,16 @@ int FIO_rust_adjustParamsForPatchFromMode(FIO_prefs_t* prefs,
|
||||
const char* FIO_determineCompressedName(const char* srcFileName, const char* outDirName, const char* suffix);
|
||||
const char* FIO_rust_determineDstName(const char* srcFileName, const char* outDirName,
|
||||
const char* const* suffixList, const char* suffixListStr);
|
||||
enum {
|
||||
FIO_RUST_COMPRESS_DST_TRANSFER_STAT_NO = 0,
|
||||
FIO_RUST_COMPRESS_DST_TRANSFER_STAT_YES = 1
|
||||
};
|
||||
typedef char FIO_rust_compress_dst_transfer_stat_values[
|
||||
(FIO_RUST_COMPRESS_DST_TRANSFER_STAT_NO == 0
|
||||
&& FIO_RUST_COMPRESS_DST_TRANSFER_STAT_YES == 1) ? 1 : -1];
|
||||
int FIO_rust_compressDestinationTransferStat(int sourceIsStdin,
|
||||
int destinationIsStdout,
|
||||
int sourceIsRegular);
|
||||
int FIO_rust_adjustMemLimitForPatchFromMode(FIO_prefs_t* prefs,
|
||||
unsigned long long dictSize,
|
||||
unsigned long long maxSrcFileSize);
|
||||
@@ -3258,8 +3268,9 @@ static void FIO_rust_compressDestinationRemove(void* opaque,
|
||||
/*! FIO_compressFilename_dstFile() :
|
||||
* open the destination, or pass through if the write pool already owns it,
|
||||
* then start compression with FIO_compressFilename_internal().
|
||||
* Rust owns the lifecycle ordering; C retains opaque resources, diagnostics,
|
||||
* metadata operations, and format-specific compression callbacks.
|
||||
* Rust owns the lifecycle ordering and scalar metadata-transfer policy; C
|
||||
* retains opaque resources, the private stat probe, metadata operations, and
|
||||
* format-specific compression callbacks.
|
||||
* note : ress.readCtx must already have a source file attached,
|
||||
* so reach this function through FIO_compressFilename_srcFile().
|
||||
* @return : 0 : compression completed correctly,
|
||||
@@ -3293,10 +3304,12 @@ static int FIO_compressFilename_dstFile(FIO_ctx_t* const fCtx,
|
||||
projection.destinationAlreadyOpen = AIO_WritePool_getFile(ress.writeCtx) != NULL;
|
||||
projection.sourceIsStdin = !strcmp(srcFileName, stdinmark);
|
||||
projection.destinationIsStdout = !strcmp(dstFileName, stdoutmark);
|
||||
projection.sourceIsRegular = (projection.sourceIsStdin
|
||||
|| projection.destinationIsStdout)
|
||||
? 0
|
||||
: UTIL_isRegularFileStat(srcFileStat);
|
||||
/* C probes the private stat_t; Rust owns the stdin/stdout exceptions and
|
||||
* normalizes the scalar consumed by the Rust destination lifecycle. */
|
||||
projection.sourceIsRegular = FIO_rust_compressDestinationTransferStat(
|
||||
projection.sourceIsStdin,
|
||||
projection.destinationIsStdout,
|
||||
UTIL_isRegularFileStat(srcFileStat));
|
||||
projection.openDestination = FIO_rust_compressDestinationOpen;
|
||||
projection.attachDestination = FIO_rust_compressDestinationAttach;
|
||||
projection.addHandler = FIO_rust_compressAddHandler;
|
||||
|
||||
Reference in New Issue
Block a user