multiple inconsistencies fixed (AI)
This commit is contained in:
@@ -97,26 +97,71 @@ export class EXTFilesystem extends BaseFilesystem {
|
||||
if (variantId !== 'ext') return;
|
||||
|
||||
const values = this.getInputValues(variantId);
|
||||
|
||||
// Validate input ranges specific to EXT filesystem
|
||||
const validation = this.validateFilesystemSpecific(variantId, values);
|
||||
if (!validation.valid) {
|
||||
console.warn('EXT validation errors:', validation.errors);
|
||||
// Continue with calculation but log warnings
|
||||
}
|
||||
|
||||
const results = {};
|
||||
|
||||
this.calculateEXT(values, results);
|
||||
}
|
||||
|
||||
validateFilesystemSpecific(variantId, values) {
|
||||
if (variantId !== 'ext') return { valid: true, errors: [] };
|
||||
|
||||
const errors = [];
|
||||
|
||||
// Validate blockgroup number doesn't exceed total blockgroups
|
||||
if (values.blockgroupNumberEXT !== undefined && values.totalBlocksEXT !== undefined && values.blocksPerGroupEXT !== undefined && values.blocksPerGroupEXT > 0) {
|
||||
const totalBlockgroups = Math.ceil(values.totalBlocksEXT / values.blocksPerGroupEXT);
|
||||
if (values.blockgroupNumberEXT >= totalBlockgroups) {
|
||||
errors.push(`blockgroupNumberEXT: ${values.blockgroupNumberEXT} >= Gesamtblockgruppen: ${totalBlockgroups}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Validate inode number isn't 0 (no inode 0 exists)
|
||||
if (values.targetInodeEXT !== undefined && values.targetInodeEXT === 0) {
|
||||
errors.push('targetInodeEXT: Inode 0 existiert nicht');
|
||||
}
|
||||
|
||||
// Validate block and inode sizes are reasonable
|
||||
if (values.blockSizeExpEXT !== undefined) {
|
||||
const blockSize = Math.pow(2, 10 + values.blockSizeExpEXT);
|
||||
if (blockSize < 1024 || blockSize > 65536) {
|
||||
errors.push(`Block-Größe: ${blockSize} außerhalb akzeptabeler Grenzen (1024-65536)`);
|
||||
}
|
||||
}
|
||||
|
||||
if (values.inodeSizeEXT !== undefined) {
|
||||
if (values.inodeSizeEXT < 128 || values.inodeSizeEXT > 4096) {
|
||||
errors.push(`Inode-Größe: ${values.inodeSizeEXT} außerhalb akzeptabeler Grenzen (128-4096)`);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
valid: errors.length === 0,
|
||||
errors: errors
|
||||
};
|
||||
}
|
||||
|
||||
calculateEXT(values, results) {
|
||||
try {
|
||||
// Superblock Position
|
||||
if (checkDependencies(['partitionStartEXT', 'superblockOffsetEXT'])) {
|
||||
results.superblockPos = values.partitionStartEXT + values.superblockOffsetEXT;
|
||||
updateResultItem('superblockPosEXT', results.superblockPos, true,
|
||||
`0x${values.partitionStartEXT.toString(16)} + 0x${values.superblockOffsetEXT.toString(16)} = 0x${results.superblockPos.toString(16)}`);
|
||||
updateResultItem('superblockPosEXT', { bytes: results.superblockPos, other: `Block 1 (bei 1024-Byte Blöcken)` }, true,
|
||||
`0x${Math.floor(values.partitionStartEXT).toString(16).toUpperCase()} + 0x${Math.floor(values.superblockOffsetEXT).toString(16).toUpperCase()} = 0x${Math.floor(results.superblockPos).toString(16).toUpperCase()}`);
|
||||
} else {
|
||||
updateResultItem('superblockPosEXT', 0, false);
|
||||
}
|
||||
|
||||
// Block Size (2^(10+n))
|
||||
} // Block Size (2^(10+n))
|
||||
if (checkDependencies(['blockSizeExpEXT'])) {
|
||||
results.blockSize = Math.pow(2, 10 + values.blockSizeExpEXT);
|
||||
updateResultItem('blockSizeBytesEXT', results.blockSize, true,
|
||||
`2^(10 + ${values.blockSizeExpEXT}) = 2^${10 + values.blockSizeExpEXT} = 0x${results.blockSize.toString(16)} (${results.blockSize} Bytes)`);
|
||||
updateResultItem('blockSizeBytesEXT', { bytes: results.blockSize, other: `2^${10 + values.blockSizeExpEXT}` }, true,
|
||||
`2^(10 + ${values.blockSizeExpEXT}) = 2^${10 + values.blockSizeExpEXT} = 0x${Math.floor(results.blockSize).toString(16).toUpperCase()} (${results.blockSize} Bytes)`);
|
||||
} else {
|
||||
updateResultItem('blockSizeBytesEXT', 0, false);
|
||||
}
|
||||
@@ -132,13 +177,18 @@ export class EXTFilesystem extends BaseFilesystem {
|
||||
|
||||
// GDT Start (block after superblock)
|
||||
if (checkDependencies(['partitionStartEXT', 'superblockOffsetEXT', 'blockSizeExpEXT']) && results.blockSize !== undefined) {
|
||||
// If block size is 1024 (0x400), superblock is in block 1, GDT starts at block 2
|
||||
// Otherwise, superblock is in block 0, GDT starts at block 1
|
||||
// Special handling for 1024-byte block size:
|
||||
// - Superblock is in block 1 (not block 0) because it starts at offset 0x400
|
||||
// - GDT follows in block 2
|
||||
// For other block sizes (2048, 4096, ...):
|
||||
// - Superblock is in block 0 (starts at offset 0)
|
||||
// - GDT follows in block 1
|
||||
const superblockBlock = (results.blockSize === 1024) ? 1 : 0;
|
||||
const gdtBlock = superblockBlock + 1;
|
||||
results.gdtStart = values.partitionStartEXT + (gdtBlock * results.blockSize);
|
||||
updateResultItem('gdtStartEXT', results.gdtStart, true,
|
||||
`0x${values.partitionStartEXT.toString(16)} + (Block ${gdtBlock} × 0x${results.blockSize.toString(16)}) = 0x${results.gdtStart.toString(16)}`);
|
||||
const gdtBlockNum = Math.floor(results.gdtStart / results.blockSize) - Math.floor(values.partitionStartEXT / results.blockSize);
|
||||
updateResultItem('gdtStartEXT', { bytes: results.gdtStart, other: `Block ${gdtBlock}` }, true,
|
||||
`0x${Math.floor(values.partitionStartEXT).toString(16).toUpperCase()} + (Block ${gdtBlock} × 0x${Math.floor(results.blockSize).toString(16).toUpperCase()}) = 0x${Math.floor(results.gdtStart).toString(16).toUpperCase()}`);
|
||||
} else {
|
||||
updateResultItem('gdtStartEXT', 0, false);
|
||||
}
|
||||
@@ -146,8 +196,8 @@ export class EXTFilesystem extends BaseFilesystem {
|
||||
// GDT Entry for specific Blockgroup
|
||||
if (checkDependencies(['blockgroupNumberEXT', 'groupDescSizeEXT']) && results.gdtStart !== undefined) {
|
||||
results.gdtBlockgroupOffset = results.gdtStart + (values.blockgroupNumberEXT * values.groupDescSizeEXT);
|
||||
updateResultItem('gdtBlockgroupOffsetEXT', results.gdtBlockgroupOffset, true,
|
||||
`0x${results.gdtStart.toString(16)} + (0x${values.blockgroupNumberEXT.toString(16)} × 0x${values.groupDescSizeEXT.toString(16)}) = 0x${results.gdtBlockgroupOffset.toString(16)}`);
|
||||
updateResultItem('gdtBlockgroupOffsetEXT', { bytes: results.gdtBlockgroupOffset, other: `Eintrag ${values.blockgroupNumberEXT}` }, true,
|
||||
`0x${Math.floor(results.gdtStart).toString(16).toUpperCase()} + (0x${Math.floor(values.blockgroupNumberEXT).toString(16).toUpperCase()} × 0x${Math.floor(values.groupDescSizeEXT).toString(16).toUpperCase()}) = 0x${Math.floor(results.gdtBlockgroupOffset).toString(16).toUpperCase()}`);
|
||||
} else {
|
||||
updateResultItem('gdtBlockgroupOffsetEXT', 0, false);
|
||||
}
|
||||
@@ -173,8 +223,8 @@ export class EXTFilesystem extends BaseFilesystem {
|
||||
// Inode Table Start
|
||||
if (checkDependencies(['partitionStartEXT', 'inodeTableBlockGroupEXT', 'blockSizeExpEXT']) && results.blockSize !== undefined) {
|
||||
results.inodeTableStart = values.partitionStartEXT + (values.inodeTableBlockGroupEXT * results.blockSize);
|
||||
updateResultItem('inodeTableStartEXT', results.inodeTableStart, true,
|
||||
`0x${values.partitionStartEXT.toString(16)} + (0x${values.inodeTableBlockGroupEXT.toString(16)} × 0x${results.blockSize.toString(16)}) = 0x${results.inodeTableStart.toString(16)}`);
|
||||
updateResultItem('inodeTableStartEXT', { bytes: results.inodeTableStart, other: `Block ${Math.floor(values.inodeTableBlockGroupEXT)}` }, true,
|
||||
`0x${Math.floor(values.partitionStartEXT).toString(16).toUpperCase()} + (0x${Math.floor(values.inodeTableBlockGroupEXT).toString(16).toUpperCase()} × 0x${Math.floor(results.blockSize).toString(16).toUpperCase()}) = 0x${Math.floor(results.inodeTableStart).toString(16).toUpperCase()}`);
|
||||
} else {
|
||||
updateResultItem('inodeTableStartEXT', 0, false);
|
||||
}
|
||||
@@ -182,8 +232,8 @@ export class EXTFilesystem extends BaseFilesystem {
|
||||
// Inode Offset
|
||||
if (checkDependencies(['targetInodeEXT', 'inodesPerGroupEXT', 'inodeSizeEXT']) && results.inodeTableStart !== undefined && results.inodeRelativeIndex !== undefined) {
|
||||
results.inodeOffset = results.inodeTableStart + (results.inodeRelativeIndex * values.inodeSizeEXT);
|
||||
updateResultItem('inodeOffsetEXT', results.inodeOffset, true,
|
||||
`0x${results.inodeTableStart.toString(16)} + (0x${results.inodeRelativeIndex.toString(16)} × 0x${values.inodeSizeEXT.toString(16)}) = 0x${results.inodeOffset.toString(16)}`);
|
||||
updateResultItem('inodeOffsetEXT', { bytes: results.inodeOffset, other: `Inode-Größe: 0x${Math.floor(values.inodeSizeEXT).toString(16).toUpperCase()}` }, true,
|
||||
`0x${Math.floor(results.inodeTableStart).toString(16).toUpperCase()} + (0x${Math.floor(results.inodeRelativeIndex).toString(16).toUpperCase()} × 0x${Math.floor(values.inodeSizeEXT).toString(16).toUpperCase()}) = 0x${Math.floor(results.inodeOffset).toString(16).toUpperCase()}`);
|
||||
} else {
|
||||
updateResultItem('inodeOffsetEXT', 0, false);
|
||||
}
|
||||
@@ -191,8 +241,8 @@ export class EXTFilesystem extends BaseFilesystem {
|
||||
// Block Offset
|
||||
if (checkDependencies(['partitionStartEXT', 'targetBlockEXT', 'blockSizeExpEXT']) && results.blockSize !== undefined) {
|
||||
results.blockOffset = values.partitionStartEXT + (values.targetBlockEXT * results.blockSize);
|
||||
updateResultItem('blockOffsetEXT', results.blockOffset, true,
|
||||
`0x${values.partitionStartEXT.toString(16)} + (0x${values.targetBlockEXT.toString(16)} × 0x${results.blockSize.toString(16)}) = 0x${results.blockOffset.toString(16)}`);
|
||||
updateResultItem('blockOffsetEXT', { bytes: results.blockOffset, other: `Block 0x${Math.floor(values.targetBlockEXT).toString(16).toUpperCase()}` }, true,
|
||||
`0x${Math.floor(values.partitionStartEXT).toString(16).toUpperCase()} + (0x${Math.floor(values.targetBlockEXT).toString(16).toUpperCase()} × 0x${Math.floor(results.blockSize).toString(16).toUpperCase()}) = 0x${Math.floor(results.blockOffset).toString(16).toUpperCase()}`);
|
||||
} else {
|
||||
updateResultItem('blockOffsetEXT', 0, false);
|
||||
}
|
||||
@@ -201,33 +251,33 @@ export class EXTFilesystem extends BaseFilesystem {
|
||||
if (results.inodeTableStart !== undefined && checkDependencies(['inodeSizeEXT'])) {
|
||||
// Inode 1 (Bad Blocks) - Index 0
|
||||
results.badBlocksInode = results.inodeTableStart + (0 * values.inodeSizeEXT);
|
||||
updateResultItem('badBlocksInodeEXT', results.badBlocksInode, true,
|
||||
`0x${results.inodeTableStart.toString(16)} + (0 × 0x${values.inodeSizeEXT.toString(16)}) = 0x${results.badBlocksInode.toString(16)}`);
|
||||
updateResultItem('badBlocksInodeEXT', { bytes: results.badBlocksInode, other: 'Inode 1 (Bad Blocks)' }, true,
|
||||
`0x${Math.floor(results.inodeTableStart).toString(16).toUpperCase()} + (0 × 0x${Math.floor(values.inodeSizeEXT).toString(16).toUpperCase()}) = 0x${Math.floor(results.badBlocksInode).toString(16).toUpperCase()}`);
|
||||
|
||||
// Inode 2 (Root Directory) - Index 1
|
||||
results.rootDirInode = results.inodeTableStart + (1 * values.inodeSizeEXT);
|
||||
updateResultItem('rootDirInodeEXT', results.rootDirInode, true,
|
||||
`0x${results.inodeTableStart.toString(16)} + (1 × 0x${values.inodeSizeEXT.toString(16)}) = 0x${results.rootDirInode.toString(16)}`);
|
||||
updateResultItem('rootDirInodeEXT', { bytes: results.rootDirInode, other: 'Inode 2 (Root Dir)' }, true,
|
||||
`0x${Math.floor(results.inodeTableStart).toString(16).toUpperCase()} + (1 × 0x${Math.floor(values.inodeSizeEXT).toString(16).toUpperCase()}) = 0x${Math.floor(results.rootDirInode).toString(16).toUpperCase()}`);
|
||||
|
||||
// Inode 3 (User Quotas) - Index 2
|
||||
results.userQuotaInode = results.inodeTableStart + (2 * values.inodeSizeEXT);
|
||||
updateResultItem('userQuotaInodeEXT', results.userQuotaInode, true,
|
||||
`0x${results.inodeTableStart.toString(16)} + (2 × 0x${values.inodeSizeEXT.toString(16)}) = 0x${results.userQuotaInode.toString(16)}`);
|
||||
updateResultItem('userQuotaInodeEXT', { bytes: results.userQuotaInode, other: 'Inode 3 (User Quota)' }, true,
|
||||
`0x${Math.floor(results.inodeTableStart).toString(16).toUpperCase()} + (2 × 0x${Math.floor(values.inodeSizeEXT).toString(16).toUpperCase()}) = 0x${Math.floor(results.userQuotaInode).toString(16).toUpperCase()}`);
|
||||
|
||||
// Inode 4 (Group Quotas) - Index 3
|
||||
results.groupQuotaInode = results.inodeTableStart + (3 * values.inodeSizeEXT);
|
||||
updateResultItem('groupQuotaInodeEXT', results.groupQuotaInode, true,
|
||||
`0x${results.inodeTableStart.toString(16)} + (3 × 0x${values.inodeSizeEXT.toString(16)}) = 0x${results.groupQuotaInode.toString(16)}`);
|
||||
updateResultItem('groupQuotaInodeEXT', { bytes: results.groupQuotaInode, other: 'Inode 4 (Group Quota)' }, true,
|
||||
`0x${Math.floor(results.inodeTableStart).toString(16).toUpperCase()} + (3 × 0x${Math.floor(values.inodeSizeEXT).toString(16).toUpperCase()}) = 0x${Math.floor(results.groupQuotaInode).toString(16).toUpperCase()}`);
|
||||
|
||||
// Inode 5 (Bootloader) - Index 4
|
||||
results.bootloaderInode = results.inodeTableStart + (4 * values.inodeSizeEXT);
|
||||
updateResultItem('bootloaderInodeEXT', results.bootloaderInode, true,
|
||||
`0x${results.inodeTableStart.toString(16)} + (4 × 0x${values.inodeSizeEXT.toString(16)}) = 0x${results.bootloaderInode.toString(16)}`);
|
||||
updateResultItem('bootloaderInodeEXT', { bytes: results.bootloaderInode, other: 'Inode 5 (Bootloader)' }, true,
|
||||
`0x${Math.floor(results.inodeTableStart).toString(16).toUpperCase()} + (4 × 0x${Math.floor(values.inodeSizeEXT).toString(16).toUpperCase()}) = 0x${Math.floor(results.bootloaderInode).toString(16).toUpperCase()}`);
|
||||
|
||||
// Inode 8 (Journal) - Index 7
|
||||
results.journalInode = results.inodeTableStart + (7 * values.inodeSizeEXT);
|
||||
updateResultItem('journalInodeEXT', results.journalInode, true,
|
||||
`0x${results.inodeTableStart.toString(16)} + (7 × 0x${values.inodeSizeEXT.toString(16)}) = 0x${results.journalInode.toString(16)}`);
|
||||
updateResultItem('journalInodeEXT', { bytes: results.journalInode, other: 'Inode 8 (Journal)' }, true,
|
||||
`0x${Math.floor(results.inodeTableStart).toString(16).toUpperCase()} + (7 × 0x${Math.floor(values.inodeSizeEXT).toString(16).toUpperCase()}) = 0x${Math.floor(results.journalInode).toString(16).toUpperCase()}`);
|
||||
} else {
|
||||
updateResultItem('badBlocksInodeEXT', 0, false);
|
||||
updateResultItem('rootDirInodeEXT', 0, false);
|
||||
@@ -240,8 +290,8 @@ export class EXTFilesystem extends BaseFilesystem {
|
||||
// Inode Table Size (Bytes)
|
||||
if (checkDependencies(['inodesPerGroupEXT', 'inodeSizeEXT'])) {
|
||||
results.inodeTableSize = values.inodesPerGroupEXT * values.inodeSizeEXT;
|
||||
updateResultItem('inodeTableSizeEXT', results.inodeTableSize, true,
|
||||
`0x${values.inodesPerGroupEXT.toString(16)} × 0x${values.inodeSizeEXT.toString(16)} = 0x${results.inodeTableSize.toString(16)} (${results.inodeTableSize} Bytes)`);
|
||||
updateResultItem('inodeTableSizeEXT', { bytes: results.inodeTableSize, other: `für 0x${Math.floor(values.inodesPerGroupEXT).toString(16).toUpperCase()} Inodes` }, true,
|
||||
`0x${Math.floor(values.inodesPerGroupEXT).toString(16).toUpperCase()} × 0x${Math.floor(values.inodeSizeEXT).toString(16).toUpperCase()} = 0x${Math.floor(results.inodeTableSize).toString(16).toUpperCase()} (${Math.floor(results.inodeTableSize)} Bytes)`);
|
||||
} else {
|
||||
updateResultItem('inodeTableSizeEXT', 0, false);
|
||||
}
|
||||
@@ -254,5 +304,12 @@ export class EXTFilesystem extends BaseFilesystem {
|
||||
} else {
|
||||
updateResultItem('inodeTableSizeBlocksEXT', 0, false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Fehler in EXT-Berechnung:', error);
|
||||
// Mark all results as unavailable on error
|
||||
updateResultItem('superblockPosEXT', 0, false);
|
||||
updateResultItem('blockSizeBytesEXT', 0, false);
|
||||
updateResultItem('totalBlockgroupsEXT', 0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user