2017-08-16 15:44:50 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2017-08-16 15:44:50 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : RBF.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : Random Block File filesystem plugin
|
2017-08-16 15:44:50 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Identifies the Random Block File filesystem and shows information.
|
2017-08-16 15:44:50 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ 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
|
2017-08-16 15:44:50 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2017-08-16 15:44:50 +01:00
|
|
|
|
using System;
|
2017-08-16 15:45:37 +01:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
using System.Text;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes;
|
|
|
|
|
|
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;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Marshal = Aaru.Helpers.Marshal;
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2020-02-27 00:33:26 +00:00
|
|
|
|
namespace Aaru.Filesystems
|
2017-08-16 15:44:50 +01:00
|
|
|
|
{
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Implements detection of the Locus filesystem
|
|
|
|
|
|
/// </summary>
|
2020-07-22 13:20:25 +01:00
|
|
|
|
public sealed class RBF : IFilesystem
|
2017-08-16 15:44:50 +01:00
|
|
|
|
{
|
2017-08-16 15:45:37 +01:00
|
|
|
|
/// <summary>Magic number for OS-9. Same for OS-9000?</summary>
|
2017-12-22 08:43:22 +00:00
|
|
|
|
const uint RBF_SYNC = 0x4372757A;
|
|
|
|
|
|
const uint RBF_CNYS = 0x7A757243;
|
2017-08-16 15:45:37 +01: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 />
|
2018-03-08 20:00:01 +00:00
|
|
|
|
public Encoding Encoding { get; private set; }
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2018-03-08 20:00:01 +00:00
|
|
|
|
public string Name => "OS-9 Random Block File Plugin";
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2018-03-08 20:00:01 +00:00
|
|
|
|
public Guid Id => new Guid("E864E45B-0B52-4D29-A858-7BDFA9199FB2");
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2018-08-29 22:15:43 +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)
|
2017-08-16 15:45:37 +01:00
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(imagePlugin.Info.SectorSize < 256)
|
|
|
|
|
|
return false;
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
|
|
|
|
|
// Documentation says ID should be sector 0
|
|
|
|
|
|
// I've found that OS-9/X68000 has it on sector 4
|
|
|
|
|
|
// I've read OS-9/Apple2 has it on sector 15
|
2020-02-29 18:03:35 +00:00
|
|
|
|
foreach(int i in new[]
|
|
|
|
|
|
{
|
|
|
|
|
|
0, 4, 15
|
|
|
|
|
|
})
|
2017-08-16 15:45:37 +01:00
|
|
|
|
{
|
2019-03-01 07:35:22 +00:00
|
|
|
|
ulong location = (ulong)i;
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
uint sbSize = (uint)(Marshal.SizeOf<IdSector>() / imagePlugin.Info.SectorSize);
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
if(Marshal.SizeOf<IdSector>() % imagePlugin.Info.SectorSize != 0)
|
2020-02-29 18:03:35 +00:00
|
|
|
|
sbSize++;
|
|
|
|
|
|
|
|
|
|
|
|
if(partition.Start + location + sbSize >= imagePlugin.Info.Sectors)
|
|
|
|
|
|
break;
|
2017-11-08 17:05:00 +00:00
|
|
|
|
|
2017-08-16 15:45:37 +01:00
|
|
|
|
byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
if(sector.Length < Marshal.SizeOf<IdSector>())
|
2020-02-29 18:03:35 +00:00
|
|
|
|
return false;
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
IdSector rbfSb = Marshal.ByteArrayToStructureBigEndian<IdSector>(sector);
|
|
|
|
|
|
NewIdSector rbf9000Sb = Marshal.ByteArrayToStructureBigEndian<NewIdSector>(sector);
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("RBF plugin",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
"magic at {0} = 0x{1:X8} or 0x{2:X8} (expected 0x{3:X8} or 0x{4:X8})",
|
|
|
|
|
|
location, rbfSb.dd_sync, rbf9000Sb.rid_sync, RBF_SYNC, RBF_CNYS);
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(rbfSb.dd_sync == RBF_SYNC ||
|
|
|
|
|
|
rbf9000Sb.rid_sync == RBF_SYNC ||
|
|
|
|
|
|
rbf9000Sb.rid_sync == RBF_CNYS)
|
2017-08-16 15:45:37 +01:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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)
|
2017-08-16 15:45:37 +01:00
|
|
|
|
{
|
2018-03-08 20:00:01 +00:00
|
|
|
|
Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15");
|
2017-08-16 15:45:37 +01:00
|
|
|
|
information = "";
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(imagePlugin.Info.SectorSize < 256)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
var rbfSb = new IdSector();
|
|
|
|
|
|
var rbf9000Sb = new NewIdSector();
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
foreach(int i in new[]
|
|
|
|
|
|
{
|
|
|
|
|
|
0, 4, 15
|
|
|
|
|
|
})
|
2017-08-16 15:45:37 +01:00
|
|
|
|
{
|
2018-06-20 22:22:21 +01:00
|
|
|
|
ulong location = (ulong)i;
|
2020-07-20 21:11:32 +01:00
|
|
|
|
uint sbSize = (uint)(Marshal.SizeOf<IdSector>() / imagePlugin.Info.SectorSize);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
if(Marshal.SizeOf<IdSector>() % imagePlugin.Info.SectorSize != 0)
|
2020-02-29 18:03:35 +00:00
|
|
|
|
sbSize++;
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
|
|
|
|
|
byte[] sector = imagePlugin.ReadSectors(partition.Start + location, sbSize);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
if(sector.Length < Marshal.SizeOf<IdSector>())
|
2020-02-29 18:03:35 +00:00
|
|
|
|
return;
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2020-07-20 21:11:32 +01:00
|
|
|
|
rbfSb = Marshal.ByteArrayToStructureBigEndian<IdSector>(sector);
|
|
|
|
|
|
rbf9000Sb = Marshal.ByteArrayToStructureBigEndian<NewIdSector>(sector);
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2020-02-27 23:48:41 +00:00
|
|
|
|
AaruConsole.DebugWriteLine("RBF plugin",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
"magic at {0} = 0x{1:X8} or 0x{2:X8} (expected 0x{3:X8} or 0x{4:X8})",
|
|
|
|
|
|
location, rbfSb.dd_sync, rbf9000Sb.rid_sync, RBF_SYNC, RBF_CNYS);
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(rbfSb.dd_sync == RBF_SYNC ||
|
|
|
|
|
|
rbf9000Sb.rid_sync == RBF_SYNC ||
|
|
|
|
|
|
rbf9000Sb.rid_sync == RBF_CNYS)
|
|
|
|
|
|
break;
|
2017-08-16 15:45:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(rbfSb.dd_sync != RBF_SYNC &&
|
|
|
|
|
|
rbf9000Sb.rid_sync != RBF_SYNC &&
|
|
|
|
|
|
rbf9000Sb.rid_sync != RBF_CNYS)
|
|
|
|
|
|
return;
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2018-03-08 20:00:01 +00:00
|
|
|
|
if(rbf9000Sb.rid_sync == RBF_CNYS)
|
2020-07-20 21:11:32 +01:00
|
|
|
|
rbf9000Sb = (NewIdSector)Marshal.SwapStructureMembersEndian(rbf9000Sb);
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
var sb = new StringBuilder();
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
|
|
|
|
|
sb.AppendLine("OS-9 Random Block File");
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
if(rbf9000Sb.rid_sync == RBF_SYNC)
|
2017-08-16 15:45:37 +01:00
|
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("Volume ID: {0:X8}", rbf9000Sb.rid_diskid).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} blocks in volume", rbf9000Sb.rid_totblocks).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} cylinders", rbf9000Sb.rid_cylinders).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} blocks in cylinder 0", rbf9000Sb.rid_cyl0size).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} blocks per cylinder", rbf9000Sb.rid_cylsize).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} heads", rbf9000Sb.rid_heads).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} bytes per block", rbf9000Sb.rid_blocksize).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-08-16 15:45:37 +01:00
|
|
|
|
// TODO: Convert to flags?
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendLine((rbf9000Sb.rid_format & 0x01) == 0x01 ? "Disk is double sided" : "Disk is single sided");
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
sb.AppendLine((rbf9000Sb.rid_format & 0x02) == 0x02 ? "Disk is double density"
|
2017-12-22 08:43:22 +00:00
|
|
|
|
: "Disk is single density");
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
if((rbf9000Sb.rid_format & 0x10) == 0x10)
|
|
|
|
|
|
sb.AppendLine("Disk is 384 TPI");
|
|
|
|
|
|
else if((rbf9000Sb.rid_format & 0x08) == 0x08)
|
|
|
|
|
|
sb.AppendLine("Disk is 192 TPI");
|
|
|
|
|
|
else if((rbf9000Sb.rid_format & 0x04) == 0x04)
|
|
|
|
|
|
sb.AppendLine("Disk is 96 TPI or 135 TPI");
|
|
|
|
|
|
else
|
|
|
|
|
|
sb.AppendLine("Disk is 48 TPI");
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sb.AppendFormat("Allocation bitmap descriptor starts at block {0}",
|
2017-12-22 08:43:22 +00:00
|
|
|
|
rbf9000Sb.rid_bitmap == 0 ? 1 : rbf9000Sb.rid_bitmap).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
if(rbf9000Sb.rid_firstboot > 0)
|
|
|
|
|
|
sb.AppendFormat("Debugger descriptor starts at block {0}", rbf9000Sb.rid_firstboot).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
if(rbf9000Sb.rid_bootfile > 0)
|
|
|
|
|
|
sb.AppendFormat("Boot file descriptor starts at block {0}", rbf9000Sb.rid_bootfile).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("Root directory descriptor starts at block {0}", rbf9000Sb.rid_rootdir).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
sb.AppendFormat("Disk is owned by group {0} user {1}", rbf9000Sb.rid_group, rbf9000Sb.rid_owner).
|
|
|
|
|
|
AppendLine();
|
|
|
|
|
|
|
|
|
|
|
|
sb.AppendFormat("Volume was created on {0}", DateHandlers.UnixToDateTime(rbf9000Sb.rid_ctime)).
|
|
|
|
|
|
AppendLine();
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sb.AppendFormat("Volume's identification block was last written on {0}",
|
2017-12-23 03:59:48 +00:00
|
|
|
|
DateHandlers.UnixToDateTime(rbf9000Sb.rid_mtime)).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(rbf9000Sb.rid_name, Encoding)).
|
|
|
|
|
|
AppendLine();
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType = new FileSystemType
|
2017-08-16 15:45:37 +01:00
|
|
|
|
{
|
2018-03-08 20:00:01 +00:00
|
|
|
|
Type = "OS-9 Random Block File",
|
|
|
|
|
|
Bootable = rbf9000Sb.rid_bootfile > 0,
|
|
|
|
|
|
ClusterSize = rbf9000Sb.rid_blocksize,
|
|
|
|
|
|
Clusters = rbf9000Sb.rid_totblocks,
|
|
|
|
|
|
CreationDate = DateHandlers.UnixToDateTime(rbf9000Sb.rid_ctime),
|
|
|
|
|
|
CreationDateSpecified = true,
|
|
|
|
|
|
ModificationDate = DateHandlers.UnixToDateTime(rbf9000Sb.rid_mtime),
|
2017-08-16 15:45:37 +01:00
|
|
|
|
ModificationDateSpecified = true,
|
2018-03-08 20:00:01 +00:00
|
|
|
|
VolumeName = StringHandlers.CToString(rbf9000Sb.rid_name, Encoding),
|
|
|
|
|
|
VolumeSerial = $"{rbf9000Sb.rid_diskid:X8}"
|
2017-08-16 15:45:37 +01:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("Volume ID: {0:X4}", rbfSb.dd_dsk).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} blocks in volume", LSNToUInt32(rbfSb.dd_tot)).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} tracks", rbfSb.dd_tks).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} sectors per track", rbfSb.dd_spt).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} bytes per sector", 256 << rbfSb.dd_lsnsize).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("{0} sectors per cluster ({1} bytes)", rbfSb.dd_bit,
|
|
|
|
|
|
rbfSb.dd_bit * (256 << rbfSb.dd_lsnsize)).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-08-16 15:45:37 +01:00
|
|
|
|
// TODO: Convert to flags?
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendLine((rbfSb.dd_fmt & 0x01) == 0x01 ? "Disk is double sided" : "Disk is single sided");
|
|
|
|
|
|
sb.AppendLine((rbfSb.dd_fmt & 0x02) == 0x02 ? "Disk is double density" : "Disk is single density");
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
if((rbfSb.dd_fmt & 0x10) == 0x10)
|
|
|
|
|
|
sb.AppendLine("Disk is 384 TPI");
|
|
|
|
|
|
else if((rbfSb.dd_fmt & 0x08) == 0x08)
|
|
|
|
|
|
sb.AppendLine("Disk is 192 TPI");
|
|
|
|
|
|
else if((rbfSb.dd_fmt & 0x04) == 0x04)
|
|
|
|
|
|
sb.AppendLine("Disk is 96 TPI or 135 TPI");
|
|
|
|
|
|
else
|
|
|
|
|
|
sb.AppendLine("Disk is 48 TPI");
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sb.AppendFormat("Allocation bitmap descriptor starts at block {0}",
|
2017-12-22 08:43:22 +00:00
|
|
|
|
rbfSb.dd_maplsn == 0 ? 1 : rbfSb.dd_maplsn).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("{0} bytes in allocation bitmap", rbfSb.dd_map).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
if(LSNToUInt32(rbfSb.dd_bt) > 0 &&
|
|
|
|
|
|
rbfSb.dd_bsz > 0)
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("Boot file starts at block {0} and has {1} bytes", LSNToUInt32(rbfSb.dd_bt),
|
|
|
|
|
|
rbfSb.dd_bsz).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
sb.AppendFormat("Root directory descriptor starts at block {0}", LSNToUInt32(rbfSb.dd_dir)).
|
|
|
|
|
|
AppendLine();
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("Disk is owned by user {0}", rbfSb.dd_own).AppendLine();
|
2017-12-23 03:59:48 +00:00
|
|
|
|
sb.AppendFormat("Volume was created on {0}", DateHandlers.Os9ToDateTime(rbfSb.dd_dat)).AppendLine();
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("Volume attributes: {0:X2}", rbfSb.dd_att).AppendLine();
|
2017-12-26 08:01:40 +00:00
|
|
|
|
sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(rbfSb.dd_nam, Encoding)).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
sb.AppendFormat("Path descriptor options: {0}", StringHandlers.CToString(rbfSb.dd_opt, Encoding)).
|
|
|
|
|
|
AppendLine();
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType = new FileSystemType
|
2017-08-16 15:45:37 +01:00
|
|
|
|
{
|
2018-03-08 20:00:01 +00:00
|
|
|
|
Type = "OS-9 Random Block File",
|
|
|
|
|
|
Bootable = LSNToUInt32(rbfSb.dd_bt) > 0 && rbfSb.dd_bsz > 0,
|
2019-04-23 01:38:33 +01:00
|
|
|
|
ClusterSize = (uint)(rbfSb.dd_bit * (256 << rbfSb.dd_lsnsize)),
|
2018-03-08 20:00:01 +00:00
|
|
|
|
Clusters = LSNToUInt32(rbfSb.dd_tot),
|
|
|
|
|
|
CreationDate = DateHandlers.Os9ToDateTime(rbfSb.dd_dat),
|
2017-08-16 15:45:37 +01:00
|
|
|
|
CreationDateSpecified = true,
|
2018-03-08 20:00:01 +00:00
|
|
|
|
VolumeName = StringHandlers.CToString(rbfSb.dd_nam, Encoding),
|
|
|
|
|
|
VolumeSerial = $"{rbfSb.dd_dsk:X4}"
|
2017-08-16 15:45:37 +01:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
information = sb.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
static uint LSNToUInt32(byte[] lsn)
|
2017-08-16 15:45:37 +01:00
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(lsn == null ||
|
|
|
|
|
|
lsn.Length != 3)
|
|
|
|
|
|
return 0;
|
2017-08-16 15:45:37 +01:00
|
|
|
|
|
|
|
|
|
|
return (uint)((lsn[0] << 16) + (lsn[1] << 8) + lsn[2]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
/// <summary>Identification sector. Wherever the sector this resides on, becomes LSN 0.</summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
2020-11-11 04:19:18 +00:00
|
|
|
|
readonly struct IdSector
|
2017-12-24 02:37:41 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>Sectors on disk</summary>
|
2018-03-08 20:00:01 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] dd_tot;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Tracks</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte dd_tks;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Bytes in allocation map</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort dd_map;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Sectors per cluster</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort dd_bit;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>LSN of root directory</summary>
|
2018-03-08 20:00:01 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] dd_dir;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Owner ID</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort dd_own;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Attributes</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte dd_att;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Disk ID</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort dd_dsk;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Format byte</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte dd_fmt;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Sectors per track</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort dd_spt;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Reserved</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort dd_res;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>LSN of boot file</summary>
|
2018-03-08 20:00:01 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] dd_bt;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Size of boot file</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort dd_bsz;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Creation date</summary>
|
2018-03-08 20:00:01 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] dd_dat;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Volume name</summary>
|
2018-03-08 20:00:01 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] dd_nam;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Path options</summary>
|
2018-03-08 20:00:01 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] dd_opt;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Reserved</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte reserved;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Magic number</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly uint dd_sync;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>LSN of allocation map</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly uint dd_maplsn;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Size of an LSN</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort dd_lsnsize;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Version ID</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort dd_versid;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
/// Identification sector. Wherever the sector this resides on, becomes LSN 0. Introduced on OS-9000, this can be
|
|
|
|
|
|
/// big or little endian.
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
2020-11-11 04:19:18 +00:00
|
|
|
|
readonly struct NewIdSector
|
2017-12-24 02:37:41 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>Magic number</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly uint rid_sync;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Disk ID</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly uint rid_diskid;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Sectors on disk</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly uint rid_totblocks;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Cylinders</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort rid_cylinders;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Sectors in cylinder 0</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort rid_cyl0size;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Sectors per cylinder</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort rid_cylsize;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Heads</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort rid_heads;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Bytes per sector</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort rid_blocksize;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Disk format</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort rid_format;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Flags</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort rid_flags;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Padding</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort rid_unused1;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Sector of allocation bitmap</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly uint rid_bitmap;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Sector of debugger FD</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly uint rid_firstboot;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Sector of bootfile FD</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly uint rid_bootfile;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Sector of root directory FD</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly uint rid_rootdir;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Group owner of media</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort rid_group;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Owner of media</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly ushort rid_owner;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Creation time</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly uint rid_ctime;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Last write time for this structure</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly uint rid_mtime;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Volume name</summary>
|
2018-03-08 20:00:01 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] rid_name;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Endian flag</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte rid_endflag;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Padding</summary>
|
2018-03-08 20:00:01 +00:00
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly byte[] rid_unused2;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>Parity</summary>
|
2019-04-23 01:38:33 +01:00
|
|
|
|
public readonly uint rid_parity;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
}
|
2017-08-16 15:44:50 +01:00
|
|
|
|
}
|
2017-08-16 15:45:37 +01:00
|
|
|
|
}
|