2017-08-25 01:58:22 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2017-08-25 01:58:22 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
2022-12-07 13:07:31 +00:00
|
|
|
|
// Filename : Info.cs
|
2017-08-25 01:58:22 +01:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : Commodore file system plugin.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Identifies the AO-DOS file system 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-12-03 16:07:10 +00:00
|
|
|
|
// Copyright © 2011-2023 Natalia Portillo
|
2017-08-25 01:58:22 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
2017-12-19 19:33:46 +00:00
|
|
|
|
using System.Linq;
|
2017-08-25 01:58:22 +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;
|
2020-07-20 15:43:52 +01:00
|
|
|
|
using Aaru.Helpers;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using Partition = Aaru.CommonTypes.Partition;
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
namespace Aaru.Filesystems;
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// Information has been extracted looking at available disk images
|
|
|
|
|
|
// This may be missing fields, or not, I don't know russian so any help is appreciated
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
/// <summary>Implements detection of the AO-DOS filesystem</summary>
|
2022-12-07 13:07:31 +00:00
|
|
|
|
public sealed partial class AODOS
|
2017-08-25 01:58:22 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
2017-08-25 01:58:22 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// Does AO-DOS support hard disks?
|
|
|
|
|
|
if(partition.Start > 0)
|
|
|
|
|
|
return false;
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// How is it really?
|
|
|
|
|
|
if(imagePlugin.Info.SectorSize != 512)
|
|
|
|
|
|
return false;
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// Does AO-DOS support any other kind of disk?
|
|
|
|
|
|
if(imagePlugin.Info.Sectors != 800 &&
|
|
|
|
|
|
imagePlugin.Info.Sectors != 1600)
|
|
|
|
|
|
return false;
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] sector);
|
2021-09-19 21:16:47 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
|
return false;
|
2021-09-19 21:16:47 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
BootBlock bb = Marshal.ByteArrayToStructureLittleEndian<BootBlock>(sector);
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return bb.identifier.SequenceEqual(_identifier);
|
|
|
|
|
|
}
|
2017-08-25 01:58:22 +01: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
|
|
|
|
{
|
|
|
|
|
|
information = "";
|
2022-12-17 23:17:18 +00:00
|
|
|
|
encoding = Encoding.GetEncoding("koi8-r");
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(0, out byte[] sector);
|
2022-12-17 22:41:56 +00:00
|
|
|
|
metadata = new FileSystem();
|
2021-09-19 21:16:47 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
|
return;
|
2021-09-19 21:16:47 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
BootBlock bb = Marshal.ByteArrayToStructureLittleEndian<BootBlock>(sector);
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
var sbInformation = new StringBuilder();
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sbInformation.AppendLine(Localization.Alexander_Osipov_DOS_file_system);
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
2022-12-17 22:41:56 +00:00
|
|
|
|
metadata = new FileSystem
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Type = FS_TYPE,
|
|
|
|
|
|
Clusters = imagePlugin.Info.Sectors,
|
|
|
|
|
|
ClusterSize = imagePlugin.Info.SectorSize,
|
|
|
|
|
|
Files = bb.files,
|
|
|
|
|
|
FreeClusters = imagePlugin.Info.Sectors - bb.usedSectors,
|
2022-12-17 23:17:18 +00:00
|
|
|
|
VolumeName = StringHandlers.SpacePaddedToString(bb.volumeLabel, encoding),
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Bootable = true
|
2022-03-06 13:29:38 +00:00
|
|
|
|
};
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sbInformation.AppendFormat(Localization._0_files_on_volume, bb.files).AppendLine();
|
|
|
|
|
|
sbInformation.AppendFormat(Localization._0_used_sectors_on_volume, bb.usedSectors).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-12-17 23:17:18 +00:00
|
|
|
|
sbInformation.AppendFormat(Localization.Disk_name_0, StringHandlers.CToString(bb.volumeLabel, encoding)).
|
2022-11-28 02:59:53 +00:00
|
|
|
|
AppendLine();
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
information = sbInformation.ToString();
|
|
|
|
|
|
}
|
2017-08-25 01:58:22 +01:00
|
|
|
|
}
|