refactor(ntfs): derive MFT inventory metadata from its schema (#16677)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-04 17:27:32 +08:00
1 parent 4f01844c1f
commit e530718f7e
1 file changed
+5 -15
+5 -15
View File
@@ -12,6 +12,8 @@ import {
import { BinaryReader } from "../binaryContainer.js";
import { err, ok, type Result } from "../result.js";
import type { RegionDecodeFailure } from "../firmware/regionDecoder.js";
import type { ntfsMftMetadataSchema } from "../formatMetadata/androidAndSystemMetadata.js";
import type { ReadonlySchemaOutput } from "../formatMetadata/primitives.js";
/** An NTFS FILE record begins with this signature. */
const MFT_FILE_RECORD_MAGIC_BYTES = 4;
@@ -149,24 +151,12 @@ export interface MftIndex extends MftInventory {
readonly records: readonly MftRecordHeader[];
}
export interface MftMetadata {
readonly kind: "ntfs-mft";
readonly record_bytes: number;
readonly record_count: number;
readonly in_use_record_count: number;
readonly directory_record_count: number;
readonly extension_record_count: number;
readonly fixup_mismatch_count: number;
readonly fixup_unverified_record_count: number;
readonly truncated_tail_bytes: number;
export interface MftMetadata extends Required<
Omit<ReadonlySchemaOutput<typeof ntfsMftMetadataSchema>, "record_headers">
> {
readonly record_headers: readonly MftRecord[];
readonly omitted_record_headers: number;
readonly record_header_start_index: number;
readonly next_record_header_index: number | null;
/** These aggregate counts cover physical records, without double-counting linked attributes. */
readonly file_name_count: number;
readonly file_name_incomplete_record_count: number;
readonly attribute_incomplete_record_count: number;
}
const failure = (