refactor(cli): move source-open policy to Rust
Move stdin-sentinel classification and source stat/open result policy into the Rust fileio backend while keeping C responsible for diagnostics, binary-mode setup, and FILE ownership. The bridge leaves stat layout and native file utilities behind the existing C ABI and adds a focused no-stat stdin test. Test Plan: git diff --cached --check; focused Rust test added but full capped verification will run after the remaining workers are integrated.
This commit is contained in:
+7
-6
@@ -351,6 +351,7 @@ enum {
|
||||
FIO_RUST_OPEN_SRC_STAT_FAILED = 1,
|
||||
FIO_RUST_OPEN_SRC_NON_REGULAR = 2,
|
||||
FIO_RUST_OPEN_SRC_FOPEN_FAILED = 3,
|
||||
FIO_RUST_OPEN_SRC_STDIN = 4,
|
||||
};
|
||||
int FIO_rust_openSrcFile(int allowBlockDevices,
|
||||
const char* srcFileName,
|
||||
@@ -671,17 +672,17 @@ static FILE* FIO_openSrcFile(const FIO_prefs_t* const prefs, const char* srcFile
|
||||
int allowBlockDevices = prefs != NULL ? prefs->allowBlockDevices : 0;
|
||||
assert(srcFileName != NULL);
|
||||
assert(statbuf != NULL);
|
||||
if (!strcmp (srcFileName, stdinmark)) {
|
||||
DISPLAYLEVEL(4,"Using stdin for input \n");
|
||||
SET_BINARY_MODE(stdin);
|
||||
return stdin;
|
||||
}
|
||||
|
||||
{ FILE* f = NULL;
|
||||
int const status = FIO_rust_openSrcFile(allowBlockDevices,
|
||||
srcFileName,
|
||||
statbuf,
|
||||
&f);
|
||||
if (status == FIO_RUST_OPEN_SRC_STDIN) {
|
||||
DISPLAYLEVEL(4,"Using stdin for input \n");
|
||||
SET_BINARY_MODE(stdin);
|
||||
return stdin;
|
||||
}
|
||||
|
||||
if (status == FIO_RUST_OPEN_SRC_STAT_FAILED) {
|
||||
DISPLAYLEVEL(1, "zstd: can't stat %s : %s -- ignored \n",
|
||||
srcFileName, strerror(errno));
|
||||
|
||||
Reference in New Issue
Block a user