refactor(cli): move list status policy to Rust

Move the scalar InfoError-to-action mapping used by FIO_listFile into Rust and reuse the same classifier while aggregating multi-file list results. C retains file opening/parsing, exact diagnostics, metadata formatting, private fileInfo_t state, and the public result values; add layout and mapping coverage.

Test Plan: git diff --cached --check; focused Rust mapping test added; full capped verification will run after the MT and dictionary workers are integrated.
This commit is contained in:
2026-07-21 07:35:53 +02:00
parent 484a76757b
commit c522906d07
2 changed files with 95 additions and 8 deletions
+21 -7
View File
@@ -4743,6 +4743,18 @@ typedef enum {
info_truncated_input=4
} InfoError;
/* Rust owns the scalar --list file-status action policy. C keeps the exact
* diagnostics, metadata formatting, file I/O, and private fileInfo_t layout. */
enum {
FIO_RUST_LIST_FILE_ACTION_SUCCESS = 0,
FIO_RUST_LIST_FILE_ACTION_FRAME_ERROR = 1,
FIO_RUST_LIST_FILE_ACTION_NOT_ZSTD = 2,
FIO_RUST_LIST_FILE_ACTION_FILE_ERROR = 3,
FIO_RUST_LIST_FILE_ACTION_TRUNCATED_INPUT = 4,
FIO_RUST_LIST_FILE_ACTION_INVALID = 5
};
int FIO_rust_listFileStatusAction(int status);
/* Keep the private fileInfo_t layout in C. This projection contains only the
* fields needed by the --list total row and crosses the Rust policy boundary
* after FIO_listFile has finished its C-owned open/parse/display work. */
@@ -4943,24 +4955,25 @@ FIO_listFile(const char* inFileName, int displayLevel,
fileInfo_t info;
memset(&info, 0, sizeof(info));
{ InfoError const error = getFileInfo(&info, inFileName);
switch (error) {
case info_frame_error:
int const action = FIO_rust_listFileStatusAction((int)error);
switch (action) {
case FIO_RUST_LIST_FILE_ACTION_FRAME_ERROR:
/* display error, but provide output */
DISPLAYLEVEL(1, "Error while parsing \"%s\" \n", inFileName);
break;
case info_not_zstd:
case FIO_RUST_LIST_FILE_ACTION_NOT_ZSTD:
DISPLAYOUT("File \"%s\" not compressed by zstd \n", inFileName);
if (displayLevel > 2) DISPLAYOUT("\n");
return 1;
case info_file_error:
case FIO_RUST_LIST_FILE_ACTION_FILE_ERROR:
/* error occurred while opening the file */
if (displayLevel > 2) DISPLAYOUT("\n");
return 1;
case info_truncated_input:
case FIO_RUST_LIST_FILE_ACTION_TRUNCATED_INPUT:
DISPLAYOUT("File \"%s\" is truncated \n", inFileName);
if (displayLevel > 2) DISPLAYOUT("\n");
return 1;
case info_success:
case FIO_RUST_LIST_FILE_ACTION_SUCCESS:
default:
break;
}
@@ -4973,7 +4986,8 @@ FIO_listFile(const char* inFileName, int displayLevel,
output->decompUnavailable = info.decompUnavailable;
output->usesCheck = info.usesCheck;
output->nbFiles = info.nbFiles;
assert(error == info_success || error == info_frame_error);
assert(action == FIO_RUST_LIST_FILE_ACTION_SUCCESS
|| action == FIO_RUST_LIST_FILE_ACTION_FRAME_ERROR);
return (int)error;
}
}