mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Added support for U.C.S.D. Pascal filesystem, closes #31
This commit is contained in:
@@ -5,11 +5,11 @@
|
||||
// Filename : Info.cs
|
||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
||||
//
|
||||
// Component : Component
|
||||
// Component : U.C.S.D. Pascal filesystem plugin.
|
||||
//
|
||||
// --[ Description ] ----------------------------------------------------------
|
||||
//
|
||||
// Description
|
||||
// Identifies the U.C.S.D. Pascal filesystem and shows information.
|
||||
//
|
||||
// --[ License ] --------------------------------------------------------------
|
||||
//
|
||||
@@ -29,13 +29,133 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// Copyright © 2011-2016 Natalia Portillo
|
||||
// ****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DiscImageChef.Filesystems.UCSDPascal
|
||||
{
|
||||
public class Info
|
||||
// Information from Call-A.P.P.L.E. Pascal Disk Directory Structure
|
||||
public partial class PascalPlugin : Filesystem
|
||||
{
|
||||
public Info()
|
||||
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd)
|
||||
{
|
||||
if(imagePlugin.GetSectors() < 3)
|
||||
return false;
|
||||
|
||||
// Blocks 0 and 1 are boot code
|
||||
byte[] volBlock = imagePlugin.ReadSector(2 + partitionStart);
|
||||
|
||||
PascalVolumeEntry volEntry = new PascalVolumeEntry();
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
|
||||
volEntry.firstBlock = BigEndianBitConverter.ToInt16(volBlock, 0x00);
|
||||
volEntry.lastBlock = BigEndianBitConverter.ToInt16(volBlock, 0x02);
|
||||
volEntry.entryType = (PascalFileKind)BigEndianBitConverter.ToInt16(volBlock, 0x04);
|
||||
volEntry.volumeName = new byte[8];
|
||||
Array.Copy(volBlock, 0x06, volEntry.volumeName, 0, 8);
|
||||
volEntry.blocks = BigEndianBitConverter.ToInt16(volBlock, 0x0E);
|
||||
volEntry.files = BigEndianBitConverter.ToInt16(volBlock, 0x10);
|
||||
volEntry.dummy = BigEndianBitConverter.ToInt16(volBlock, 0x12);
|
||||
volEntry.lastBoot = BigEndianBitConverter.ToInt16(volBlock, 0x14);
|
||||
volEntry.tail = BigEndianBitConverter.ToInt32(volBlock, 0x16);
|
||||
|
||||
// First block is always 0 (even is it's sector 2)
|
||||
if(volEntry.firstBlock != 0)
|
||||
return false;
|
||||
|
||||
// Last volume record block must be after first block, and before end of device
|
||||
if(volEntry.lastBlock <= volEntry.firstBlock || (ulong)volEntry.lastBlock > imagePlugin.GetSectors() - 2)
|
||||
return false;
|
||||
|
||||
// Volume record entry type must be volume or secure
|
||||
if(volEntry.entryType != PascalFileKind.Volume && volEntry.entryType != PascalFileKind.Secure)
|
||||
return false;
|
||||
|
||||
// Volume name is max 7 characters
|
||||
if(volEntry.volumeName[0] > 7)
|
||||
return false;
|
||||
|
||||
// Volume blocks is equal to volume sectors
|
||||
if(volEntry.blocks < 0 || (ulong)volEntry.blocks != imagePlugin.GetSectors())
|
||||
return false;
|
||||
|
||||
// There can be not less than zero files
|
||||
if(volEntry.files < 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, ulong partitionStart, ulong partitionEnd, out string information)
|
||||
{
|
||||
StringBuilder sbInformation = new StringBuilder();
|
||||
information = "";
|
||||
|
||||
if(imagePlugin.GetSectors() < 3)
|
||||
return;
|
||||
|
||||
// Blocks 0 and 1 are boot code
|
||||
byte[] volBlock = imagePlugin.ReadSector(2 + partitionStart);
|
||||
|
||||
PascalVolumeEntry volEntry = new PascalVolumeEntry();
|
||||
|
||||
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
||||
|
||||
volEntry.firstBlock = BigEndianBitConverter.ToInt16(volBlock, 0x00);
|
||||
volEntry.lastBlock = BigEndianBitConverter.ToInt16(volBlock, 0x02);
|
||||
volEntry.entryType = (PascalFileKind)BigEndianBitConverter.ToInt16(volBlock, 0x04);
|
||||
volEntry.volumeName = new byte[8];
|
||||
Array.Copy(volBlock, 0x06, volEntry.volumeName, 0, 8);
|
||||
volEntry.blocks = BigEndianBitConverter.ToInt16(volBlock, 0x0E);
|
||||
volEntry.files = BigEndianBitConverter.ToInt16(volBlock, 0x10);
|
||||
volEntry.dummy = BigEndianBitConverter.ToInt16(volBlock, 0x12);
|
||||
volEntry.lastBoot = BigEndianBitConverter.ToInt16(volBlock, 0x14);
|
||||
volEntry.tail = BigEndianBitConverter.ToInt32(volBlock, 0x16);
|
||||
|
||||
// First block is always 0 (even is it's sector 2)
|
||||
if(volEntry.firstBlock != 0)
|
||||
return;
|
||||
|
||||
// Last volume record block must be after first block, and before end of device
|
||||
if(volEntry.lastBlock <= volEntry.firstBlock || (ulong)volEntry.lastBlock > imagePlugin.GetSectors() - 2)
|
||||
return;
|
||||
|
||||
// Volume record entry type must be volume or secure
|
||||
if(volEntry.entryType != PascalFileKind.Volume && volEntry.entryType != PascalFileKind.Secure)
|
||||
return;
|
||||
|
||||
// Volume name is max 7 characters
|
||||
if(volEntry.volumeName[0] > 7)
|
||||
return;
|
||||
|
||||
// Volume blocks is equal to volume sectors
|
||||
if(volEntry.blocks < 0 || (ulong)volEntry.blocks != imagePlugin.GetSectors())
|
||||
return;
|
||||
|
||||
// There can be not less than zero files
|
||||
if(volEntry.files < 0)
|
||||
return;
|
||||
|
||||
sbInformation.AppendFormat("Volume record spans from block {0} to block {1}", volEntry.firstBlock, volEntry.lastBlock).AppendLine();
|
||||
sbInformation.AppendFormat("Volume name: {0}", StringHandlers.PascalToString(volEntry.volumeName)).AppendLine();
|
||||
sbInformation.AppendFormat("Volume has {0} blocks", volEntry.blocks).AppendLine();
|
||||
sbInformation.AppendFormat("Volume has {0} files", volEntry.files).AppendLine();
|
||||
sbInformation.AppendFormat("Volume last booted at {0}", DateHandlers.UCSDPascalToDateTime(volEntry.lastBoot)).AppendLine();
|
||||
|
||||
information = sbInformation.ToString();
|
||||
|
||||
xmlFSType = new Schemas.FileSystemType();
|
||||
xmlFSType.Bootable = !ArrayHelpers.ArrayIsNullOrEmpty(imagePlugin.ReadSectors(partitionStart, 2));
|
||||
xmlFSType.Clusters = volEntry.blocks;
|
||||
xmlFSType.ClusterSize = (int)imagePlugin.GetSectorSize();
|
||||
xmlFSType.Files = volEntry.files;
|
||||
xmlFSType.FilesSpecified = true;
|
||||
xmlFSType.Type = "UCSD Pascal";
|
||||
xmlFSType.VolumeName = StringHandlers.PascalToString(volEntry.volumeName);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user