multiple inconsistencies fixed (AI)

This commit is contained in:
2025-12-07 20:12:48 +01:00
parent 95367b4d14
commit d38b4c7813
8 changed files with 283 additions and 50 deletions

View File

@@ -103,6 +103,13 @@ export class NTFSFilesystem extends BaseFilesystem {
calculate(variantId) {
const values = this.getInputValues(variantId);
// Validate input ranges
const validation = this.validateFilesystemSpecific(variantId, values);
if (!validation.valid) {
console.warn('NTFS validation errors:', validation.errors);
}
const results = {};
if (variantId === 'ntfs') {
@@ -110,6 +117,32 @@ export class NTFSFilesystem extends BaseFilesystem {
}
}
validateFilesystemSpecific(variantId, values) {
if (variantId !== 'ntfs') return { valid: true, errors: [] };
const errors = [];
// Validate cluster number is reasonable
if (values.clusterNumberNTFS !== undefined && values.partitionSizeSectorsNTFS !== undefined && values.sectorSizeNTFS !== undefined && values.clusterSizeSectorsNTFS !== undefined) {
const clusterSizeBytes = Math.pow(2, values.sectorSizeNTFS) * Math.pow(2, values.clusterSizeSectorsNTFS);
const partitionSizeBytes = values.partitionSizeSectorsNTFS * Math.pow(2, values.sectorSizeNTFS);
const maxClusters = partitionSizeBytes / clusterSizeBytes;
if (values.clusterNumberNTFS > maxClusters) {
errors.push(`clusterNumberNTFS: ${values.clusterNumberNTFS} > max ${Math.floor(maxClusters)}`);
}
}
// Validate MFT entry number is reasonable
if (values.mftEntryNumberNTFS !== undefined && values.mftEntryNumberNTFS < 0) {
errors.push('mftEntryNumberNTFS: MFT-Eintrag muss >= 0 sein');
}
return {
valid: errors.length === 0,
errors: errors
};
}
calculateMFTEntrySize(rawValue, clusterSizeBytes) {
// Special encoding from offset 0x40 and 0x44
// If positive (0x00-0x7F): size = value * cluster size