2017-08-25 03:02:55 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : RT11.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : RT-11 file system plugin.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Identifies the RT-11 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2018-12-29 17:34:38 +00:00
|
|
|
|
// Copyright © 2011-2019 Natalia Portillo
|
2017-08-25 03:02:55 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
using System.Text;
|
2017-12-27 21:57:07 +00:00
|
|
|
|
using Claunia.Encoding;
|
2017-08-25 03:02:55 +01:00
|
|
|
|
using DiscImageChef.CommonTypes;
|
2018-06-25 19:08:16 +01:00
|
|
|
|
using DiscImageChef.CommonTypes.Interfaces;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using Schemas;
|
2017-12-27 21:57:07 +00:00
|
|
|
|
using Encoding = System.Text.Encoding;
|
2019-03-01 07:35:22 +00:00
|
|
|
|
using Marshal = DiscImageChef.Helpers.Marshal;
|
2017-08-25 03:02:55 +01:00
|
|
|
|
|
|
|
|
|
|
namespace DiscImageChef.Filesystems
|
|
|
|
|
|
{
|
|
|
|
|
|
// Information from http://www.trailing-edge.com/~shoppa/rt11fs/
|
|
|
|
|
|
// TODO: Implement Radix-50
|
2017-12-26 06:05:12 +00:00
|
|
|
|
public class RT11 : IFilesystem
|
2017-08-25 03:02:55 +01:00
|
|
|
|
{
|
2017-12-26 08:01:40 +00:00
|
|
|
|
public FileSystemType XmlFsType { get; private set; }
|
2018-06-22 08:08:38 +01:00
|
|
|
|
public Encoding Encoding { get; private set; }
|
|
|
|
|
|
public string Name => "RT-11 file system";
|
|
|
|
|
|
public Guid Id => new Guid("DB3E2F98-8F98-463C-8126-E937843DA024");
|
2018-08-29 22:15:43 +01:00
|
|
|
|
public string Author => "Natalia Portillo";
|
2017-10-12 23:54:02 +01:00
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
2017-08-25 03:02:55 +01:00
|
|
|
|
{
|
2017-12-20 17:26:28 +00:00
|
|
|
|
if(1 + partition.Start >= partition.End) return false;
|
2017-08-25 03:02:55 +01:00
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
byte[] magicB = new byte[12];
|
2017-12-22 08:43:22 +00:00
|
|
|
|
byte[] hbSector = imagePlugin.ReadSector(1 + partition.Start);
|
2017-08-25 03:02:55 +01:00
|
|
|
|
|
2019-05-06 20:09:25 +01:00
|
|
|
|
if(hbSector.Length < 512) return false;
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
Array.Copy(hbSector, 0x1F0, magicB, 0, 12);
|
|
|
|
|
|
string magic = Encoding.ASCII.GetString(magicB);
|
2017-08-25 03:02:55 +01:00
|
|
|
|
|
|
|
|
|
|
return magic == "DECRT11A ";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 08:01:40 +00:00
|
|
|
|
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
|
2018-06-22 08:08:38 +01:00
|
|
|
|
Encoding encoding)
|
2017-08-25 03:02:55 +01:00
|
|
|
|
{
|
2018-06-22 08:08:38 +01:00
|
|
|
|
Encoding = new Radix50();
|
2017-08-25 03:02:55 +01:00
|
|
|
|
information = "";
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
byte[] hbSector = imagePlugin.ReadSector(1 + partition.Start);
|
2017-08-25 03:02:55 +01:00
|
|
|
|
|
2019-03-01 07:35:22 +00:00
|
|
|
|
RT11HomeBlock homeblock = Marshal.ByteArrayToStructureLittleEndian<RT11HomeBlock>(hbSector);
|
2017-08-25 03:02:55 +01:00
|
|
|
|
|
|
|
|
|
|
/* TODO: Is this correct?
|
|
|
|
|
|
* Assembler:
|
|
|
|
|
|
* MOV address, R0
|
|
|
|
|
|
* CLR R1
|
|
|
|
|
|
* MOV #255., R2
|
|
|
|
|
|
* 10$: ADD (R0)+, R1
|
|
|
|
|
|
* SOB R2, 10$
|
|
|
|
|
|
* MOV 1,@R0
|
|
|
|
|
|
*/
|
2018-06-22 08:08:38 +01:00
|
|
|
|
ushort check = 0;
|
2017-12-22 08:43:22 +00:00
|
|
|
|
for(int i = 0; i < 512; i += 2) check += BitConverter.ToUInt16(hbSector, i);
|
2017-08-25 03:02:55 +01:00
|
|
|
|
|
2017-12-27 21:57:07 +00:00
|
|
|
|
sb.AppendFormat("Volume format is {0}",
|
|
|
|
|
|
StringHandlers.SpacePaddedToString(homeblock.format, Encoding.ASCII)).AppendLine();
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sb.AppendFormat("{0} sectors per cluster ({1} bytes)", homeblock.cluster, homeblock.cluster * 512)
|
|
|
|
|
|
.AppendLine();
|
2017-08-25 03:02:55 +01:00
|
|
|
|
sb.AppendFormat("First directory segment starts at block {0}", homeblock.rootBlock).AppendLine();
|
2017-12-27 21:57:07 +00:00
|
|
|
|
sb.AppendFormat("Volume owner is \"{0}\"", Encoding.GetString(homeblock.ownername).TrimEnd()).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("Volume label: \"{0}\"", Encoding.GetString(homeblock.volname).TrimEnd()).AppendLine();
|
2017-08-25 03:02:55 +01:00
|
|
|
|
sb.AppendFormat("Checksum: 0x{0:X4} (calculated 0x{1:X4})", homeblock.checksum, check).AppendLine();
|
|
|
|
|
|
|
|
|
|
|
|
byte[] bootBlock = imagePlugin.ReadSector(0);
|
|
|
|
|
|
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType = new FileSystemType
|
2017-08-25 03:02:55 +01:00
|
|
|
|
{
|
2018-06-22 08:08:38 +01:00
|
|
|
|
Type = "RT-11",
|
2019-04-23 01:38:33 +01:00
|
|
|
|
ClusterSize = (uint)(homeblock.cluster * 512),
|
2018-06-22 08:08:38 +01:00
|
|
|
|
Clusters = homeblock.cluster,
|
|
|
|
|
|
VolumeName = StringHandlers.SpacePaddedToString(homeblock.volname, Encoding),
|
|
|
|
|
|
Bootable = !ArrayHelpers.ArrayIsNullOrEmpty(bootBlock)
|
2017-08-25 03:02:55 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
information = sb.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-24 02:37:41 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
struct RT11HomeBlock
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>Bad block replacement table</summary>
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 130)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] badBlockTable;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Unused</summary>
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] unused;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>INITIALIZE/RESTORE data area</summary>
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 38)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] initArea;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>BUP information area</summary>
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 18)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] bupInformation;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Empty</summary>
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 260)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] empty;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Reserved</summary>
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] reserved1;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Reserved</summary>
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] reserved2;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] empty2;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Cluster size</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort cluster;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Block of the first directory segment</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort rootBlock;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>"V3A" in Radix-50</summary>
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] systemVersion;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Name of the volume, 12 bytes</summary>
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] volname;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Name of the volume owner, 12 bytes</summary>
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] ownername;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>RT11 defines it as "DECRT11A ", 12 bytes</summary>
|
2018-06-22 08:08:38 +01:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] format;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Unused</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort unused2;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Checksum of preceding 255 words (16 bit units)</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort checksum;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
}
|
2017-08-25 03:02:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|