mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Separate Lisa tag decoding from Lisa filesystem and added
Priam tags.
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.ImagePlugins;
|
||||
using DiscImageChef.Decoders;
|
||||
|
||||
namespace DiscImageChef.Filesystems.LisaFS
|
||||
{
|
||||
@@ -174,10 +175,10 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
// If root catalog is not pointed in MDDF (unchecked) maybe it's always following S-Records File?
|
||||
for(ulong i = 0; i < device.GetSectors(); i++)
|
||||
{
|
||||
Tag catTag;
|
||||
LisaTag.PriamTag catTag;
|
||||
DecodeTag(device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out catTag);
|
||||
|
||||
if(catTag.fileID == FILEID_CATALOG && catTag.relBlock == 0)
|
||||
if(catTag.fileID == FILEID_CATALOG && catTag.relPage == 0)
|
||||
{
|
||||
firstCatalogBlock = device.ReadSectors(i, 4);
|
||||
break;
|
||||
@@ -194,7 +195,7 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
// Traverse double-linked list until first catalog block
|
||||
while(prevCatalogPointer != 0xFFFFFFFF)
|
||||
{
|
||||
Tag prevTag;
|
||||
LisaTag.PriamTag prevTag;
|
||||
DecodeTag(device.ReadSectorTag(prevCatalogPointer + mddf.mddf_block + volumePrefix, SectorTagType.AppleSectorTag), out prevTag);
|
||||
|
||||
if(prevTag.fileID != FILEID_CATALOG)
|
||||
@@ -213,7 +214,7 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
// Traverse double-linked list to read full catalog
|
||||
while(nextCatalogPointer != 0xFFFFFFFF)
|
||||
{
|
||||
Tag nextTag;
|
||||
LisaTag.PriamTag nextTag;
|
||||
DecodeTag(device.ReadSectorTag(nextCatalogPointer + mddf.mddf_block + volumePrefix, SectorTagType.AppleSectorTag), out nextTag);
|
||||
|
||||
if(nextTag.fileID != FILEID_CATALOG)
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
using System;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.ImagePlugins;
|
||||
using DiscImageChef.Decoders;
|
||||
|
||||
namespace DiscImageChef.Filesystems.LisaFS
|
||||
{
|
||||
@@ -76,7 +77,7 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
// Pointers are relative to MDDF
|
||||
ptr += mddf.mddf_block + volumePrefix;
|
||||
|
||||
Tag extTag;
|
||||
LisaTag.PriamTag extTag;
|
||||
|
||||
// This happens on some disks.
|
||||
// This is a filesystem corruption that makes LisaOS crash on scavenge.
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
using System;
|
||||
using DiscImageChef.ImagePlugins;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Decoders;
|
||||
|
||||
namespace DiscImageChef.Filesystems.LisaFS
|
||||
{
|
||||
@@ -212,7 +213,7 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
}
|
||||
}
|
||||
|
||||
Tag sysTag;
|
||||
LisaTag.PriamTag sysTag;
|
||||
|
||||
// Should be enough to check 100 sectors?
|
||||
for(ulong i = 0; i < 100; i++)
|
||||
@@ -247,9 +248,9 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
|
||||
// Relative block for $Loader starts at $Boot block
|
||||
if(sysTag.fileID == FILEID_LOADER_SIGNED)
|
||||
sysTag.relBlock--;
|
||||
sysTag.relPage--;
|
||||
|
||||
Array.Copy(sector, 0, buf, sector.Length * sysTag.relBlock, sector.Length);
|
||||
Array.Copy(sector, 0, buf, sector.Length * sysTag.relPage, sector.Length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Decoders;
|
||||
using DiscImageChef.ImagePlugins;
|
||||
|
||||
namespace DiscImageChef.Filesystems.LisaFS
|
||||
@@ -61,7 +62,7 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
// LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors
|
||||
for(int i = 0; i < 100; i++)
|
||||
{
|
||||
Tag searchTag;
|
||||
LisaTag.PriamTag searchTag;
|
||||
DecodeTag(imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag), out searchTag);
|
||||
|
||||
DicConsole.DebugWriteLine("LisaFS plugin", "Sector {0}, file ID 0x{1:X4}", i, searchTag.fileID);
|
||||
@@ -150,7 +151,7 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
// LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors
|
||||
for(int i = 0; i < 100; i++)
|
||||
{
|
||||
Tag searchTag;
|
||||
LisaTag.PriamTag searchTag;
|
||||
DecodeTag(imagePlugin.ReadSectorTag((ulong)i, SectorTagType.AppleSectorTag), out searchTag);
|
||||
|
||||
DicConsole.DebugWriteLine("LisaFS plugin", "Sector {0}, file ID 0x{1:X4}", i, searchTag.fileID);
|
||||
|
||||
@@ -207,48 +207,6 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
public byte scavenge_flag;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The sector tag. Before the sector is encoded to GCR the tag is attached to the data.
|
||||
/// Its size and format varies depending on device.
|
||||
/// Lisa OS relies on tags for scavenging a floppy, but ignores most of them for normal usage,
|
||||
/// except on hard disks where the checksum byte is absolutely enforced (a sector with an invalid
|
||||
/// one gives an OS error).
|
||||
/// </summary>
|
||||
struct Tag
|
||||
{
|
||||
/// <summary>0x00 version</summary>
|
||||
public ushort version;
|
||||
/// <summary>0x02 unknown</summary>
|
||||
public ushort unknown;
|
||||
/// <summary>0x04 File ID. Negative numbers are extents for the file with same absolute value number</summary>
|
||||
public short fileID;
|
||||
/// <summary>Only in 20 bytes tag at 0x06, mask 0x8000 if valid tag</summary>
|
||||
public ushort usedBytes;
|
||||
/// <summary>Only in 20 bytes tag at 0x08, 3 bytes</summary>
|
||||
public uint absoluteBlock;
|
||||
/// <summary>Only in 20 bytes tag at 0x0B, checksum byte</summary>
|
||||
public byte checksum;
|
||||
/// <summary>0x06 in 12 bytes tag, 0x0C in 20 bytes tag, relative block</summary>
|
||||
public ushort relBlock;
|
||||
/// <summary>
|
||||
/// Next block for this file.
|
||||
/// In 12 bytes tag at 0x08, 2 bytes, 0x8000 bit seems always set, 0x07FF means this is last block.
|
||||
/// In 20 bytes tag at 0x0E, 3 bytes, 0xFFFFFF means this is last block.
|
||||
/// </summary>
|
||||
public uint nextBlock;
|
||||
/// <summary>
|
||||
/// Previous block for this file.
|
||||
/// In 12 bytes tag at 0x0A, 2 bytes, 0x07FF means this is first block.
|
||||
/// In 20 bytes tag at 0x11, 3 bytes, 0xFFFFFF means this is first block.
|
||||
/// </summary>
|
||||
public uint prevBlock;
|
||||
|
||||
/// <summary>On-memory value for easy first block search.</summary>
|
||||
public bool isFirst;
|
||||
/// <summary>On-memory value for easy last block search.</summary>
|
||||
public bool isLast;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An entry in the catalog from V3.
|
||||
/// The first entry is bigger than the rest, may be a header, I have not needed any of its values so I just ignored it.
|
||||
|
||||
@@ -34,6 +34,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.ImagePlugins;
|
||||
using DiscImageChef.Decoders;
|
||||
|
||||
namespace DiscImageChef.Filesystems.LisaFS
|
||||
{
|
||||
@@ -80,7 +81,7 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
// LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors
|
||||
for(ulong i = 0; i < 100; i++)
|
||||
{
|
||||
Tag searchTag;
|
||||
LisaTag.PriamTag searchTag;
|
||||
DecodeTag(device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out searchTag);
|
||||
|
||||
DicConsole.DebugWriteLine("LisaFS plugin", "Sector {0}, file ID 0x{1:X4}", i, searchTag.fileID);
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DiscImageChef.Decoders;
|
||||
|
||||
namespace DiscImageChef.Filesystems.LisaFS
|
||||
{
|
||||
@@ -214,47 +215,15 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
/// <returns>Error number.</returns>
|
||||
/// <param name="tag">Sector tag.</param>
|
||||
/// <param name="decoded">Decoded sector tag.</param>
|
||||
Errno DecodeTag(byte[] tag, out Tag decoded)
|
||||
Errno DecodeTag(byte[] tag, out LisaTag.PriamTag decoded)
|
||||
{
|
||||
decoded = new Tag();
|
||||
decoded = new LisaTag.PriamTag();
|
||||
LisaTag.PriamTag? pmTag = LisaTag.DecodeTag(tag);
|
||||
|
||||
if(tag.Length == 12)
|
||||
{
|
||||
decoded.version = BigEndianBitConverter.ToUInt16(tag, 0x00);
|
||||
decoded.unknown = BigEndianBitConverter.ToUInt16(tag, 0x02);
|
||||
decoded.fileID = BigEndianBitConverter.ToInt16(tag, 0x04);
|
||||
decoded.relBlock = BigEndianBitConverter.ToUInt16(tag, 0x06);
|
||||
decoded.nextBlock = BigEndianBitConverter.ToUInt16(tag, 0x08);
|
||||
decoded.nextBlock &= 0x7FF;
|
||||
decoded.prevBlock = BigEndianBitConverter.ToUInt16(tag, 0x0A);
|
||||
decoded.prevBlock &= 0x7FF;
|
||||
|
||||
if(decoded.nextBlock == 0x7FF)
|
||||
decoded.isLast = true;
|
||||
if(decoded.prevBlock == 0x7FF)
|
||||
decoded.isFirst = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
decoded.version = BigEndianBitConverter.ToUInt16(tag, 0x00);
|
||||
decoded.unknown = BigEndianBitConverter.ToUInt16(tag, 0x02);
|
||||
decoded.fileID = BigEndianBitConverter.ToInt16(tag, 0x04);
|
||||
decoded.usedBytes = BigEndianBitConverter.ToUInt16(tag, 0x06);
|
||||
decoded.absoluteBlock = BigEndianBitConverter.ToUInt32(tag, 0x07);
|
||||
decoded.absoluteBlock &= 0xFFFFFF;
|
||||
decoded.checksum = tag[0x0B];
|
||||
decoded.relBlock = BigEndianBitConverter.ToUInt16(tag, 0x0C);
|
||||
decoded.nextBlock = BigEndianBitConverter.ToUInt32(tag, 0x0D);
|
||||
decoded.nextBlock &= 0xFFFFFF;
|
||||
decoded.prevBlock = BigEndianBitConverter.ToUInt32(tag, 0x10);
|
||||
decoded.prevBlock &= 0xFFFFFF;
|
||||
|
||||
if(decoded.nextBlock == 0xFFFFFF)
|
||||
decoded.isLast = true;
|
||||
if(decoded.prevBlock == 0xFFFFFF)
|
||||
decoded.isFirst = true;
|
||||
}
|
||||
if(!pmTag.HasValue)
|
||||
return Errno.InvalidArgument;
|
||||
|
||||
decoded = pmTag.Value;
|
||||
return Errno.NoError;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user