Files
Aaru/DiscImageChef.Filesystems/AmigaDOS.cs
Natalia Portillo b2ab03407f * LICENSE.MIT:
* LICENSE.LGPL:
	  Added LICENSE files for LGPL and MIT licenses.

	* DiscImageChef.Devices/Enums.cs:
	* DiscImageChef.Partitions/MBR.cs:
	* DiscImageChef.Partitions/RDB.cs:
	* DiscImageChef.DiscImages/GDI.cs:
	* DiscImageChef.Partitions/Sun.cs:
	* DiscImageChef.DiscImages/VHD.cs:
	* DiscImageChef.Partitions/GPT.cs:
	* DiscImageChef.Filesystems/FFS.cs:
	* DiscImageChef.Filesystems/FAT.cs:
	* DiscImageChef.Partitions/NeXT.cs:
	* DiscImageChef.Devices/Command.cs:
	* DiscImageChef.DiscImages/Nero.cs:
	* DiscImageChef.Decoders/CD/PMA.cs:
	* DiscImageChef.Decoders/CD/TOC.cs:
	* DiscImageChef.Filesystems/BFS.cs:
	* DiscImageChef.Filesystems/ODS.cs:
	* DiscImageChef.Helpers/PrintHex.cs:
	* DiscImageChef.Helpers/Swapping.cs:
	* DiscImageChef.Decoders/DVD/PRI.cs:
	* DiscImageChef.Decoders/DVD/DMI.cs:
	* DiscImageChef.Decoders/DVD/DDS.cs:
	* DiscImageChef.Decoders/DVD/RMD.cs:
	* DiscImageChef.Decoders/DVD/UDI.cs:
	* DiscImageChef.Partitions/Atari.cs:
	* DiscImageChef.Decoders/DVD/BCA.cs:
	* DiscImageChef.Filesystems/SysV.cs:
	* DiscImageChef.Filesystems/HPFS.cs:
	* DiscImageChef.Filesystems/NTFS.cs:
	* DiscImageChef.Filesystems/APFS.cs:
	* DiscImageChef.Decoders/DVD/PFI.cs:
	* DiscImageChef.Decoders/CD/ATIP.cs:
	* DiscImageChef.Filesystems/Acorn.cs:
	* DiscImageChef.DiscImages/CDRWin.cs:
	* DiscImageChef.DiscImages/CDRDAO.cs:
	* DiscImageChef.Filesystems/BTRFS.cs:
	* DiscImageChef.Decoders/Xbox/DMI.cs:
	* DiscImageChef.Helpers/ArrayFill.cs:
	* DiscImageChef.Settings/Settings.cs:
	* DiscImageChef.Filesystems/Opera.cs:
	* DiscImageChef.Filesystems/extFS.cs:
	* DiscImageChef.Decoders/DVD/CPRM.cs:
	* DiscImageChef.Decoders/DVD/ADIP.cs:
	* DiscImageChef.Decoders/CD/Enums.cs:
	* DiscImageChef.Decoders/DVD/AACS.cs:
	* DiscImageChef.Decoders/SCSI/EVPD.cs:
	* DiscImageChef.Filesystems/ProDOS.cs:
	* DiscImageChef.Metadata/MediaType.cs:
	* DiscImageChef.Console/DicConsole.cs:
	* DiscImageChef.Decoders/DVD/Spare.cs:
	* DiscImageChef.Filesystems/ext2FS.cs:
	* DiscImageChef.Decoders/DVD/Enums.cs:
	* DiscImageChef.Filesystems/Symbian.cs:
	* DiscImageChef.Decoders/SCSI/Types.cs:
	* DiscImageChef.Filesystems/UNIXBFS.cs:
	* DiscImageChef.DiscImages/TeleDisk.cs:
	* DiscImageChef.Decoders/SCSI/Sense.cs:
	* DiscImageChef.Decoders/CD/FullTOC.cs:
	* DiscImageChef.Decoders/Blu-ray/DI.cs:
	* DiscImageChef.Decoders/ATA/Errors.cs:
	* DiscImageChef.Filesystems/ISO9660.cs:
	* DiscImageChef.Filesystems/MinixFS.cs:
	* DiscImageChef.Devices/Linux/Enums.cs:
	* DiscImageChef.Filesystems/SolarFS.cs:
	* DiscImageChef.Filesystems/Structs.cs:
	* DiscImageChef.DiscImages/Apple2MG.cs:
	* DiscImageChef.Decoders/SCSI/Modes.cs:
	* DiscImageChef.Metadata/Dimensions.cs:
	* DiscImageChef.Partitions/AppleMap.cs:
	* DiscImageChef.Decoders/Floppy/ISO.cs:
	* DiscImageChef.Decoders/DVD/Layers.cs:
	* DiscImageChef.Decoders/CD/Session.cs:
	* DiscImageChef.Decoders/SCSI/Enums.cs:
	* DiscImageChef.Filesystems/Nintendo.cs:
	* DiscImageChef.Helpers/DateHandlers.cs:
	* DiscImageChef.Filesystems/AmigaDOS.cs:
	* DiscImageChef.DiscImages/ImageInfo.cs:
	* DiscImageChef.Checksums/MD5Context.cs:
	* DiscImageChef.Devices/Linux/Extern.cs:
	* DiscImageChef.Filesystems/AppleHFS.cs:
	* DiscImageChef.Filesystems/AppleMFS.cs:
	* DiscImageChef.Helpers/ArrayIsEmpty.cs:
	* DiscImageChef.Decoders/Blu-ray/BCA.cs:
	* DiscImageChef.Decoders/Blu-ray/DDS.cs:
	* DiscImageChef.Filesystems/PCEngine.cs:
	* DiscImageChef.Decoders/ATA/Identify.cs:
	* DiscImageChef.Devices/Linux/Command.cs:
	* DiscImageChef.Devices/FreeBSD/Enums.cs:
	* DiscImageChef.Decoders/SCSI/Inquiry.cs:
	* DiscImageChef.Metadata/DeviceReport.cs:
	* DiscImageChef.Decoders/Floppy/Amiga.cs:
	* DiscImageChef.Devices/Linux/Structs.cs:
	* DiscImageChef.Devices/Windows/Enums.cs:
	* DiscImageChef.Decoders/DVD/CSS&CPRM.cs:
	* DiscImageChef.Checksums/SHA1Context.cs:
	* DiscImageChef.DiscImages/DiskCopy42.cs:
	* DiscImageChef.Partitions/PartPlugin.cs:
	* DiscImageChef.CommonTypes/Partition.cs:
	* DiscImageChef.Decoders/Floppy/Enums.cs:
	* DiscImageChef.CommonTypes/MediaType.cs:
	* DiscImageChef.Decoders/Floppy/Apple2.cs:
	* DiscImageChef.Devices/Windows/Extern.cs:
	* DiscImageChef.Decoders/SCSI/MMC/CPRM.cs:
	* DiscImageChef.Helpers/StringHandlers.cs:
	* DiscImageChef.DiscImages/ImagePlugin.cs:
	* DiscImageChef.Checksums/CRC64Context.cs:
	* DiscImageChef.Checksums/CRC32Context.cs:
	* DiscImageChef.DiscImages/ZZZRawImage.cs:
	* DiscImageChef.Checksums/CRC16Context.cs:
	* DiscImageChef.Filesystems/LisaFS/Dir.cs:
	* DiscImageChef.Decoders/DVD/Cartridge.cs:
	* DiscImageChef.Decoders/Blu-ray/Spare.cs:
	* DiscImageChef.Filesystems/Filesystem.cs:
	* DiscImageChef.Decoders/SCSI/MMC/AACS.cs:
	* DiscImageChef.Devices/FreeBSD/Extern.cs:
	* DiscImageChef.Devices/Device/Commands.cs:
	* DiscImageChef.Checksums/SHA384Context.cs:
	* DiscImageChef.Devices/FreeBSD/Command.cs:
	* DiscImageChef.Checksums/SHA512Context.cs:
	* DiscImageChef.Decoders/SCSI/MMC/Enums.cs:
	* DiscImageChef.Devices/Windows/Command.cs:
	* DiscImageChef.Devices/FreeBSD/Structs.cs:
	* DiscImageChef.Devices/Windows/Structs.cs:
	* DiscImageChef.Filesystems/LisaFS/Info.cs:
	* DiscImageChef.Checksums/SHA256Context.cs:
	* DiscImageChef.Filesystems/LisaFS/File.cs:
	* DiscImageChef.Filesystems/AppleHFSPlus.cs:
	* DiscImageChef.Filesystems/LisaFS/Super.cs:
	* DiscImageChef.Filesystems/LisaFS/Xattr.cs:
	* DiscImageChef.Checksums/Adler32Context.cs:
	* DiscImageChef.Decoders/Floppy/System34.cs:
	* DiscImageChef.Checksums/SpamSumContext.cs:
	* DiscImageChef.Decoders/SCSI/MMC/Hybrid.cs:
	* DiscImageChef.Devices/Device/Variables.cs:
	* DiscImageChef.Filesystems/LisaFS/Consts.cs:
	* DiscImageChef.Filesystems/LisaFS/LisaFS.cs:
	* DiscImageChef.Decoders/Floppy/Commodore.cs:
	* DiscImageChef.Checksums/FletcherContext.cs:
	* DiscImageChef.Filesystems/LisaFS/Extent.cs:
	* DiscImageChef.Devices/Device/Destructor.cs:
	* DiscImageChef.Decoders/Floppy/AppleSony.cs:
	* DiscImageChef.Filesystems/LisaFS/Structs.cs:
	* DiscImageChef.Decoders/SCSI/VendorString.cs:
	* DiscImageChef.Decoders/SCSI/MMC/Features.cs:
	* DiscImageChef.Devices/Device/Constructor.cs:
	* DiscImageChef.Checksums/RIPEMD160Context.cs:
	* DiscImageChef.Decoders/CD/CDTextOnLeadIn.cs:
	* DiscImageChef.Decoders/Blu-ray/Cartridge.cs:
	* DiscImageChef.Decoders/Floppy/System3740.cs:
	* DiscImageChef.Filesystems/LisaFS/Encoding.cs:
	* DiscImageChef.Decoders/SCSI/ModesEncoders.cs:
	* DiscImageChef.CommonTypes/MediaTypeFromSCSI.cs:
	* DiscImageChef.Helpers/BigEndianBitConverter.cs:
	* DiscImageChef.Decoders/Floppy/Perpendicular.cs:
	* DiscImageChef.Decoders/SCSI/SSC/BlockLimits.cs:
	* DiscImageChef.Decoders/SCSI/MMC/WriteProtect.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/HP.cs:
	* DiscImageChef.Devices/Device/AtaCommands/Cfa.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/NEC.cs:
	* DiscImageChef.Helpers/EndianAwareBinaryReader.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/MMC.cs:
	* DiscImageChef.Devices/Device/AtaCommands/MCPT.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/SSC.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/SPC.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/SMC.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/SBC.cs:
	* DiscImageChef.Metadata/Properties/AssemblyInfo.cs:
	* DiscImageChef.Devices/Device/AtaCommands/Atapi.cs:
	* DiscImageChef.Devices/Device/AtaCommands/Ata28.cs:
	* DiscImageChef.Devices/Device/AtaCommands/Smart.cs:
	* DiscImageChef.Decoders/SCSI/SSC/DensitySupport.cs:
	* DiscImageChef.Devices/Device/AtaCommands/Ata48.cs:
	* DiscImageChef.Decoders/SCSI/MMC/DiscInformation.cs:
	* DiscImageChef.Devices/Device/AtaCommands/AtaCHS.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/SyQuest.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/Plextor.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/Plasmon.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/Pioneer.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/Adaptec.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/Fujitsu.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/HL-DT-ST.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/Certance.cs:
	* DiscImageChef.Decoders/SCSI/DiscStructureCapabilities.cs:
	* DiscImageChef.Devices/Device/ScsiCommands/ArchiveCorp.cs:
	  Relicensed as LGPL.
	Updated standard header.

	* DiscImageChef/Main.cs:
	* DiscImageChef/Plugins.cs:
	* DiscImageChef/Options.cs:
	* DiscImageChef/Commands/Ls.cs:
	* DiscImageChef/Core/IBGLog.cs:
	* DiscImageChef/Core/MHDDLog.cs:
	* DiscImageChef/AssemblyInfo.cs:
	* DiscImageChef/Core/Checksum.cs:
	* DiscImageChef/Commands/Decode.cs:
	* DiscImageChef/Core/Statistics.cs:
	* DiscImageChef/Commands/Verify.cs:
	* DiscImageChef/Commands/Formats.cs:
	* DiscImageChef/Commands/Entropy.cs:
	* DiscImageChef/Commands/Compare.cs:
	* DiscImageChef.Interop/DetectOS.cs:
	* DiscImageChef/Commands/Analyze.cs:
	* DiscImageChef/Commands/Commands.cs:
	* DiscImageChef/Commands/PrintHex.cs:
	* DiscImageChef/Commands/Checksum.cs:
	* DiscImageChef/DetectImageFormat.cs:
	* DiscImageChef/Commands/DumpMedia.cs:
	* DiscImageChef/Commands/Benchmark.cs:
	* DiscImageChef/Commands/Configure.cs:
	* DiscImageChef/Commands/MediaInfo.cs:
	* DiscImageChef.Interop/PlatformID.cs:
	* DiscImageChef/Commands/MediaScan.cs:
	* DiscImageChef/Commands/Statistics.cs:
	* DiscImageChef/Commands/DeviceInfo.cs:
	* DiscImageChef.Checksums/ReedSolomon.cs:
	* DiscImageChef/Commands/DeviceReport.cs:
	* DiscImageChef/Commands/ExtractFiles.cs:
	* DiscImageChef.Checksums/CDChecksums.cs:
	* DiscImageChef/Commands/CreateSidecar.cs:
	  Updated standard header.

	* DiscImageChef.Checksums/DiscImageChef.Checksums.csproj:
	  Relicensed project as LGPL.
	Updated standard header.
	Embed license as resource.

	* DiscImageChef.Console/DiscImageChef.Console.csproj:
	* DiscImageChef.Devices/DiscImageChef.Devices.csproj:
	* DiscImageChef.Helpers/DiscImageChef.Helpers.csproj:
	* DiscImageChef.Settings/DiscImageChef.Settings.csproj:
	* DiscImageChef.Decoders/DiscImageChef.Decoders.csproj:
	* DiscImageChef.Metadata/DiscImageChef.Metadata.csproj:
	* DiscImageChef.Partitions/DiscImageChef.Partitions.csproj:
	* DiscImageChef.DiscImages/DiscImageChef.DiscImages.csproj:
	* DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj:
	* DiscImageChef.CommonTypes/DiscImageChef.CommonTypes.csproj:
	  Relicensed as LGPL.
	Updated standard header.
	Embed license as resource.

	* DiscImageChef/DiscImageChef.csproj:
	* DiscImageChef.Interop/DiscImageChef.Interop.csproj:
	  Updated standard header.
	Embed license as resource.
