2017-07-19 16:31:08 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : MinixFS.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : MINIX filesystem plugin.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Identifies the MINIX filesystem 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2025-08-14 02:49:52 +01:00
|
|
|
|
// Copyright © 2011-2025 Natalia Portillo
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// ****************************************************************************/
|
2014-04-17 19:58:14 +00:00
|
|
|
|
|
2012-08-05 18:13:48 +00:00
|
|
|
|
using System;
|
2017-07-23 21:01:26 +01:00
|
|
|
|
using System.Runtime.InteropServices;
|
2017-07-19 16:31:08 +01:00
|
|
|
|
using System.Text;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes;
|
|
|
|
|
|
using Aaru.CommonTypes.Enums;
|
|
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using Schemas;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Marshal = Aaru.Helpers.Marshal;
|
2012-08-05 18:13:48 +00:00
|
|
|
|
|
2020-02-27 00:33:26 +00:00
|
|
|
|
namespace Aaru.Filesystems
|
2012-08-05 18:13:48 +00:00
|
|
|
|
{
|
2016-07-28 22:25:26 +01:00
|
|
|
|
// Information from the Linux kernel
|
2021-08-17 14:25:12 +01:00
|
|
|
|
/// <inheritdoc />
|
2021-08-17 21:23:10 +01:00
|
|
|
|
/// <summary>Implements detection of the MINIX filesystem</summary>
|
2020-07-22 13:20:25 +01:00
|
|
|
|
public sealed class MinixFS : IFilesystem
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2017-07-25 02:48:04 +01:00
|
|
|
|
/// <summary>Minix v1, 14 char filenames</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
const ushort MINIX_MAGIC = 0x137F;
|
2017-07-25 02:48:04 +01:00
|
|
|
|
/// <summary>Minix v1, 30 char filenames</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
const ushort MINIX_MAGIC2 = 0x138F;
|
2017-07-25 02:48:04 +01:00
|
|
|
|
/// <summary>Minix v2, 14 char filenames</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
const ushort MINIX2_MAGIC = 0x2468;
|
2017-07-25 02:48:04 +01:00
|
|
|
|
/// <summary>Minix v2, 30 char filenames</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
const ushort MINIX2_MAGIC2 = 0x2478;
|
2017-07-25 02:48:04 +01:00
|
|
|
|
/// <summary>Minix v3, 60 char filenames</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
const ushort MINIX3_MAGIC = 0x4D5A;
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
// Byteswapped
|
2017-07-25 02:48:04 +01:00
|
|
|
|
/// <summary>Minix v1, 14 char filenames</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
const ushort MINIX_CIGAM = 0x7F13;
|
2017-07-25 02:48:04 +01:00
|
|
|
|
/// <summary>Minix v1, 30 char filenames</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
const ushort MINIX_CIGAM2 = 0x8F13;
|
2017-07-25 02:48:04 +01:00
|
|
|
|
/// <summary>Minix v2, 14 char filenames</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
const ushort MINIX2_CIGAM = 0x6824;
|
2017-07-25 02:48:04 +01:00
|
|
|
|
/// <summary>Minix v2, 30 char filenames</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
const ushort MINIX2_CIGAM2 = 0x7824;
|
2017-07-25 02:48:04 +01:00
|
|
|
|
/// <summary>Minix v3, 60 char filenames</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
const ushort MINIX3_CIGAM = 0x5A4D;
|
2014-04-14 02:29:13 +00: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 />
|
2021-08-17 21:23:10 +01:00
|
|
|
|
public Encoding Encoding { get; private set; }
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2021-08-17 21:23:10 +01:00
|
|
|
|
public string Name => "Minix Filesystem";
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2021-08-17 21:23:10 +01:00
|
|
|
|
public Guid Id => new Guid("FE248C3B-B727-4AE5-A39F-79EA9A07D4B3");
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2021-08-17 21:23:10 +01:00
|
|
|
|
public string Author => "Natalia Portillo";
|
2016-07-27 13:32:45 +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)
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2017-07-25 22:23:51 +01:00
|
|
|
|
uint sector = 2;
|
|
|
|
|
|
uint offset = 0;
|
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc)
|
2017-07-25 22:23:51 +01:00
|
|
|
|
{
|
|
|
|
|
|
sector = 0;
|
|
|
|
|
|
offset = 0x400;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(sector + partition.Start >= partition.End)
|
|
|
|
|
|
return false;
|
2014-07-09 19:49:14 +01:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
byte[] minixSbSector = imagePlugin.ReadSector(sector + partition.Start);
|
2017-07-25 22:23:51 +01:00
|
|
|
|
|
|
|
|
|
|
// Optical media
|
|
|
|
|
|
if(offset > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] tmp = new byte[0x200];
|
2017-12-22 08:43:22 +00:00
|
|
|
|
Array.Copy(minixSbSector, offset, tmp, 0, 0x200);
|
|
|
|
|
|
minixSbSector = tmp;
|
2017-07-25 22:23:51 +01:00
|
|
|
|
}
|
2012-08-05 18:13:48 +00:00
|
|
|
|
|
2018-06-20 22:22:21 +01:00
|
|
|
|
ushort magic = BitConverter.ToUInt16(minixSbSector, 0x010);
|
2016-04-19 02:11:47 +01:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(magic == MINIX_MAGIC ||
|
|
|
|
|
|
magic == MINIX_MAGIC2 ||
|
|
|
|
|
|
magic == MINIX2_MAGIC ||
|
|
|
|
|
|
magic == MINIX2_MAGIC2 ||
|
|
|
|
|
|
magic == MINIX_CIGAM ||
|
|
|
|
|
|
magic == MINIX_CIGAM2 ||
|
|
|
|
|
|
magic == MINIX2_CIGAM ||
|
|
|
|
|
|
magic == MINIX2_CIGAM2)
|
|
|
|
|
|
return true;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
magic = BitConverter.ToUInt16(minixSbSector, 0x018); // Here should reside magic number on Minix v3
|
2014-04-14 02:29:13 +00:00
|
|
|
|
|
2018-06-20 22:22:21 +01:00
|
|
|
|
return magic == MINIX_MAGIC || magic == MINIX2_MAGIC || magic == MINIX3_MAGIC || magic == MINIX_CIGAM ||
|
|
|
|
|
|
magic == MINIX2_CIGAM || magic == MINIX3_CIGAM;
|
2014-04-14 02:29:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-17 13:56:05 +01:00
|
|
|
|
/// <inheritdoc />
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Encoding encoding)
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2018-06-22 08:08:38 +01:00
|
|
|
|
Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15");
|
2014-04-14 02:29:13 +00:00
|
|
|
|
information = "";
|
2016-04-19 02:11:47 +01:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
var sb = new StringBuilder();
|
2012-08-05 18:13:48 +00:00
|
|
|
|
|
2017-07-25 22:23:51 +01:00
|
|
|
|
uint sector = 2;
|
|
|
|
|
|
uint offset = 0;
|
|
|
|
|
|
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(imagePlugin.Info.XmlMediaType == XmlMediaType.OpticalDisc)
|
2017-07-25 22:23:51 +01:00
|
|
|
|
{
|
|
|
|
|
|
sector = 0;
|
|
|
|
|
|
offset = 0x400;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 08:08:38 +01:00
|
|
|
|
bool minix3 = false;
|
|
|
|
|
|
int filenamesize;
|
2014-04-14 02:29:13 +00:00
|
|
|
|
string minixVersion;
|
2017-12-22 08:43:22 +00:00
|
|
|
|
byte[] minixSbSector = imagePlugin.ReadSector(sector + partition.Start);
|
2017-07-25 22:23:51 +01:00
|
|
|
|
|
|
|
|
|
|
// Optical media
|
|
|
|
|
|
if(offset > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] tmp = new byte[0x200];
|
2017-12-22 08:43:22 +00:00
|
|
|
|
Array.Copy(minixSbSector, offset, tmp, 0, 0x200);
|
|
|
|
|
|
minixSbSector = tmp;
|
2017-07-25 22:23:51 +01:00
|
|
|
|
}
|
2012-08-05 18:13:48 +00:00
|
|
|
|
|
2018-06-20 22:22:21 +01:00
|
|
|
|
ushort magic = BitConverter.ToUInt16(minixSbSector, 0x018);
|
2012-08-05 18:13:48 +00:00
|
|
|
|
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType = new FileSystemType();
|
2015-12-05 17:10:27 +00:00
|
|
|
|
|
2017-12-21 16:07:20 +00:00
|
|
|
|
bool littleEndian;
|
2017-07-23 21:01:26 +01:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(magic == MINIX3_MAGIC ||
|
|
|
|
|
|
magic == MINIX3_CIGAM ||
|
|
|
|
|
|
magic == MINIX2_MAGIC ||
|
|
|
|
|
|
magic == MINIX2_CIGAM ||
|
|
|
|
|
|
magic == MINIX_MAGIC ||
|
|
|
|
|
|
magic == MINIX_CIGAM)
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
|
|
|
|
|
filenamesize = 60;
|
2017-12-20 17:26:28 +00:00
|
|
|
|
littleEndian = magic != MINIX3_CIGAM || magic == MINIX2_CIGAM || magic == MINIX_CIGAM;
|
2014-04-14 02:29:13 +00:00
|
|
|
|
|
2017-12-24 02:37:41 +00:00
|
|
|
|
switch(magic)
|
|
|
|
|
|
{
|
2017-12-21 04:43:29 +00:00
|
|
|
|
case MINIX3_MAGIC:
|
|
|
|
|
|
case MINIX3_CIGAM:
|
2018-06-22 08:08:38 +01:00
|
|
|
|
minixVersion = "Minix v3 filesystem";
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType.Type = "Minix v3";
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-21 04:43:29 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MINIX2_MAGIC:
|
|
|
|
|
|
case MINIX2_CIGAM:
|
2018-06-22 08:08:38 +01:00
|
|
|
|
minixVersion = "Minix 3 v2 filesystem";
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType.Type = "Minix 3 v2";
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-21 04:43:29 +00:00
|
|
|
|
break;
|
|
|
|
|
|
default:
|
2018-06-22 08:08:38 +01:00
|
|
|
|
minixVersion = "Minix 3 v1 filesystem";
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType.Type = "Minix 3 v1";
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-21 04:43:29 +00:00
|
|
|
|
break;
|
2017-07-25 02:48:04 +01:00
|
|
|
|
}
|
2015-12-05 17:10:27 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
minix3 = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
|
magic = BitConverter.ToUInt16(minixSbSector, 0x010);
|
2014-04-14 02:29:13 +00:00
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
switch(magic)
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
|
|
|
|
|
case MINIX_MAGIC:
|
2018-06-22 08:08:38 +01:00
|
|
|
|
filenamesize = 14;
|
|
|
|
|
|
minixVersion = "Minix v1 filesystem";
|
|
|
|
|
|
littleEndian = true;
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType.Type = "Minix v1";
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MINIX_MAGIC2:
|
2018-06-22 08:08:38 +01:00
|
|
|
|
filenamesize = 30;
|
|
|
|
|
|
minixVersion = "Minix v1 filesystem";
|
|
|
|
|
|
littleEndian = true;
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType.Type = "Minix v1";
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MINIX2_MAGIC:
|
2018-06-22 08:08:38 +01:00
|
|
|
|
filenamesize = 14;
|
|
|
|
|
|
minixVersion = "Minix v2 filesystem";
|
|
|
|
|
|
littleEndian = true;
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType.Type = "Minix v2";
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MINIX2_MAGIC2:
|
2018-06-22 08:08:38 +01:00
|
|
|
|
filenamesize = 30;
|
|
|
|
|
|
minixVersion = "Minix v2 filesystem";
|
|
|
|
|
|
littleEndian = true;
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType.Type = "Minix v2";
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MINIX_CIGAM:
|
2018-06-22 08:08:38 +01:00
|
|
|
|
filenamesize = 14;
|
|
|
|
|
|
minixVersion = "Minix v1 filesystem";
|
|
|
|
|
|
littleEndian = false;
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType.Type = "Minix v1";
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MINIX_CIGAM2:
|
2018-06-22 08:08:38 +01:00
|
|
|
|
filenamesize = 30;
|
|
|
|
|
|
minixVersion = "Minix v1 filesystem";
|
|
|
|
|
|
littleEndian = false;
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType.Type = "Minix v1";
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MINIX2_CIGAM:
|
2018-06-22 08:08:38 +01:00
|
|
|
|
filenamesize = 14;
|
|
|
|
|
|
minixVersion = "Minix v2 filesystem";
|
|
|
|
|
|
littleEndian = false;
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType.Type = "Minix v2";
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
break;
|
|
|
|
|
|
case MINIX2_CIGAM2:
|
2018-06-22 08:08:38 +01:00
|
|
|
|
filenamesize = 30;
|
|
|
|
|
|
minixVersion = "Minix v2 filesystem";
|
|
|
|
|
|
littleEndian = false;
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType.Type = "Minix v2";
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
break;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
default: return;
|
2014-04-14 02:29:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(minix3)
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2020-07-22 13:20:25 +01:00
|
|
|
|
SuperBlock3 mnxSb = littleEndian ? Marshal.ByteArrayToStructureLittleEndian<SuperBlock3>(minixSbSector)
|
|
|
|
|
|
: Marshal.ByteArrayToStructureBigEndian<SuperBlock3>(minixSbSector);
|
2012-08-05 18:13:48 +00:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
if(magic != MINIX3_MAGIC &&
|
|
|
|
|
|
magic != MINIX3_CIGAM)
|
|
|
|
|
|
mnxSb.s_blocksize = 1024;
|
2017-07-25 02:48:04 +01:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
sb.AppendLine(minixVersion);
|
|
|
|
|
|
sb.AppendFormat("{0} chars in filename", filenamesize).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
if(mnxSb.s_zones > 0) // On V2
|
2020-02-29 18:03:35 +00:00
|
|
|
|
sb.AppendFormat("{0} zones on volume ({1} bytes)", mnxSb.s_zones, mnxSb.s_zones * 1024).
|
|
|
|
|
|
AppendLine();
|
2017-07-25 02:48:04 +01:00
|
|
|
|
else
|
2020-02-29 18:03:35 +00:00
|
|
|
|
sb.AppendFormat("{0} zones on volume ({1} bytes)", mnxSb.s_nzones, mnxSb.s_nzones * 1024).
|
|
|
|
|
|
AppendLine();
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("{0} bytes/block", mnxSb.s_blocksize).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} inodes on volume", mnxSb.s_ninodes).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("{0} blocks on inode map ({1} bytes)", mnxSb.s_imap_blocks,
|
|
|
|
|
|
mnxSb.s_imap_blocks * mnxSb.s_blocksize).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("{0} blocks on zone map ({1} bytes)", mnxSb.s_zmap_blocks,
|
|
|
|
|
|
mnxSb.s_zmap_blocks * mnxSb.s_blocksize).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("First data zone: {0}", mnxSb.s_firstdatazone).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
//sb.AppendFormat("log2 of blocks/zone: {0}", mnx_sb.s_log_zone_size).AppendLine(); // Apparently 0
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("{0} bytes maximum per file", mnxSb.s_max_size).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("On-disk filesystem version: {0}", mnxSb.s_disk_version).AppendLine();
|
2015-12-05 17:10:27 +00:00
|
|
|
|
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType.ClusterSize = mnxSb.s_blocksize;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
XmlFsType.Clusters = mnxSb.s_zones > 0 ? mnxSb.s_zones : mnxSb.s_nzones;
|
2014-04-14 02:29:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2020-07-22 13:20:25 +01:00
|
|
|
|
SuperBlock mnxSb = littleEndian ? Marshal.ByteArrayToStructureLittleEndian<SuperBlock>(minixSbSector)
|
|
|
|
|
|
: Marshal.ByteArrayToStructureBigEndian<SuperBlock>(minixSbSector);
|
2012-08-05 18:13:48 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
sb.AppendLine(minixVersion);
|
|
|
|
|
|
sb.AppendFormat("{0} chars in filename", filenamesize).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
if(mnxSb.s_zones > 0) // On V2
|
2020-02-29 18:03:35 +00:00
|
|
|
|
sb.AppendFormat("{0} zones on volume ({1} bytes)", mnxSb.s_zones, mnxSb.s_zones * 1024).
|
|
|
|
|
|
AppendLine();
|
2014-04-14 02:29:13 +00:00
|
|
|
|
else
|
2020-02-29 18:03:35 +00:00
|
|
|
|
sb.AppendFormat("{0} zones on volume ({1} bytes)", mnxSb.s_nzones, mnxSb.s_nzones * 1024).
|
|
|
|
|
|
AppendLine();
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("{0} inodes on volume", mnxSb.s_ninodes).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
sb.AppendFormat("{0} blocks on inode map ({1} bytes)", mnxSb.s_imap_blocks, mnxSb.s_imap_blocks * 1024).
|
|
|
|
|
|
AppendLine();
|
|
|
|
|
|
|
|
|
|
|
|
sb.AppendFormat("{0} blocks on zone map ({1} bytes)", mnxSb.s_zmap_blocks, mnxSb.s_zmap_blocks * 1024).
|
|
|
|
|
|
AppendLine();
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("First data zone: {0}", mnxSb.s_firstdatazone).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
//sb.AppendFormat("log2 of blocks/zone: {0}", mnx_sb.s_log_zone_size).AppendLine(); // Apparently 0
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("{0} bytes maximum per file", mnxSb.s_max_size).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("Filesystem state: {0:X4}", mnxSb.s_state).AppendLine();
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType.ClusterSize = 1024;
|
2018-06-22 08:08:38 +01:00
|
|
|
|
XmlFsType.Clusters = mnxSb.s_zones > 0 ? mnxSb.s_zones : mnxSb.s_nzones;
|
2014-04-14 02:29:13 +00:00
|
|
|
|
}
|
2018-06-22 08:08:38 +01:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
information = sb.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
/// <summary>Superblock for Minix v1 and V2 filesystems</summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
2020-11-11 04:19:18 +00:00
|
|
|
|
readonly struct SuperBlock
|
2017-12-24 02:37:41 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>0x00, inodes on volume</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ushort s_ninodes;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x02, zones on volume</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ushort s_nzones;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x04, blocks on inode map</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly short s_imap_blocks;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x06, blocks on zone map</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly short s_zmap_blocks;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x08, first data zone</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ushort s_firstdatazone;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x0A, log2 of blocks/zone</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly short s_log_zone_size;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x0C, max file size</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly uint s_max_size;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x10, magic</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ushort s_magic;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x12, filesystem state</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ushort s_state;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x14, number of zones</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly uint s_zones;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
/// <summary>Superblock for Minix v3 filesystems</summary>
|
2017-12-24 02:37:41 +00:00
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
2020-07-20 21:11:32 +01:00
|
|
|
|
struct SuperBlock3
|
2017-12-24 02:37:41 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>0x00, inodes on volume</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly uint s_ninodes;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x02, old zones on volume</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ushort s_nzones;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x06, blocks on inode map</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ushort s_imap_blocks;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x08, blocks on zone map</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ushort s_zmap_blocks;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x0A, first data zone</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ushort s_firstdatazone;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x0C, log2 of blocks/zone</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ushort s_log_zone_size;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x0E, padding</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ushort s_pad1;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x10, max file size</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly uint s_max_size;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x14, number of zones</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly uint s_zones;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x18, magic</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ushort s_magic;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x1A, padding</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly ushort s_pad2;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
/// <summary>0x1C, bytes in a block</summary>
|
|
|
|
|
|
public ushort s_blocksize;
|
|
|
|
|
|
/// <summary>0x1E, on-disk structures version</summary>
|
2020-02-29 18:03:35 +00:00
|
|
|
|
public readonly byte s_disk_version;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
}
|
2014-04-14 02:29:13 +00:00
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|