mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Reverse engineered S-Records, use them. They are a must for
V2.
This commit is contained in:
@@ -68,20 +68,44 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
if(extentCache.TryGetValue(fileId, out file))
|
||||
return Errno.NoError;
|
||||
|
||||
// If the file is found but not its extents file we should suppose it's a directory
|
||||
bool fileFound = false;
|
||||
if(fileId >= srecords.Length)
|
||||
return Errno.InvalidArgument;
|
||||
|
||||
ulong ptr = srecords[fileId].extent_ptr;
|
||||
|
||||
if(ptr == 0xFFFFFFFF || ptr == 0x00000000)
|
||||
return Errno.NoSuchFile;
|
||||
|
||||
ptr += mddf.mddf_block + volumePrefix;
|
||||
|
||||
for(ulong i = 0; i < device.GetSectors(); i++)
|
||||
{
|
||||
Tag extTag;
|
||||
DecodeTag(device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out extTag);
|
||||
|
||||
if(extTag.fileID == fileId)
|
||||
fileFound = true;
|
||||
// This happens on some disks.
|
||||
// This is a filesystem corruption that makes LisaOS crash on scavenge.
|
||||
// This code just allow to ignore that corruption
|
||||
if(ptr >= device.ImageInfo.sectors)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
for(ulong i = 0; i < device.ImageInfo.sectors; i++)
|
||||
{
|
||||
DecodeTag(device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out extTag);
|
||||
if(extTag.fileID == fileId * -1)
|
||||
{
|
||||
ptr = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!found)
|
||||
return Errno.InvalidArgument;
|
||||
}
|
||||
|
||||
DecodeTag(device.ReadSectorTag(ptr, SectorTagType.AppleSectorTag), out extTag);
|
||||
|
||||
if(extTag.fileID == ((short)(-1 * fileId)))
|
||||
{
|
||||
byte[] sector = device.ReadSector((ulong)i);
|
||||
byte[] sector = device.ReadSector(ptr);
|
||||
|
||||
if(sector[0] >= 32 || sector[0] == 0)
|
||||
return Errno.InvalidArgument;
|
||||
@@ -209,9 +233,29 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
|
||||
return Errno.NoError;
|
||||
}
|
||||
|
||||
return Errno.NoSuchFile;
|
||||
}
|
||||
|
||||
return fileFound ? Errno.IsDirectory : Errno.NoSuchFile;
|
||||
Errno ReadSRecords()
|
||||
{
|
||||
if(!mounted)
|
||||
return Errno.AccessDenied;
|
||||
|
||||
byte[] sectors = device.ReadSectors(mddf.srec_ptr + mddf.mddf_block + volumePrefix, mddf.srec_len);
|
||||
|
||||
srecords = new SRecord[sectors.Length / 14];
|
||||
|
||||
for(int s = 0; s < srecords.Length; s++)
|
||||
{
|
||||
srecords[s] = new SRecord();
|
||||
srecords[s].extent_ptr = BigEndianBitConverter.ToUInt32(sectors, 0x00 + 14 * s);
|
||||
srecords[s].unknown = BigEndianBitConverter.ToUInt32(sectors, 0x04 + 14 * s);
|
||||
srecords[s].filesize = BigEndianBitConverter.ToUInt32(sectors, 0x08 + 14 * s);
|
||||
srecords[s].flags = BigEndianBitConverter.ToUInt16(sectors, 0x0C + 14 * s);
|
||||
}
|
||||
|
||||
return Errno.NoError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,6 +204,21 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
|
||||
int count = 0;
|
||||
|
||||
if(fileId == FILEID_SRECORD)
|
||||
{
|
||||
if(!tags)
|
||||
{
|
||||
buf = device.ReadSectors(mddf.mddf_block + volumePrefix + mddf.srec_ptr, mddf.srec_len);
|
||||
systemFileCache.Add(fileId, buf);
|
||||
return Errno.NoError;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf = device.ReadSectorsTag(mddf.mddf_block + volumePrefix + mddf.srec_ptr, mddf.srec_len, SectorTagType.AppleSectorTag);
|
||||
return Errno.NoError;
|
||||
}
|
||||
}
|
||||
|
||||
Tag sysTag;
|
||||
|
||||
// Should be enough to check 100 sectors?
|
||||
@@ -353,7 +368,7 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
stat.DeviceNo = 0;
|
||||
int len;
|
||||
if(!fileSizeCache.TryGetValue(fileId, out len))
|
||||
stat.Length = file.length;
|
||||
stat.Length = srecords[fileId].filesize;
|
||||
else
|
||||
stat.Length = len;
|
||||
stat.BlockSize = mddf.datasize;
|
||||
|
||||
@@ -207,8 +207,9 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
mddf.clustersize = BigEndianBitConverter.ToUInt16(sector, 0x8A);
|
||||
mddf.fs_size = BigEndianBitConverter.ToUInt32(sector, 0x8C);
|
||||
mddf.unknown7 = BigEndianBitConverter.ToUInt32(sector, 0x90);
|
||||
mddf.unknown8 = BigEndianBitConverter.ToUInt32(sector, 0x94);
|
||||
mddf.unknown9 = BigEndianBitConverter.ToUInt32(sector, 0x98);
|
||||
mddf.srec_ptr = BigEndianBitConverter.ToUInt32(sector, 0x94);
|
||||
mddf.unknown9 = BigEndianBitConverter.ToUInt16(sector, 0x98);
|
||||
mddf.srec_len = BigEndianBitConverter.ToUInt16(sector, 0x9A);
|
||||
mddf.unknown10 = BigEndianBitConverter.ToUInt32(sector, 0x9C);
|
||||
mddf.unknown11 = BigEndianBitConverter.ToUInt32(sector, 0xA0);
|
||||
mddf.unknown12 = BigEndianBitConverter.ToUInt32(sector, 0xA4);
|
||||
@@ -259,8 +260,7 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown5 = 0x{0:X8} ({0})", mddf.unknown5);
|
||||
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown6 = 0x{0:X8} ({0})", mddf.unknown6);
|
||||
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown7 = 0x{0:X8} ({0})", mddf.unknown7);
|
||||
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown8 = 0x{0:X8} ({0})", mddf.unknown8);
|
||||
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown9 = 0x{0:X8} ({0})", mddf.unknown9);
|
||||
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown9 = 0x{0:X4} ({0})", mddf.unknown9);
|
||||
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown10 = 0x{0:X8} ({0})", mddf.unknown10);
|
||||
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown11 = 0x{0:X8} ({0})", mddf.unknown11);
|
||||
DicConsole.DebugWriteLine("LisaFS plugin", "mddf.unknown12 = 0x{0:X8} ({0})", mddf.unknown12);
|
||||
@@ -362,6 +362,7 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
sb.AppendFormat("Boot code: 0x{0:X8}", mddf.boot_code).AppendLine();
|
||||
sb.AppendFormat("Boot environment: 0x{0:X8}", mddf.boot_environ).AppendLine();
|
||||
sb.AppendFormat("Overmount stamp: 0x{0:X16}", mddf.overmount_stamp).AppendLine();
|
||||
sb.AppendFormat("S-Records start at {0} and spans for {1} blocks", mddf.srec_ptr + mddf.mddf_block + before_mddf, mddf.srec_len).AppendLine();
|
||||
|
||||
if(mddf.vol_left_mounted == 0)
|
||||
sb.AppendLine("Volume is clean");
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
MDDF mddf;
|
||||
ulong volumePrefix;
|
||||
int devTagSize;
|
||||
SRecord[] srecords;
|
||||
|
||||
#region Caches
|
||||
Dictionary<Int16, ExtentFile> extentCache;
|
||||
|
||||
@@ -94,10 +94,12 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
public UInt32 fs_size;
|
||||
/// <summary>0x90, unknown</summary>
|
||||
public UInt32 unknown7;
|
||||
/// <summary>0x94, unknown</summary>
|
||||
public UInt32 unknown8;
|
||||
/// <summary>0x94, Pointer to S-Records</summary>
|
||||
public UInt32 srec_ptr;
|
||||
/// <summary>0x98, unknown</summary>
|
||||
public UInt32 unknown9;
|
||||
public UInt16 unknown9;
|
||||
/// <summary>0x9A, S-Records length</summary>
|
||||
public UInt16 srec_len;
|
||||
/// <summary>0x9C, unknown</summary>
|
||||
public UInt32 unknown10;
|
||||
/// <summary>0xA0, unknown</summary>
|
||||
@@ -355,6 +357,18 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
/// <summary>0x180, 128 bytes</summary>
|
||||
public byte[] LisaInfo;
|
||||
}
|
||||
|
||||
struct SRecord
|
||||
{
|
||||
/// <summary>0x00, block where ExtentsFile for this entry resides</summary>
|
||||
public UInt32 extent_ptr;
|
||||
/// <summary>0x04, unknown</summary>
|
||||
public UInt32 unknown;
|
||||
/// <summary>0x08, filesize in bytes</summary>
|
||||
public UInt32 filesize;
|
||||
/// <summary>0x0C, some kind of flags, meaning unknown</summary>
|
||||
public UInt16 flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,8 +130,9 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
mddf.clustersize = BigEndianBitConverter.ToUInt16(sector, 0x8A);
|
||||
mddf.fs_size = BigEndianBitConverter.ToUInt32(sector, 0x8C);
|
||||
mddf.unknown7 = BigEndianBitConverter.ToUInt32(sector, 0x90);
|
||||
mddf.unknown8 = BigEndianBitConverter.ToUInt32(sector, 0x94);
|
||||
mddf.unknown9 = BigEndianBitConverter.ToUInt32(sector, 0x98);
|
||||
mddf.srec_ptr = BigEndianBitConverter.ToUInt32(sector, 0x94);
|
||||
mddf.unknown9 = BigEndianBitConverter.ToUInt16(sector, 0x98);
|
||||
mddf.srec_len = BigEndianBitConverter.ToUInt16(sector, 0x9A);
|
||||
mddf.unknown10 = BigEndianBitConverter.ToUInt32(sector, 0x9C);
|
||||
mddf.unknown11 = BigEndianBitConverter.ToUInt32(sector, 0xA0);
|
||||
mddf.unknown12 = BigEndianBitConverter.ToUInt32(sector, 0xA4);
|
||||
@@ -221,6 +222,13 @@ namespace DiscImageChef.Filesystems.LisaFS
|
||||
printedExtents = new List<short>();
|
||||
}
|
||||
|
||||
error = ReadSRecords();
|
||||
if(error != Errno.NoError)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Error {0} reading S-Records file.", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
List<CatalogEntry> tempCat;
|
||||
error = ReadCatalog((short)FILEID_DIRECTORY, out tempCat);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user