2017-07-19 16:31:08 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : SolarFS.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : SolarOS filesystem plugin.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Identifies the SolarOS filesystem 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2020-12-31 23:08:23 +00:00
|
|
|
|
// Copyright © 2011-2021 Natalia Portillo
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// ****************************************************************************/
|
2014-04-17 19:58:14 +00:00
|
|
|
|
|
2012-08-06 20:51:28 +00:00
|
|
|
|
using System;
|
2021-08-17 16:27:42 +01:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2017-07-19 16:31:08 +01:00
|
|
|
|
using System.Text;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes;
|
2021-09-19 21:16:47 +01:00
|
|
|
|
using Aaru.CommonTypes.Enums;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
|
|
|
|
|
using Aaru.Console;
|
2020-07-20 15:43:52 +01:00
|
|
|
|
using Aaru.Helpers;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using Schemas;
|
2015-10-18 22:04:03 +01:00
|
|
|
|
|
2020-02-27 00:33:26 +00:00
|
|
|
|
namespace Aaru.Filesystems
|
2012-08-06 20:51:28 +00:00
|
|
|
|
{
|
2016-07-28 22:25:26 +01:00
|
|
|
|
// Based on FAT's BPB, cannot find a FAT or directory
|
2021-08-17 14:25:12 +01:00
|
|
|
|
/// <inheritdoc />
|
2021-08-17 21:23:10 +01:00
|
|
|
|
/// <summary>Implements detection of the Solar OS filesystem</summary>
|
2020-07-22 13:20:25 +01:00
|
|
|
|
public sealed class SolarFS : IFilesystem
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2017-12-26 08:01:40 +00:00
|
|
|
|
public FileSystemType XmlFsType { get; private set; }
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2021-08-17 21:23:10 +01:00
|
|
|
|
public Encoding Encoding { get; private set; }
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2021-08-17 21:23:10 +01:00
|
|
|
|
public string Name => "Solar_OS filesystem";
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2021-09-19 21:16:47 +01:00
|
|
|
|
public Guid Id => new("EA3101C1-E777-4B4F-B5A3-8C57F50F6E65");
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2021-08-17 21:23:10 +01:00
|
|
|
|
public string Author => "Natalia Portillo";
|
2017-10-12 23:54:02 +01:00
|
|
|
|
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(2 + partition.Start >= partition.End)
|
|
|
|
|
|
return false;
|
2014-07-09 19:49:14 +01:00
|
|
|
|
|
2021-09-19 21:16:47 +01:00
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bpb);
|
|
|
|
|
|
|
|
|
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
|
return false;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
byte[] fsTypeB = new byte[8];
|
2012-08-06 20:51:28 +00:00
|
|
|
|
|
2018-06-20 22:22:21 +01:00
|
|
|
|
byte signature = bpb[0x25];
|
2017-12-22 08:43:22 +00:00
|
|
|
|
Array.Copy(bpb, 0x35, fsTypeB, 0, 8);
|
|
|
|
|
|
string fsType = StringHandlers.CToString(fsTypeB);
|
2014-04-14 02:29:13 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
return signature == 0x29 && fsType == "SOL_FS ";
|
2014-04-14 02:29:13 +00:00
|
|
|
|
}
|
2012-08-06 20:51:28 +00:00
|
|
|
|
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2017-12-26 08:01:40 +00:00
|
|
|
|
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Encoding encoding)
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2018-06-22 08:08:38 +01:00
|
|
|
|
Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15");
|
2014-04-14 02:29:13 +00:00
|
|
|
|
information = "";
|
2016-04-19 02:11:47 +01:00
|
|
|
|
|
2021-09-19 21:16:47 +01:00
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bpbSector);
|
|
|
|
|
|
|
|
|
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
|
return;
|
2017-12-22 08:43:22 +00:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
var bpb = new BiosParameterBlock
|
2017-12-22 08:43:22 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
bps = BitConverter.ToUInt16(bpbSector, 0x0B),
|
|
|
|
|
|
root_ent = BitConverter.ToUInt16(bpbSector, 0x10),
|
|
|
|
|
|
sectors = BitConverter.ToUInt16(bpbSector, 0x12),
|
|
|
|
|
|
media = bpbSector[0x14],
|
|
|
|
|
|
spfat = BitConverter.ToUInt16(bpbSector, 0x15),
|
|
|
|
|
|
sptrk = BitConverter.ToUInt16(bpbSector, 0x17),
|
|
|
|
|
|
heads = BitConverter.ToUInt16(bpbSector, 0x19),
|
|
|
|
|
|
signature = bpbSector[0x25]
|
2017-12-22 08:43:22 +00:00
|
|
|
|
};
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
byte[] bpbStrings = new byte[8];
|
|
|
|
|
|
Array.Copy(bpbSector, 0x03, bpbStrings, 0, 8);
|
|
|
|
|
|
bpb.OEMName = StringHandlers.CToString(bpbStrings);
|
2018-06-22 08:08:38 +01:00
|
|
|
|
bpbStrings = new byte[8];
|
2017-12-22 08:43:22 +00:00
|
|
|
|
Array.Copy(bpbSector, 0x2A, bpbStrings, 0, 11);
|
2017-12-26 08:01:40 +00:00
|
|
|
|
bpb.vol_name = StringHandlers.CToString(bpbStrings, Encoding);
|
2018-06-22 08:08:38 +01:00
|
|
|
|
bpbStrings = new byte[8];
|
2017-12-22 08:43:22 +00:00
|
|
|
|
Array.Copy(bpbSector, 0x35, bpbStrings, 0, 8);
|
2017-12-26 08:01:40 +00:00
|
|
|
|
bpb.fs_type = StringHandlers.CToString(bpbStrings, Encoding);
|
2017-12-22 08:43:22 +00:00
|
|
|
|
|
|
|
|
|
|
bpb.x86_jump = new byte[3];
|
|
|
|
|
|
Array.Copy(bpbSector, 0x00, bpb.x86_jump, 0, 3);
|
|
|
|
|
|
bpb.unk1 = bpbSector[0x0D];
|
|
|
|
|
|
bpb.unk2 = BitConverter.ToUInt16(bpbSector, 0x0E);
|
|
|
|
|
|
bpb.unk3 = new byte[10];
|
|
|
|
|
|
Array.Copy(bpbSector, 0x1B, bpb.unk3, 0, 10);
|
|
|
|
|
|
bpb.unk4 = BitConverter.ToUInt32(bpbSector, 0x26);
|
|
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.x86_jump: 0x{0:X2}{1:X2}{2:X2}", bpb.x86_jump[0],
|
2020-02-29 18:03:35 +00:00
|
|
|
|
bpb.x86_jump[1], bpb.x86_jump[2]);
|
|
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.OEMName: \"{0}\"", bpb.OEMName);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.bps: {0}", bpb.bps);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.unk1: 0x{0:X2}", bpb.unk1);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.unk2: 0x{0:X4}", bpb.unk2);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.root_ent: {0}", bpb.root_ent);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.sectors: {0}", bpb.sectors);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.media: 0x{0:X2}", bpb.media);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.spfat: {0}", bpb.spfat);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.sptrk: {0}", bpb.sptrk);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.heads: {0}", bpb.heads);
|
|
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
"BPB.unk3: 0x{0:X2}{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}{7:X2}{8:X2}{9:X2}",
|
|
|
|
|
|
bpb.unk3[0], bpb.unk3[1], bpb.unk3[2], bpb.unk3[3], bpb.unk3[4], bpb.unk3[5],
|
|
|
|
|
|
bpb.unk3[6], bpb.unk3[7], bpb.unk3[8], bpb.unk3[9]);
|
|
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.signature: 0x{0:X2}", bpb.signature);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.unk4: 0x{0:X8}", bpb.unk4);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.vol_name: \"{0}\"", bpb.vol_name);
|
|
|
|
|
|
AaruConsole.DebugWriteLine("SolarFS plugin", "BPB.fs_type: \"{0}\"", bpb.fs_type);
|
2012-08-06 20:51:28 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
sb.AppendLine("Solar_OS filesystem");
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("Media descriptor: 0x{0:X2}", bpb.media).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} bytes per sector", bpb.bps).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
if(imagePlugin.Info.SectorSize == 2336 ||
|
|
|
|
|
|
imagePlugin.Info.SectorSize == 2352 ||
|
2017-12-26 06:05:12 +00:00
|
|
|
|
imagePlugin.Info.SectorSize == 2448)
|
2014-04-14 01:14:20 +00:00
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(bpb.bps != imagePlugin.Info.SectorSize)
|
2020-02-29 18:03:35 +00:00
|
|
|
|
sb.
|
|
|
|
|
|
AppendFormat("WARNING: Filesystem describes a {0} bytes/sector, while device describes a {1} bytes/sector",
|
2018-06-22 08:08:38 +01:00
|
|
|
|
bpb.bps, 2048).AppendLine();
|
2014-04-14 01:14:20 +00:00
|
|
|
|
}
|
2017-12-26 06:05:12 +00:00
|
|
|
|
else if(bpb.bps != imagePlugin.Info.SectorSize)
|
2020-02-29 18:03:35 +00:00
|
|
|
|
sb.
|
|
|
|
|
|
AppendFormat("WARNING: Filesystem describes a {0} bytes/sector, while device describes a {1} bytes/sector",
|
2018-06-22 08:08:38 +01:00
|
|
|
|
bpb.bps, imagePlugin.Info.SectorSize).AppendLine();
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("{0} sectors on volume ({1} bytes)", bpb.sectors, bpb.sectors * bpb.bps).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(bpb.sectors > imagePlugin.Info.Sectors)
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sb.AppendFormat("WARNING: Filesystem describes a {0} sectors volume, bigger than device ({1} sectors)",
|
2017-12-26 06:05:12 +00:00
|
|
|
|
bpb.sectors, imagePlugin.Info.Sectors);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("{0} heads", bpb.heads).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} sectors per track", bpb.sptrk).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("Volume name: {0}", bpb.vol_name).AppendLine();
|
|
|
|
|
|
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType = new FileSystemType
|
2017-12-22 08:43:22 +00:00
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
Type = "SolarFS",
|
|
|
|
|
|
Clusters = bpb.sectors,
|
|
|
|
|
|
ClusterSize = bpb.bps,
|
|
|
|
|
|
VolumeName = bpb.vol_name
|
2017-12-22 08:43:22 +00:00
|
|
|
|
};
|
2015-12-05 17:10:27 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
information = sb.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-17 16:27:42 +01:00
|
|
|
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
2020-07-20 21:11:32 +01:00
|
|
|
|
struct BiosParameterBlock
|
2017-12-24 02:37:41 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>0x00, x86 jump (3 bytes), jumps to 0x60</summary>
|
|
|
|
|
|
public byte[] x86_jump;
|
|
|
|
|
|
/// <summary>0x03, 8 bytes, "SOLAR_OS"</summary>
|
|
|
|
|
|
public string OEMName;
|
|
|
|
|
|
/// <summary>0x0B, Bytes per sector</summary>
|
|
|
|
|
|
public ushort bps;
|
|
|
|
|
|
/// <summary>0x0D, unknown, 0x01</summary>
|
|
|
|
|
|
public byte unk1;
|
|
|
|
|
|
/// <summary>0x0E, unknown, 0x0201</summary>
|
|
|
|
|
|
public ushort unk2;
|
|
|
|
|
|
/// <summary>0x10, Number of entries on root directory ? (no root directory found)</summary>
|
|
|
|
|
|
public ushort root_ent;
|
|
|
|
|
|
/// <summary>0x12, Sectors in volume</summary>
|
|
|
|
|
|
public ushort sectors;
|
|
|
|
|
|
/// <summary>0x14, Media descriptor</summary>
|
|
|
|
|
|
public byte media;
|
|
|
|
|
|
/// <summary>0x15, Sectors per FAT ? (no FAT found)</summary>
|
|
|
|
|
|
public ushort spfat;
|
|
|
|
|
|
/// <summary>0x17, Sectors per track</summary>
|
|
|
|
|
|
public ushort sptrk;
|
|
|
|
|
|
/// <summary>0x19, Heads</summary>
|
|
|
|
|
|
public ushort heads;
|
|
|
|
|
|
/// <summary>0x1B, unknown, 10 bytes, zero-filled</summary>
|
|
|
|
|
|
public byte[] unk3;
|
|
|
|
|
|
/// <summary>0x25, 0x29</summary>
|
|
|
|
|
|
public byte signature;
|
|
|
|
|
|
/// <summary>0x26, unknown, zero-filled</summary>
|
|
|
|
|
|
public uint unk4;
|
|
|
|
|
|
/// <summary>0x2A, 11 bytes, volume name, space-padded</summary>
|
|
|
|
|
|
public string vol_name;
|
|
|
|
|
|
/// <summary>0x35, 8 bytes, "SOL_FS "</summary>
|
|
|
|
|
|
public string fs_type;
|
|
|
|
|
|
}
|
2014-04-14 02:29:13 +00:00
|
|
|
|
}
|
2014-04-14 01:14:20 +00:00
|
|
|
|
}
|