2016-07-28 18:13:49 +01:00

437 lines
19 KiB
C#

// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : AmigaDOS.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Amiga Fast File System plugin.
//
// --[ Description ] ----------------------------------------------------------
//
// Identifies the Amiga Fast File System and shows information.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2016 Natalia Portillo
// ****************************************************************************/
using System;
using System.Text;
using DiscImageChef;
using DiscImageChef.PartPlugins;
using System.Collections.Generic;
using DiscImageChef.Console;
namespace DiscImageChef.Filesystems
{
class AmigaDOSPlugin : Filesystem
{
public AmigaDOSPlugin()
{
Name = "Amiga DOS filesystem";
PluginUUID = new Guid("3c882400-208c-427d-a086-9119852a1bc7");
}
public AmigaDOSPlugin(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd)
{
Name = "Amiga DOS filesystem";
PluginUUID = new Guid("3c882400-208c-427d-a086-9119852a1bc7");
}
/// <summary>
/// Boot block, first 2 sectors
/// </summary>
struct BootBlock
{
/// <summary>
/// Offset 0x00, "DOSx" disk type
/// </summary>
public UInt32 diskType;
/// <summary>
/// Offset 0x04, Checksum
/// </summary>
public UInt32 checksum;
/// <summary>
/// Offset 0x08, Pointer to root block, mostly invalid
/// </summary>
public UInt32 root_ptr;
/// <summary>
/// Offset 0x0C, Boot code, til completion
/// </summary>
public byte[] bootCode;
}
struct RootBlock
{
/// <summary>
/// Offset 0x00, block type, value = T_HEADER (2)
/// </summary>
public UInt32 type;
/// <summary>
/// Offset 0x04, unused
/// </summary>
public UInt32 headerKey;
/// <summary>
/// Offset 0x08, unused
/// </summary>
public UInt32 highSeq;
/// <summary>
/// Offset 0x0C, longs used by hash table
/// </summary>
public UInt32 hashTableSize;
/// <summary>
/// Offset 0x10, unused
/// </summary>
public UInt32 firstData;
/// <summary>
/// Offset 0x14, Rootblock checksum
/// </summary>
public UInt32 checksum;
/// <summary>
/// Offset 0x18, Hashtable, size = (block size / 4) - 56 or size = hashTableSize
/// </summary>
public UInt32[] hashTable;
/// <summary>
/// Offset 0x18+hashTableSize*4+0, bitmap flag, 0xFFFFFFFF if valid
/// </summary>
public UInt32 bitmapFlag;
/// <summary>
/// Offset 0x18+hashTableSize*4+4, bitmap pages, 25 entries
/// </summary>
public UInt32[] bitmapPages;
/// <summary>
/// Offset 0x18+hashTableSize*4+104, pointer to bitmap extension block
/// </summary>
public UInt32 bitmapExtensionBlock;
/// <summary>
/// Offset 0x18+hashTableSize*4+108, last root alteration days since 1978/01/01
/// </summary>
public UInt32 rDays;
/// <summary>
/// Offset 0x18+hashTableSize*4+112, last root alteration minutes past midnight
/// </summary>
public UInt32 rMins;
/// <summary>
/// Offset 0x18+hashTableSize*4+116, last root alteration ticks (1/50 secs)
/// </summary>
public UInt32 rTicks;
/// <summary>
/// Offset 0x18+hashTableSize*4+120, disk name, pascal string, 32 bytes
/// </summary>
public string diskName;
/// <summary>
/// Offset 0x18+hashTableSize*4+152, unused
/// </summary>
public UInt32 reserved1;
/// <summary>
/// Offset 0x18+hashTableSize*4+156, unused
/// </summary>
public UInt32 reserved2;
/// <summary>
/// Offset 0x18+hashTableSize*4+160, last disk alteration days since 1978/01/01
/// </summary>
public UInt32 vDays;
/// <summary>
/// Offset 0x18+hashTableSize*4+164, last disk alteration minutes past midnight
/// </summary>
public UInt32 vMins;
/// <summary>
/// Offset 0x18+hashTableSize*4+168, last disk alteration ticks (1/50 secs)
/// </summary>
public UInt32 vTicks;
/// <summary>
/// Offset 0x18+hashTableSize*4+172, filesystem creation days since 1978/01/01
/// </summary>
public UInt32 cDays;
/// <summary>
/// Offset 0x18+hashTableSize*4+176, filesystem creation minutes since 1978/01/01
/// </summary>
public UInt32 cMins;
/// <summary>
/// Offset 0x18+hashTableSize*4+180, filesystem creation ticks since 1978/01/01
/// </summary>
public UInt32 cTicks;
/// <summary>
/// Offset 0x18+hashTableSize*4+184, unused
/// </summary>
public UInt32 nextHash;
/// <summary>
/// Offset 0x18+hashTableSize*4+188, unused
/// </summary>
public UInt32 parentDir;
/// <summary>
/// Offset 0x18+hashTableSize*4+192, first directory cache block
/// </summary>
public UInt32 extension;
/// <summary>
/// Offset 0x18+hashTableSize*4+196, block secondary type = ST_ROOT (1)
/// </summary>
public UInt32 sec_type;
}
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd)
{
if(partitionStart >= imagePlugin.GetSectors())
return false;
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
byte[] sector = imagePlugin.ReadSector(0 + partitionStart);
UInt32 magic = BigEndianBitConverter.ToUInt32(sector, 0x00);
if((magic & 0x6D754600) != 0x6D754600 &&
(magic & 0x444F5300) != 0x444F5300)
return false;
ulong root_ptr = BigEndianBitConverter.ToUInt32(sector, 0x08);
DicConsole.DebugWriteLine("AmigaDOS plugin", "Bootblock points to {0} as Rootblock", root_ptr);
root_ptr = (partitionEnd - partitionStart) / 2 + partitionStart + 1;
DicConsole.DebugWriteLine("AmigaDOS plugin", "Nonetheless, going to block {0} for Rootblock", root_ptr);
if(root_ptr >= imagePlugin.GetSectors())
return false;
sector = imagePlugin.ReadSector(root_ptr);
UInt32 type = BigEndianBitConverter.ToUInt32(sector, 0x00);
UInt32 hashTableSize = BigEndianBitConverter.ToUInt32(sector, 0x0C);
if((0x18 + hashTableSize * 4 + 196) > sector.Length)
return false;
UInt32 sec_type = BigEndianBitConverter.ToUInt32(sector, (int)(0x18 + hashTableSize * 4 + 196));
return type == 2 && sec_type == 1;
}
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, out string information)
{
StringBuilder sbInformation = new StringBuilder();
byte[] BootBlockSectors = imagePlugin.ReadSectors(0 + partitionStart, 2);
byte[] RootBlockSector = imagePlugin.ReadSector((partitionEnd - partitionStart) / 2 + partitionStart + 1);
byte[] diskName = new byte[32];
BootBlock bootBlk = new BootBlock();
RootBlock rootBlk = new RootBlock();
xmlFSType = new Schemas.FileSystemType();
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
bootBlk.diskType = BigEndianBitConverter.ToUInt32(BootBlockSectors, 0x00);
bootBlk.checksum = BigEndianBitConverter.ToUInt32(BootBlockSectors, 0x04);
bootBlk.root_ptr = BigEndianBitConverter.ToUInt32(BootBlockSectors, 0x08);
bootBlk.bootCode = new byte[BootBlockSectors.Length - 0x0C];
Array.Copy(BootBlockSectors, 0x0C, bootBlk.bootCode, 0, BootBlockSectors.Length - 0x0C);
DicConsole.DebugWriteLine("AmigaDOS plugin", "Stored boot blocks checksum is 0x{0:X8}", bootBlk.checksum);
DicConsole.DebugWriteLine("AmigaDOS plugin", "Probably incorrect calculated boot blocks checksum is 0x{0:X8}", AmigaChecksum(RootBlockSector));
Checksums.SHA1Context sha1Ctx = new Checksums.SHA1Context();
sha1Ctx.Init();
sha1Ctx.Update(bootBlk.bootCode);
DicConsole.DebugWriteLine("AmigaDOS plugin", "Boot code SHA1 is {0}", sha1Ctx.End());
rootBlk.type = BigEndianBitConverter.ToUInt32(RootBlockSector, 0x00);
rootBlk.headerKey = BigEndianBitConverter.ToUInt32(RootBlockSector, 0x04);
rootBlk.highSeq = BigEndianBitConverter.ToUInt32(RootBlockSector, 0x08);
rootBlk.hashTableSize = BigEndianBitConverter.ToUInt32(RootBlockSector, 0x0C);
rootBlk.firstData = BigEndianBitConverter.ToUInt32(RootBlockSector, 0x10);
rootBlk.checksum = BigEndianBitConverter.ToUInt32(RootBlockSector, 0x14);
rootBlk.hashTable = new uint[rootBlk.hashTableSize];
for(int i = 0; i < rootBlk.hashTableSize; i++)
rootBlk.hashTable[i] = BigEndianBitConverter.ToUInt32(RootBlockSector, 0x18 + i * 4);
rootBlk.bitmapFlag = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 0));
rootBlk.bitmapPages = new uint[25];
for(int i = 0; i < 25; i++)
rootBlk.bitmapPages[i] = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 4 + i * 4));
rootBlk.bitmapExtensionBlock = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 104));
rootBlk.rDays = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 108));
rootBlk.rMins = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 112));
rootBlk.rTicks = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 116));
Array.Copy(RootBlockSector, 0x18 + rootBlk.hashTableSize * 4 + 120, diskName, 0, 32);
rootBlk.diskName = StringHandlers.PascalToString(diskName);
rootBlk.reserved1 = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 152));
rootBlk.reserved2 = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 156));
rootBlk.vDays = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 160));
rootBlk.vMins = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 164));
rootBlk.vTicks = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 168));
rootBlk.cDays = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 172));
rootBlk.cMins = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 176));
rootBlk.cTicks = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 180));
rootBlk.nextHash = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 184));
rootBlk.parentDir = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 188));
rootBlk.extension = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 192));
rootBlk.sec_type = BigEndianBitConverter.ToUInt32(RootBlockSector, (int)(0x18 + rootBlk.hashTableSize * 4 + 196));
DicConsole.DebugWriteLine("AmigaDOS plugin", "Stored root block checksum is 0x{0:X8}", rootBlk.checksum);
DicConsole.DebugWriteLine("AmigaDOS plugin", "Probably incorrect calculated root block checksum is 0x{0:X8}", AmigaChecksum(RootBlockSector));
switch(bootBlk.diskType & 0xFF)
{
case 0:
sbInformation.Append("Amiga Original File System");
xmlFSType.Type = "Amiga OFS";
break;
case 1:
sbInformation.Append("Amiga Fast File System");
xmlFSType.Type = "Amiga FFS";
break;
case 2:
sbInformation.Append("Amiga Original File System with international characters");
xmlFSType.Type = "Amiga OFS";
break;
case 3:
sbInformation.Append("Amiga Fast File System with international characters");
xmlFSType.Type = "Amiga FFS";
break;
case 4:
sbInformation.Append("Amiga Original File System with directory cache");
xmlFSType.Type = "Amiga OFS";
break;
case 5:
sbInformation.Append("Amiga Fast File System with directory cache");
xmlFSType.Type = "Amiga FFS";
break;
case 6:
sbInformation.Append("Amiga Original File System with long filenames");
xmlFSType.Type = "Amiga OFS";
break;
case 7:
sbInformation.Append("Amiga Fast File System with long filenames");
xmlFSType.Type = "Amiga FFS";
break;
}
if((bootBlk.diskType & 0x6D754600) == 0x6D754600)
sbInformation.Append(", with multi-user patches");
sbInformation.AppendLine();
if((bootBlk.diskType & 0xFF) == 6 || (bootBlk.diskType & 0xFF) == 7)
{
sbInformation.AppendLine("AFFS v2, following information may be completely incorrect or garbage.");
xmlFSType.Type = "Amiga FFS2";
}
sbInformation.AppendFormat("Volume name: {0}", rootBlk.diskName).AppendLine();
if(rootBlk.bitmapFlag == 0xFFFFFFFF)
sbInformation.AppendLine("Volume bitmap is valid");
if(rootBlk.bitmapExtensionBlock != 0x00000000 && rootBlk.bitmapExtensionBlock != 0xFFFFFFFF)
sbInformation.AppendFormat("Bitmap extension at block {0}", rootBlk.bitmapExtensionBlock).AppendLine();
if((bootBlk.diskType & 0xFF) == 4 || (bootBlk.diskType & 0xFF) == 5)
sbInformation.AppendFormat("Directory cache starts at block {0}", rootBlk.extension).AppendLine();
sbInformation.AppendFormat("Volume created on {0}", DateHandlers.AmigaToDateTime(rootBlk.cDays, rootBlk.cMins, rootBlk.cTicks)).AppendLine();
sbInformation.AppendFormat("Volume last modified on {0}", DateHandlers.AmigaToDateTime(rootBlk.vDays, rootBlk.vMins, rootBlk.vTicks)).AppendLine();
sbInformation.AppendFormat("Volume root directory last modified on on {0}", DateHandlers.AmigaToDateTime(rootBlk.rDays, rootBlk.rMins, rootBlk.rTicks)).AppendLine();
information = sbInformation.ToString();
xmlFSType.CreationDate = DateHandlers.AmigaToDateTime(rootBlk.cDays, rootBlk.cMins, rootBlk.cTicks);
xmlFSType.CreationDateSpecified = true;
xmlFSType.ModificationDate = DateHandlers.AmigaToDateTime(rootBlk.vDays, rootBlk.vMins, rootBlk.vTicks);
xmlFSType.ModificationDateSpecified = true;
xmlFSType.Dirty = rootBlk.bitmapFlag != 0xFFFFFFFF;
xmlFSType.Clusters = (long)((partitionEnd - partitionStart) + 1);
xmlFSType.ClusterSize = (int)imagePlugin.GetSectorSize();
}
static UInt32 AmigaChecksum(byte[] data)
{
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
UInt32 sum = 0;
for(int i = 0; i < data.Length; i += 4)
sum += BigEndianBitConverter.ToUInt32(data, i);
return sum;
}
public override Errno Mount()
{
return Errno.NotImplemented;
}
public override Errno Mount(bool debug)
{
return Errno.NotImplemented;
}
public override Errno Unmount()
{
return Errno.NotImplemented;
}
public override Errno MapBlock(string path, long fileBlock, ref long deviceBlock)
{
return Errno.NotImplemented;
}
public override Errno GetAttributes(string path, ref FileAttributes attributes)
{
return Errno.NotImplemented;
}
public override Errno ListXAttr(string path, ref List<string> xattrs)
{
return Errno.NotImplemented;
}
public override Errno GetXattr(string path, string xattr, ref byte[] buf)
{
return Errno.NotImplemented;
}
public override Errno Read(string path, long offset, long size, ref byte[] buf)
{
return Errno.NotImplemented;
}
public override Errno ReadDir(string path, ref List<string> contents)
{
return Errno.NotImplemented;
}
public override Errno StatFs(ref FileSystemInfo stat)
{
return Errno.NotImplemented;
}
public override Errno Stat(string path, ref FileEntryInfo stat)
{
return Errno.NotImplemented;
}
public override Errno ReadLink(string path, ref string dest)
{
return Errno.NotImplemented;
}
}
}