2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2016-07-21 17:36:51 +01:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : Super.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2016-07-21 17:36:51 +01:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Component : Apple Lisa filesystem plugin.
|
2016-07-21 17:36:51 +01:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Handles mounting and umounting the Apple Lisa filesystem.
|
2016-07-21 17:36:51 +01:00
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// 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
|
2016-07-21 17:36:51 +01:00
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// 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.
|
2016-07-21 17:36:51 +01:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// 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/>.
|
2016-07-21 17:36:51 +01:00
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2016-07-21 17:36:51 +01:00
|
|
|
// ****************************************************************************/
|
2016-07-28 18:13:49 +01:00
|
|
|
|
2016-07-21 17:36:51 +01:00
|
|
|
using System;
|
2016-07-22 02:18:53 +01:00
|
|
|
using System.Collections.Generic;
|
2017-12-26 06:05:12 +00:00
|
|
|
using Claunia.Encoding;
|
|
|
|
|
using DiscImageChef.CommonTypes;
|
2016-07-22 02:18:53 +01:00
|
|
|
using DiscImageChef.Console;
|
2016-08-21 19:23:58 +01:00
|
|
|
using DiscImageChef.Decoders;
|
2017-12-20 17:15:26 +00:00
|
|
|
using DiscImageChef.DiscImages;
|
2017-12-21 14:30:38 +00:00
|
|
|
using Schemas;
|
2017-12-26 06:05:12 +00:00
|
|
|
using Encoding = System.Text.Encoding;
|
2016-07-22 02:18:53 +01:00
|
|
|
|
2016-07-21 17:36:51 +01:00
|
|
|
namespace DiscImageChef.Filesystems.LisaFS
|
|
|
|
|
{
|
2017-12-21 16:27:09 +00:00
|
|
|
public partial class LisaFS
|
2016-07-21 17:36:51 +01:00
|
|
|
{
|
2016-07-29 02:22:24 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Mounts an Apple Lisa filesystem
|
2016-07-29 02:22:24 +01:00
|
|
|
/// </summary>
|
2017-12-27 23:55:59 +00:00
|
|
|
public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
|
|
|
|
|
Dictionary<string, string> options)
|
2016-07-22 02:18:53 +01:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-12-27 23:55:59 +00:00
|
|
|
device = imagePlugin;
|
2017-12-26 08:01:40 +00:00
|
|
|
Encoding = new LisaRoman();
|
2017-12-26 06:05:12 +00:00
|
|
|
|
2016-07-29 02:22:24 +01:00
|
|
|
// Lisa OS is unable to work on disks without tags.
|
|
|
|
|
// This code is designed like that.
|
|
|
|
|
// However with some effort the code may be modified to ignore them.
|
2017-12-26 06:05:12 +00:00
|
|
|
if(device.Info.ReadableSectorTags == null ||
|
|
|
|
|
!device.Info.ReadableSectorTags.Contains(SectorTagType.AppleSectorTag))
|
2016-07-22 02:18:53 +01:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("LisaFS plugin", "Underlying device does not support Lisa tags");
|
|
|
|
|
return Errno.InOutError;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// LisaOS is big-endian
|
|
|
|
|
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
|
|
|
|
|
|
|
|
|
|
// Minimal LisaOS disk is 3.5" single sided double density, 800 sectors
|
2017-12-26 06:05:12 +00:00
|
|
|
if(device.Info.Sectors < 800)
|
2016-07-22 02:18:53 +01:00
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("LisaFS plugin", "Device is too small");
|
|
|
|
|
return Errno.InOutError;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-27 22:13:47 +01:00
|
|
|
// MDDF cannot be at end of device, of course
|
2017-12-26 06:05:12 +00:00
|
|
|
volumePrefix = device.Info.Sectors;
|
2016-07-27 22:13:47 +01:00
|
|
|
|
2016-07-22 02:18:53 +01:00
|
|
|
// LisaOS searches sectors until tag tells MDDF resides there, so we'll search 100 sectors
|
2016-07-27 22:13:47 +01:00
|
|
|
for(ulong i = 0; i < 100; i++)
|
2016-07-22 02:18:53 +01:00
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
DecodeTag(device.ReadSectorTag(i, SectorTagType.AppleSectorTag), out LisaTag.PriamTag searchTag);
|
2016-07-27 22:13:47 +01:00
|
|
|
|
2017-12-22 02:04:18 +00:00
|
|
|
DicConsole.DebugWriteLine("LisaFS plugin", "Sector {0}, file ID 0x{1:X4}", i, searchTag.FileId);
|
2016-07-22 02:18:53 +01:00
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
if(volumePrefix == device.Info.Sectors && searchTag.FileId == FILEID_LOADER_SIGNED)
|
2016-07-27 22:13:47 +01:00
|
|
|
volumePrefix = i - 1;
|
2016-07-22 02:18:53 +01:00
|
|
|
|
2017-12-22 02:04:18 +00:00
|
|
|
if(searchTag.FileId != FILEID_MDDF) continue;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
|
|
|
devTagSize = device.ReadSectorTag(i, SectorTagType.AppleSectorTag).Length;
|
|
|
|
|
|
2017-12-27 23:55:59 +00:00
|
|
|
byte[] sector = device.ReadSector(i);
|
|
|
|
|
mddf = new MDDF();
|
2017-12-21 06:06:19 +00:00
|
|
|
byte[] pString = new byte[33];
|
2017-12-27 23:55:59 +00:00
|
|
|
uint lisaTime;
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
|
|
|
mddf.fsversion = BigEndianBitConverter.ToUInt16(sector, 0x00);
|
2017-12-27 23:55:59 +00:00
|
|
|
mddf.volid = BigEndianBitConverter.ToUInt64(sector, 0x02);
|
|
|
|
|
mddf.volnum = BigEndianBitConverter.ToUInt16(sector, 0x0A);
|
2017-12-21 06:06:19 +00:00
|
|
|
Array.Copy(sector, 0x0C, pString, 0, 33);
|
2017-12-27 23:55:59 +00:00
|
|
|
mddf.volname = StringHandlers.PascalToString(pString, Encoding);
|
2017-12-21 06:06:19 +00:00
|
|
|
mddf.unknown1 = sector[0x2D];
|
|
|
|
|
Array.Copy(sector, 0x2E, pString, 0, 33);
|
|
|
|
|
// Prevent garbage
|
2017-12-27 23:55:59 +00:00
|
|
|
mddf.password =
|
|
|
|
|
pString[0] <= 32 ? StringHandlers.PascalToString(pString, Encoding) : "";
|
|
|
|
|
mddf.unknown2 = sector[0x4F];
|
|
|
|
|
mddf.machine_id = BigEndianBitConverter.ToUInt32(sector, 0x50);
|
|
|
|
|
mddf.master_copy_id = BigEndianBitConverter.ToUInt32(sector, 0x54);
|
|
|
|
|
lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x58);
|
|
|
|
|
mddf.dtvc = DateHandlers.LisaToDateTime(lisaTime);
|
|
|
|
|
lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x5C);
|
|
|
|
|
mddf.dtcc = DateHandlers.LisaToDateTime(lisaTime);
|
|
|
|
|
lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x60);
|
|
|
|
|
mddf.dtvb = DateHandlers.LisaToDateTime(lisaTime);
|
|
|
|
|
lisaTime = BigEndianBitConverter.ToUInt32(sector, 0x64);
|
|
|
|
|
mddf.dtvs = DateHandlers.LisaToDateTime(lisaTime);
|
|
|
|
|
mddf.unknown3 = BigEndianBitConverter.ToUInt32(sector, 0x68);
|
|
|
|
|
mddf.mddf_block = BigEndianBitConverter.ToUInt32(sector, 0x6C);
|
|
|
|
|
mddf.volsize_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x70);
|
2017-12-21 06:06:19 +00:00
|
|
|
mddf.volsize_minus_mddf_minus_one = BigEndianBitConverter.ToUInt32(sector, 0x74);
|
2017-12-27 23:55:59 +00:00
|
|
|
mddf.vol_size = BigEndianBitConverter.ToUInt32(sector, 0x78);
|
|
|
|
|
mddf.blocksize = BigEndianBitConverter.ToUInt16(sector, 0x7C);
|
|
|
|
|
mddf.datasize = BigEndianBitConverter.ToUInt16(sector, 0x7E);
|
|
|
|
|
mddf.unknown4 = BigEndianBitConverter.ToUInt16(sector, 0x80);
|
|
|
|
|
mddf.unknown5 = BigEndianBitConverter.ToUInt32(sector, 0x82);
|
|
|
|
|
mddf.unknown6 = BigEndianBitConverter.ToUInt32(sector, 0x86);
|
|
|
|
|
mddf.clustersize = BigEndianBitConverter.ToUInt16(sector, 0x8A);
|
|
|
|
|
mddf.fs_size = BigEndianBitConverter.ToUInt32(sector, 0x8C);
|
|
|
|
|
mddf.unknown7 = BigEndianBitConverter.ToUInt32(sector, 0x90);
|
|
|
|
|
mddf.srec_ptr = BigEndianBitConverter.ToUInt32(sector, 0x94);
|
|
|
|
|
mddf.unknown9 = BigEndianBitConverter.ToUInt16(sector, 0x98);
|
|
|
|
|
mddf.srec_len = BigEndianBitConverter.ToUInt16(sector, 0x9A);
|
|
|
|
|
mddf.unknown10 = BigEndianBitConverter.ToUInt32(sector, 0x9C);
|
|
|
|
|
mddf.unknown11 = BigEndianBitConverter.ToUInt32(sector, 0xA0);
|
|
|
|
|
mddf.unknown12 = BigEndianBitConverter.ToUInt32(sector, 0xA4);
|
|
|
|
|
mddf.unknown13 = BigEndianBitConverter.ToUInt32(sector, 0xA8);
|
|
|
|
|
mddf.unknown14 = BigEndianBitConverter.ToUInt32(sector, 0xAC);
|
|
|
|
|
mddf.filecount = BigEndianBitConverter.ToUInt16(sector, 0xB0);
|
|
|
|
|
mddf.unknown15 = BigEndianBitConverter.ToUInt32(sector, 0xB2);
|
|
|
|
|
mddf.unknown16 = BigEndianBitConverter.ToUInt32(sector, 0xB6);
|
|
|
|
|
mddf.freecount = BigEndianBitConverter.ToUInt32(sector, 0xBA);
|
|
|
|
|
mddf.unknown17 = BigEndianBitConverter.ToUInt16(sector, 0xBE);
|
|
|
|
|
mddf.unknown18 = BigEndianBitConverter.ToUInt32(sector, 0xC0);
|
|
|
|
|
mddf.overmount_stamp = BigEndianBitConverter.ToUInt64(sector, 0xC4);
|
|
|
|
|
mddf.serialization = BigEndianBitConverter.ToUInt32(sector, 0xCC);
|
|
|
|
|
mddf.unknown19 = BigEndianBitConverter.ToUInt32(sector, 0xD0);
|
|
|
|
|
mddf.unknown_timestamp = BigEndianBitConverter.ToUInt32(sector, 0xD4);
|
|
|
|
|
mddf.unknown20 = BigEndianBitConverter.ToUInt32(sector, 0xD8);
|
|
|
|
|
mddf.unknown21 = BigEndianBitConverter.ToUInt32(sector, 0xDC);
|
|
|
|
|
mddf.unknown22 = BigEndianBitConverter.ToUInt32(sector, 0xE0);
|
|
|
|
|
mddf.unknown23 = BigEndianBitConverter.ToUInt32(sector, 0xE4);
|
|
|
|
|
mddf.unknown24 = BigEndianBitConverter.ToUInt32(sector, 0xE8);
|
|
|
|
|
mddf.unknown25 = BigEndianBitConverter.ToUInt32(sector, 0xEC);
|
|
|
|
|
mddf.unknown26 = BigEndianBitConverter.ToUInt32(sector, 0xF0);
|
|
|
|
|
mddf.unknown27 = BigEndianBitConverter.ToUInt32(sector, 0xF4);
|
|
|
|
|
mddf.unknown28 = BigEndianBitConverter.ToUInt32(sector, 0xF8);
|
|
|
|
|
mddf.unknown29 = BigEndianBitConverter.ToUInt32(sector, 0xFC);
|
|
|
|
|
mddf.unknown30 = BigEndianBitConverter.ToUInt32(sector, 0x100);
|
|
|
|
|
mddf.unknown31 = BigEndianBitConverter.ToUInt32(sector, 0x104);
|
|
|
|
|
mddf.unknown32 = BigEndianBitConverter.ToUInt32(sector, 0x108);
|
|
|
|
|
mddf.unknown33 = BigEndianBitConverter.ToUInt32(sector, 0x10C);
|
|
|
|
|
mddf.unknown34 = BigEndianBitConverter.ToUInt32(sector, 0x110);
|
|
|
|
|
mddf.unknown35 = BigEndianBitConverter.ToUInt32(sector, 0x114);
|
|
|
|
|
mddf.backup_volid = BigEndianBitConverter.ToUInt64(sector, 0x118);
|
|
|
|
|
mddf.label_size = BigEndianBitConverter.ToUInt16(sector, 0x120);
|
|
|
|
|
mddf.fs_overhead = BigEndianBitConverter.ToUInt16(sector, 0x122);
|
|
|
|
|
mddf.result_scavenge = BigEndianBitConverter.ToUInt16(sector, 0x124);
|
|
|
|
|
mddf.boot_code = BigEndianBitConverter.ToUInt16(sector, 0x126);
|
|
|
|
|
mddf.boot_environ = BigEndianBitConverter.ToUInt16(sector, 0x6C);
|
|
|
|
|
mddf.unknown36 = BigEndianBitConverter.ToUInt32(sector, 0x12A);
|
|
|
|
|
mddf.unknown37 = BigEndianBitConverter.ToUInt32(sector, 0x12E);
|
|
|
|
|
mddf.unknown38 = BigEndianBitConverter.ToUInt32(sector, 0x132);
|
|
|
|
|
mddf.vol_sequence = BigEndianBitConverter.ToUInt16(sector, 0x136);
|
|
|
|
|
mddf.vol_left_mounted = sector[0x138];
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
|
|
|
// Check that the MDDF is correct
|
2017-12-27 23:55:59 +00:00
|
|
|
if(mddf.mddf_block != i - volumePrefix ||
|
|
|
|
|
mddf.vol_size > device.Info.Sectors ||
|
|
|
|
|
mddf.vol_size - 1 !=
|
|
|
|
|
mddf.volsize_minus_one ||
|
|
|
|
|
mddf.vol_size - i - 1 !=
|
|
|
|
|
mddf.volsize_minus_mddf_minus_one - volumePrefix ||
|
|
|
|
|
mddf.datasize >
|
|
|
|
|
mddf.blocksize || mddf.blocksize < device.Info.SectorSize ||
|
|
|
|
|
mddf.datasize != device.Info.SectorSize)
|
2016-07-22 02:18:53 +01:00
|
|
|
{
|
2017-12-21 06:06:19 +00:00
|
|
|
DicConsole.DebugWriteLine("LisaFS plugin", "Incorrect MDDF found");
|
|
|
|
|
return Errno.InvalidArgument;
|
|
|
|
|
}
|
2016-07-22 02:18:53 +01:00
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
// Check MDDF version
|
|
|
|
|
switch(mddf.fsversion)
|
|
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
case LISA_V1:
|
2017-12-21 06:06:19 +00:00
|
|
|
DicConsole.DebugWriteLine("LisaFS plugin", "Mounting LisaFS v1");
|
|
|
|
|
break;
|
2017-12-22 08:43:22 +00:00
|
|
|
case LISA_V2:
|
2017-12-21 06:06:19 +00:00
|
|
|
DicConsole.DebugWriteLine("LisaFS plugin", "Mounting LisaFS v2");
|
|
|
|
|
break;
|
2017-12-22 08:43:22 +00:00
|
|
|
case LISA_V3:
|
2017-12-21 06:06:19 +00:00
|
|
|
DicConsole.DebugWriteLine("LisaFS plugin", "Mounting LisaFS v3");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
DicConsole.ErrorWriteLine("Cannot mount LisaFS version {0}", mddf.fsversion.ToString());
|
|
|
|
|
return Errno.NotSupported;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initialize caches
|
2017-12-27 23:55:59 +00:00
|
|
|
extentCache = new Dictionary<short, ExtentFile>();
|
2017-12-21 06:06:19 +00:00
|
|
|
systemFileCache = new Dictionary<short, byte[]>();
|
2017-12-27 23:55:59 +00:00
|
|
|
fileCache = new Dictionary<short, byte[]>();
|
2017-12-21 06:06:19 +00:00
|
|
|
//catalogCache = new Dictionary<short, List<CatalogEntry>>();
|
|
|
|
|
fileSizeCache = new Dictionary<short, int>();
|
|
|
|
|
|
2017-12-27 23:55:59 +00:00
|
|
|
mounted = true;
|
|
|
|
|
if(options == null) options = GetDefaultOptions();
|
|
|
|
|
if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out debug);
|
2016-07-22 02:18:53 +01:00
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
if(debug) printedExtents = new List<short>();
|
2016-07-22 02:18:53 +01:00
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
// Read the S-Records file
|
2017-12-22 08:43:22 +00:00
|
|
|
Errno error = ReadSRecords();
|
2017-12-21 06:06:19 +00:00
|
|
|
if(error != Errno.NoError)
|
|
|
|
|
{
|
|
|
|
|
DicConsole.ErrorWriteLine("Error {0} reading S-Records file.", error);
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
directoryDtcCache = new Dictionary<short, DateTime> {{DIRID_ROOT, mddf.dtcc}};
|
2016-07-27 14:34:29 +01:00
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
// Read the Catalog File
|
|
|
|
|
error = ReadCatalog();
|
2016-07-22 02:18:53 +01:00
|
|
|
|
2017-12-21 06:06:19 +00:00
|
|
|
if(error != Errno.NoError)
|
|
|
|
|
{
|
|
|
|
|
DicConsole.DebugWriteLine("LisaFS plugin", "Cannot read Catalog File, error {0}",
|
|
|
|
|
error.ToString());
|
|
|
|
|
mounted = false;
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If debug, cache system files
|
|
|
|
|
if(debug)
|
|
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
error = ReadSystemFile(FILEID_BOOT_SIGNED, out _);
|
2016-07-28 03:41:57 +01:00
|
|
|
if(error != Errno.NoError)
|
|
|
|
|
{
|
2017-12-21 06:06:19 +00:00
|
|
|
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read boot blocks");
|
|
|
|
|
mounted = false;
|
2016-07-28 03:41:57 +01:00
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
error = ReadSystemFile(FILEID_LOADER_SIGNED, out _);
|
2016-07-22 02:18:53 +01:00
|
|
|
if(error != Errno.NoError)
|
|
|
|
|
{
|
2017-12-21 06:06:19 +00:00
|
|
|
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read boot loader");
|
2016-07-22 02:18:53 +01:00
|
|
|
mounted = false;
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
error = ReadSystemFile((short)FILEID_MDDF, out _);
|
2017-12-21 06:06:19 +00:00
|
|
|
if(error != Errno.NoError)
|
2016-07-22 02:18:53 +01:00
|
|
|
{
|
2017-12-21 06:06:19 +00:00
|
|
|
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read MDDF");
|
|
|
|
|
mounted = false;
|
|
|
|
|
return error;
|
2016-07-22 02:18:53 +01:00
|
|
|
}
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
error = ReadSystemFile((short)FILEID_BITMAP, out _);
|
2017-12-21 06:06:19 +00:00
|
|
|
if(error != Errno.NoError)
|
2016-07-22 02:18:53 +01:00
|
|
|
{
|
2017-12-21 06:06:19 +00:00
|
|
|
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read volume bitmap");
|
|
|
|
|
mounted = false;
|
|
|
|
|
return error;
|
2016-07-22 02:18:53 +01:00
|
|
|
}
|
2017-12-21 06:06:19 +00:00
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
error = ReadSystemFile((short)FILEID_SRECORD, out _);
|
2017-12-21 06:06:19 +00:00
|
|
|
if(error != Errno.NoError)
|
2016-07-22 02:18:53 +01:00
|
|
|
{
|
2017-12-21 06:06:19 +00:00
|
|
|
DicConsole.DebugWriteLine("LisaFS plugin", "Unable to read S-Records file");
|
|
|
|
|
mounted = false;
|
|
|
|
|
return error;
|
2016-07-22 02:18:53 +01:00
|
|
|
}
|
|
|
|
|
}
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
|
|
|
// Create XML metadata for mounted filesystem
|
2017-12-26 08:01:40 +00:00
|
|
|
XmlFsType = new FileSystemType();
|
2017-12-21 06:06:19 +00:00
|
|
|
if(DateTime.Compare(mddf.dtvb, DateHandlers.LisaToDateTime(0)) > 0)
|
|
|
|
|
{
|
2017-12-27 23:55:59 +00:00
|
|
|
XmlFsType.BackupDate = mddf.dtvb;
|
2017-12-26 08:01:40 +00:00
|
|
|
XmlFsType.BackupDateSpecified = true;
|
2017-12-21 06:06:19 +00:00
|
|
|
}
|
2017-12-27 23:55:59 +00:00
|
|
|
|
|
|
|
|
XmlFsType.Clusters = mddf.vol_size;
|
2017-12-26 08:01:40 +00:00
|
|
|
XmlFsType.ClusterSize = mddf.clustersize * mddf.datasize;
|
2017-12-21 06:06:19 +00:00
|
|
|
if(DateTime.Compare(mddf.dtvc, DateHandlers.LisaToDateTime(0)) > 0)
|
|
|
|
|
{
|
2017-12-27 23:55:59 +00:00
|
|
|
XmlFsType.CreationDate = mddf.dtvc;
|
2017-12-26 08:01:40 +00:00
|
|
|
XmlFsType.CreationDateSpecified = true;
|
2017-12-21 06:06:19 +00:00
|
|
|
}
|
2017-12-27 23:55:59 +00:00
|
|
|
|
|
|
|
|
XmlFsType.Dirty = mddf.vol_left_mounted != 0;
|
|
|
|
|
XmlFsType.Files = mddf.filecount;
|
|
|
|
|
XmlFsType.FilesSpecified = true;
|
|
|
|
|
XmlFsType.FreeClusters = mddf.freecount;
|
2017-12-26 08:01:40 +00:00
|
|
|
XmlFsType.FreeClustersSpecified = true;
|
2017-12-27 23:55:59 +00:00
|
|
|
XmlFsType.Type = "LisaFS";
|
|
|
|
|
XmlFsType.VolumeName = mddf.volname;
|
|
|
|
|
XmlFsType.VolumeSerial = $"{mddf.volid:X16}";
|
2017-12-21 06:06:19 +00:00
|
|
|
|
|
|
|
|
return Errno.NoError;
|
2016-07-22 02:18:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DicConsole.DebugWriteLine("LisaFS plugin", "Not a Lisa filesystem");
|
|
|
|
|
return Errno.NotSupported;
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
DicConsole.ErrorWriteLine("Exception {0}, {1}, {2}", ex.Message, ex.InnerException, ex.StackTrace);
|
|
|
|
|
return Errno.InOutError;
|
|
|
|
|
}
|
2016-07-21 17:36:51 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-29 02:22:24 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Umounts this Lisa filesystem
|
2016-07-29 02:22:24 +01:00
|
|
|
/// </summary>
|
2017-12-26 07:28:40 +00:00
|
|
|
public Errno Unmount()
|
2016-07-21 17:36:51 +01:00
|
|
|
{
|
2017-12-27 23:55:59 +00:00
|
|
|
mounted = false;
|
|
|
|
|
extentCache = null;
|
2016-07-22 02:18:53 +01:00
|
|
|
systemFileCache = null;
|
2017-12-27 23:55:59 +00:00
|
|
|
fileCache = null;
|
|
|
|
|
catalogCache = null;
|
|
|
|
|
fileSizeCache = null;
|
|
|
|
|
printedExtents = null;
|
|
|
|
|
mddf = new MDDF();
|
|
|
|
|
volumePrefix = 0;
|
|
|
|
|
devTagSize = 0;
|
|
|
|
|
srecords = null;
|
2016-07-22 02:18:53 +01:00
|
|
|
|
|
|
|
|
return Errno.NoError;
|
2016-07-21 17:36:51 +01:00
|
|
|
}
|
|
|
|
|
|
2016-07-29 02:22:24 +01:00
|
|
|
/// <summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
/// Gets information about the mounted volume.
|
2016-07-29 02:22:24 +01:00
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="stat">Information about the mounted volume.</param>
|
2017-12-26 08:17:28 +00:00
|
|
|
public Errno StatFs(out FileSystemInfo stat)
|
2016-07-21 17:36:51 +01:00
|
|
|
{
|
2017-12-26 08:17:28 +00:00
|
|
|
stat = null;
|
2017-12-19 20:33:03 +00:00
|
|
|
if(!mounted) return Errno.AccessDenied;
|
2016-07-22 02:18:53 +01:00
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
stat = new FileSystemInfo
|
|
|
|
|
{
|
2017-12-27 23:55:59 +00:00
|
|
|
Blocks = mddf.vol_size,
|
2017-12-22 08:43:22 +00:00
|
|
|
FilenameLength = (ushort)E_NAME,
|
2017-12-27 23:55:59 +00:00
|
|
|
Files = mddf.filecount,
|
|
|
|
|
FreeBlocks = mddf.freecount,
|
|
|
|
|
Id = {Serial64 = mddf.volid, IsLong = true},
|
|
|
|
|
PluginId = Id
|
2017-12-22 08:43:22 +00:00
|
|
|
};
|
2016-07-22 02:18:53 +01:00
|
|
|
stat.FreeFiles = FILEID_MAX - stat.Files;
|
2016-07-31 20:56:15 +01:00
|
|
|
switch(mddf.fsversion)
|
|
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
case LISA_V1:
|
2016-07-31 20:56:15 +01:00
|
|
|
stat.Type = "LisaFS v1";
|
|
|
|
|
break;
|
2017-12-22 08:43:22 +00:00
|
|
|
case LISA_V2:
|
2016-07-31 20:56:15 +01:00
|
|
|
stat.Type = "LisaFS v2";
|
|
|
|
|
break;
|
2017-12-22 08:43:22 +00:00
|
|
|
case LISA_V3:
|
2016-07-31 20:56:15 +01:00
|
|
|
stat.Type = "LisaFS v3";
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-07-22 02:18:53 +01:00
|
|
|
|
|
|
|
|
return Errno.NoError;
|
2016-07-21 17:36:51 +01:00
|
|
|
}
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|