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
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
2022-12-07 13:07:31 +00:00
|
|
|
|
// Filename : Info.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : SolarOS filesystem plugin.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2024-12-19 10:45:18 +00:00
|
|
|
|
// Copyright © 2011-2025 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;
|
2017-07-19 16:31:08 +01:00
|
|
|
|
using System.Text;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using Aaru.CommonTypes.AaruMetadata;
|
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;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using Partition = Aaru.CommonTypes.Partition;
|
2015-10-18 22:04:03 +01:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
namespace Aaru.Filesystems;
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// Based on FAT's BPB, cannot find a FAT or directory
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
/// <summary>Implements detection of the Solar OS filesystem</summary>
|
2022-12-07 13:07:31 +00:00
|
|
|
|
public sealed partial class SolarFS
|
2012-08-06 20:51:28 +00:00
|
|
|
|
{
|
2023-10-03 23:22:08 +01:00
|
|
|
|
#region IFilesystem Members
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(2 + partition.Start >= partition.End) return false;
|
2014-07-09 19:49:14 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bpb);
|
2021-09-19 21:16:47 +01:00
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(errno != ErrorNumber.NoError) return false;
|
2014-04-14 01:14:20 +00:00
|
|
|
|
|
2023-10-03 23:22:08 +01:00
|
|
|
|
var fsTypeB = new byte[8];
|
2012-08-06 20:51:28 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
byte signature = bpb[0x25];
|
|
|
|
|
|
Array.Copy(bpb, 0x35, fsTypeB, 0, 8);
|
|
|
|
|
|
string fsType = StringHandlers.CToString(fsTypeB);
|
2014-04-14 02:29:13 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return signature == 0x29 && fsType == "SOL_FS ";
|
|
|
|
|
|
}
|
2012-08-06 20:51:28 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
2022-12-17 22:41:56 +00:00
|
|
|
|
public void GetInformation(IMediaImage imagePlugin, Partition partition, Encoding encoding, out string information,
|
|
|
|
|
|
out FileSystem metadata)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-12-17 23:17:18 +00:00
|
|
|
|
encoding ??= Encoding.GetEncoding("iso-8859-15");
|
|
|
|
|
|
information = "";
|
|
|
|
|
|
metadata = new FileSystem();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bpbSector);
|
|
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(errno != ErrorNumber.NoError) return;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
var bpb = new BiosParameterBlock
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00: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]
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2023-10-03 23:22:08 +01:00
|
|
|
|
var bpbStrings = new byte[8];
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Array.Copy(bpbSector, 0x03, bpbStrings, 0, 8);
|
|
|
|
|
|
bpb.OEMName = StringHandlers.CToString(bpbStrings);
|
|
|
|
|
|
bpbStrings = new byte[8];
|
|
|
|
|
|
Array.Copy(bpbSector, 0x2A, bpbStrings, 0, 11);
|
2022-12-17 23:17:18 +00:00
|
|
|
|
bpb.vol_name = StringHandlers.CToString(bpbStrings, encoding);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
bpbStrings = new byte[8];
|
|
|
|
|
|
Array.Copy(bpbSector, 0x35, bpbStrings, 0, 8);
|
2022-12-17 23:17:18 +00:00
|
|
|
|
bpb.fs_type = StringHandlers.CToString(bpbStrings, encoding);
|
2022-03-06 13:29:38 +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);
|
|
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME,
|
|
|
|
|
|
"BPB.x86_jump: 0x{0:X2}{1:X2}{2:X2}",
|
|
|
|
|
|
bpb.x86_jump[0],
|
|
|
|
|
|
bpb.x86_jump[1],
|
2023-10-04 17:34:40 +01:00
|
|
|
|
bpb.x86_jump[2]);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2023-10-03 17:47:32 +01:00
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.OEMName: \"{0}\"", bpb.OEMName);
|
2023-10-03 23:22:08 +01:00
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.bps: {0}", bpb.bps);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.unk1: 0x{0:X2}", bpb.unk1);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.unk2: 0x{0:X4}", bpb.unk2);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.root_ent: {0}", bpb.root_ent);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.sectors: {0}", bpb.sectors);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.media: 0x{0:X2}", bpb.media);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.spfat: {0}", bpb.spfat);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.sptrk: {0}", bpb.sptrk);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.heads: {0}", bpb.heads);
|
2023-10-03 17:47:32 +01:00
|
|
|
|
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME,
|
2022-03-06 13:29:38 +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}",
|
2024-05-01 04:05:22 +01:00
|
|
|
|
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]);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2023-10-03 17:47:32 +01:00
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.signature: 0x{0:X2}", bpb.signature);
|
2023-10-03 23:22:08 +01:00
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.unk4: 0x{0:X8}", bpb.unk4);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.vol_name: \"{0}\"", bpb.vol_name);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "BPB.fs_type: \"{0}\"", bpb.fs_type);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Solar_OS_filesystem);
|
2023-10-03 23:22:08 +01:00
|
|
|
|
sb.AppendFormat(Localization.Media_descriptor_0, bpb.media).AppendLine();
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendFormat(Localization._0_bytes_per_sector, bpb.bps).AppendLine();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-03-16 11:47:00 +00:00
|
|
|
|
if(imagePlugin.Info.SectorSize is 2336 or 2352 or 2448)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
if(bpb.bps != imagePlugin.Info.SectorSize)
|
2023-10-03 23:22:08 +01:00
|
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
|
sb.AppendFormat(Localization
|
|
|
|
|
|
.WARNING_Filesystem_describes_a_0_bytes_sector_while_device_describes_a_1_bytes_sector,
|
|
|
|
|
|
bpb.bps,
|
|
|
|
|
|
2048)
|
|
|
|
|
|
.AppendLine();
|
2023-10-03 23:22:08 +01:00
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
else if(bpb.bps != imagePlugin.Info.SectorSize)
|
2023-10-03 23:22:08 +01:00
|
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
|
sb.AppendFormat(Localization
|
|
|
|
|
|
.WARNING_Filesystem_describes_a_0_bytes_sector_while_device_describes_a_1_bytes_sector,
|
|
|
|
|
|
bpb.bps,
|
|
|
|
|
|
imagePlugin.Info.SectorSize)
|
|
|
|
|
|
.AppendLine();
|
2023-10-03 23:22:08 +01:00
|
|
|
|
}
|
2018-06-22 08:08:38 +01:00
|
|
|
|
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, bpb.sectors, bpb.sectors * bpb.bps).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(bpb.sectors > imagePlugin.Info.Sectors)
|
2023-10-03 23:22:08 +01:00
|
|
|
|
{
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendFormat(Localization.WARNING_Filesystem_describes_a_0_sectors_volume_bigger_than_device_1_sectors,
|
2024-05-01 04:05:22 +01:00
|
|
|
|
bpb.sectors,
|
|
|
|
|
|
imagePlugin.Info.Sectors);
|
2023-10-03 23:22:08 +01:00
|
|
|
|
}
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2023-10-03 23:22:08 +01:00
|
|
|
|
sb.AppendFormat(Localization._0_heads, bpb.heads).AppendLine();
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendFormat(Localization._0_sectors_per_track, bpb.sptrk).AppendLine();
|
2023-10-03 23:22:08 +01:00
|
|
|
|
sb.AppendFormat(Localization.Volume_name_0, bpb.vol_name).AppendLine();
|
2017-12-22 08:43:22 +00:00
|
|
|
|
|
2022-12-17 22:41:56 +00:00
|
|
|
|
metadata = new FileSystem
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-11-28 02:59:53 +00:00
|
|
|
|
Type = FS_TYPE,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Clusters = bpb.sectors,
|
|
|
|
|
|
ClusterSize = bpb.bps,
|
|
|
|
|
|
VolumeName = bpb.vol_name
|
|
|
|
|
|
};
|
2015-12-05 17:10:27 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
information = sb.ToString();
|
|
|
|
|
|
}
|
2023-10-03 23:22:08 +01:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
2014-04-14 01:14:20 +00:00
|
|
|
|
}
|