[SonyPFS] Implement Identify.

This commit is contained in:
2026-04-13 11:08:13 +01:00
parent 8055a6c44a
commit 7232f8fbdb

View File

@@ -29,7 +29,9 @@
using System;
using System.Text;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.Helpers;
using Partition = Aaru.CommonTypes.Partition;
namespace Aaru.Filesystems;
@@ -37,7 +39,31 @@ namespace Aaru.Filesystems;
public partial class SonyPFS
{
/// <inheritdoc />
public bool Identify(IMediaImage imagePlugin, Partition partition) => throw new NotImplementedException();
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
uint sectorSize = imagePlugin.Info.SectorSize;
if(sectorSize < 512) return false;
// Superblock is at sector 0 relative to partition data start
int sbSize = Marshal.SizeOf<SuperBlock>();
var sectorsToRead = (uint)((sbSize + sectorSize - 1) / sectorSize);
ErrorNumber errno = imagePlugin.ReadSectors(partition.Start, false, sectorsToRead, out byte[] sector, out _);
if(errno != ErrorNumber.NoError) return false;
if(sector.Length < sbSize) return false;
SuperBlock sb = Marshal.ByteArrayToStructureLittleEndian<SuperBlock>(sector);
if(sb.magic != PFS_SUPER_MAGIC) return false;
if(sb.version > PFS_FORMAT_VERSION) return false;
return true;
}
/// <inheritdoc />
public void GetInformation(IMediaImage imagePlugin, Partition partition, Encoding encoding, out string information,