2017-08-25 01:58:22 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : AODOS.cs
|
|
|
|
|
|
// 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2017-08-25 01:58:22 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2017-12-19 19:33:46 +00:00
|
|
|
|
using System.Linq;
|
2017-08-25 01:58:22 +01:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using DiscImageChef.CommonTypes;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using DiscImageChef.DiscImages;
|
|
|
|
|
|
using Schemas;
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
|
|
|
|
|
namespace DiscImageChef.Filesystems
|
|
|
|
|
|
{
|
|
|
|
|
|
// 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
|
2017-12-26 06:05:12 +00:00
|
|
|
|
public class AODOS : IFilesystem
|
2017-08-25 01:58:22 +01:00
|
|
|
|
{
|
2017-12-24 02:37:41 +00:00
|
|
|
|
readonly byte[] AODOSIdentifier = {0x20, 0x41, 0x4F, 0x2D, 0x44, 0x4F, 0x53, 0x20};
|
2017-12-26 06:05:12 +00:00
|
|
|
|
Encoding currentEncoding;
|
|
|
|
|
|
FileSystemType xmlFsType;
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public FileSystemType XmlFsType => xmlFsType;
|
|
|
|
|
|
public string Name => "Alexander Osipov DOS file system";
|
|
|
|
|
|
public Guid Id => new Guid("668E5039-9DDD-442A-BE1B-A315D6E38E26");
|
|
|
|
|
|
public Encoding Encoding => currentEncoding;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
2017-08-25 01:58:22 +01:00
|
|
|
|
{
|
|
|
|
|
|
// Does AO-DOS support hard disks?
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(partition.Start > 0) return false;
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
|
|
|
|
|
// How is it really?
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(imagePlugin.Info.SectorSize != 512) return false;
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
|
|
|
|
|
// Does AO-DOS support any other kind of disk?
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(imagePlugin.Info.Sectors != 800 && imagePlugin.Info.Sectors != 1600) return false;
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
byte[] sector = imagePlugin.ReadSector(0);
|
2017-08-25 01:58:22 +01:00
|
|
|
|
AODOS_BootBlock bb = new AODOS_BootBlock();
|
|
|
|
|
|
IntPtr bbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(bb));
|
|
|
|
|
|
Marshal.Copy(sector, 0, bbPtr, Marshal.SizeOf(bb));
|
|
|
|
|
|
bb = (AODOS_BootBlock)Marshal.PtrToStructure(bbPtr, typeof(AODOS_BootBlock));
|
|
|
|
|
|
Marshal.FreeHGlobal(bbPtr);
|
|
|
|
|
|
|
|
|
|
|
|
return bb.identifier.SequenceEqual(AODOSIdentifier);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding)
|
2017-08-25 01:58:22 +01:00
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
|
currentEncoding = Encoding.GetEncoding("koi8-r");
|
2017-12-22 08:43:22 +00:00
|
|
|
|
byte[] sector = imagePlugin.ReadSector(0);
|
2017-08-25 01:58:22 +01:00
|
|
|
|
AODOS_BootBlock bb = new AODOS_BootBlock();
|
|
|
|
|
|
IntPtr bbPtr = Marshal.AllocHGlobal(Marshal.SizeOf(bb));
|
|
|
|
|
|
Marshal.Copy(sector, 0, bbPtr, Marshal.SizeOf(bb));
|
|
|
|
|
|
bb = (AODOS_BootBlock)Marshal.PtrToStructure(bbPtr, typeof(AODOS_BootBlock));
|
|
|
|
|
|
Marshal.FreeHGlobal(bbPtr);
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder sbInformation = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
sbInformation.AppendLine("Alexander Osipov DOS file system");
|
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
xmlFsType = new FileSystemType
|
2017-08-25 01:58:22 +01:00
|
|
|
|
{
|
|
|
|
|
|
Type = "Alexander Osipov DOS file system",
|
2017-12-26 06:05:12 +00:00
|
|
|
|
Clusters = (long)imagePlugin.Info.Sectors,
|
|
|
|
|
|
ClusterSize = (int)imagePlugin.Info.SectorSize,
|
2017-08-25 01:58:22 +01:00
|
|
|
|
Files = bb.files,
|
|
|
|
|
|
FilesSpecified = true,
|
2017-12-26 06:05:12 +00:00
|
|
|
|
FreeClusters = (long)(imagePlugin.Info.Sectors - bb.usedSectors),
|
2017-08-25 01:58:22 +01:00
|
|
|
|
FreeClustersSpecified = true,
|
2017-12-26 06:05:12 +00:00
|
|
|
|
VolumeName = StringHandlers.SpacePaddedToString(bb.volumeLabel, currentEncoding),
|
2017-08-25 01:58:22 +01:00
|
|
|
|
Bootable = true
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
sbInformation.AppendFormat("{0} files on volume", bb.files).AppendLine();
|
|
|
|
|
|
sbInformation.AppendFormat("{0} used sectors on volume", bb.usedSectors).AppendLine();
|
2017-12-26 06:05:12 +00:00
|
|
|
|
sbInformation.AppendFormat("Disk name: {0}", StringHandlers.CToString(bb.volumeLabel, currentEncoding))
|
2017-12-19 20:33:03 +00:00
|
|
|
|
.AppendLine();
|
2017-08-25 01:58:22 +01:00
|
|
|
|
|
|
|
|
|
|
information = sbInformation.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-24 02:37:41 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
struct AODOS_BootBlock
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A NOP opcode
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public byte nop;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A branch to real bootloader
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ushort branch;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Unused
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public byte unused;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// " AO-DOS "
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] public byte[] identifier;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Volume label
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] public byte[] volumeLabel;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// How many files are present in disk
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ushort files;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// How many sectors are used
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public ushort usedSectors;
|
|
|
|
|
|
}
|
2017-08-25 01:58:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|