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
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
2022-12-07 13:07:31 +00:00
|
|
|
|
// Filename : Info.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : UnixWare boot filesystem plugin.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-12-03 16:07:10 +00:00
|
|
|
|
// Copyright © 2011-2023 Natalia Portillo
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// ****************************************************************************/
|
2014-04-17 19:58:14 +00:00
|
|
|
|
|
2012-08-06 21:21:14 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Text;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using Aaru.CommonTypes.AaruMetadata;
|
2021-09-19 21:16:47 +01:00
|
|
|
|
using Aaru.CommonTypes.Enums;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
|
|
|
|
|
using Aaru.Console;
|
2020-07-20 15:43:52 +01:00
|
|
|
|
using Aaru.Helpers;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using Partition = Aaru.CommonTypes.Partition;
|
2015-10-18 22:04:03 +01:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
namespace Aaru.Filesystems;
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
// Information from the Linux kernel
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
/// <summary>Implements detection of the UNIX boot filesystem</summary>
|
2022-12-07 13:07:31 +00:00
|
|
|
|
public sealed partial class BFS
|
2012-08-06 21:21:14 +00:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(2 + partition.Start >= partition.End)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] tmp);
|
2014-07-09 19:49:14 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
|
return false;
|
2021-09-19 21:16:47 +01:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
uint magic = BitConverter.ToUInt32(tmp, 0);
|
2021-09-19 21:16:47 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return magic == BFS_MAGIC;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2022-12-17 22:41:56 +00:00
|
|
|
|
public void GetInformation(IMediaImage imagePlugin, Partition partition, Encoding encoding, out string information,
|
|
|
|
|
|
out FileSystem metadata)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
2022-12-17 23:17:18 +00:00
|
|
|
|
encoding ??= Encoding.GetEncoding("iso-8859-15");
|
|
|
|
|
|
information = "";
|
|
|
|
|
|
metadata = new FileSystem();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] bfsSbSector);
|
2014-04-14 02:29:13 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
|
return;
|
2012-08-06 21:21:14 +00:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
byte[] sbStrings = new byte[6];
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
|
|
var bfsSb = new SuperBlock
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
s_magic = BitConverter.ToUInt32(bfsSbSector, 0x00),
|
|
|
|
|
|
s_start = BitConverter.ToUInt32(bfsSbSector, 0x04),
|
|
|
|
|
|
s_end = BitConverter.ToUInt32(bfsSbSector, 0x08),
|
|
|
|
|
|
s_from = BitConverter.ToUInt32(bfsSbSector, 0x0C),
|
|
|
|
|
|
s_to = BitConverter.ToUInt32(bfsSbSector, 0x10),
|
|
|
|
|
|
s_bfrom = BitConverter.ToInt32(bfsSbSector, 0x14),
|
|
|
|
|
|
s_bto = BitConverter.ToInt32(bfsSbSector, 0x18)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Array.Copy(bfsSbSector, 0x1C, sbStrings, 0, 6);
|
2022-12-17 23:17:18 +00:00
|
|
|
|
bfsSb.s_fsname = StringHandlers.CToString(sbStrings, encoding);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Array.Copy(bfsSbSector, 0x22, sbStrings, 0, 6);
|
2022-12-17 23:17:18 +00:00
|
|
|
|
bfsSb.s_volume = StringHandlers.CToString(sbStrings, encoding);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2023-10-03 17:47:32 +01:00
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "bfs_sb.s_magic: 0x{0:X8}", bfsSb.s_magic);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "bfs_sb.s_start: 0x{0:X8}", bfsSb.s_start);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "bfs_sb.s_end: 0x{0:X8}", bfsSb.s_end);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "bfs_sb.s_from: 0x{0:X8}", bfsSb.s_from);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "bfs_sb.s_to: 0x{0:X8}", bfsSb.s_to);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "bfs_sb.s_bfrom: 0x{0:X8}", bfsSb.s_bfrom);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "bfs_sb.s_bto: 0x{0:X8}", bfsSb.s_bto);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "bfs_sb.s_fsname: 0x{0}", bfsSb.s_fsname);
|
|
|
|
|
|
AaruConsole.DebugWriteLine(MODULE_NAME, "bfs_sb.s_volume: 0x{0}", bfsSb.s_volume);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.UNIX_Boot_Filesystem);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendFormat(Localization.Volume_goes_from_byte_0_to_byte_1_for_2_bytes, bfsSb.s_start, bfsSb.s_end,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
bfsSb.s_end - bfsSb.s_start).AppendLine();
|
|
|
|
|
|
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendFormat(Localization.Filesystem_name_0, bfsSb.s_fsname).AppendLine();
|
|
|
|
|
|
sb.AppendFormat(Localization.Volume_name_0, bfsSb.s_volume).AppendLine();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
2022-12-17 22:41:56 +00:00
|
|
|
|
metadata = new FileSystem
|
2017-12-24 02:37:41 +00:00
|
|
|
|
{
|
2022-11-28 02:59:53 +00:00
|
|
|
|
Type = FS_TYPE,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
VolumeName = bfsSb.s_volume,
|
|
|
|
|
|
ClusterSize = imagePlugin.Info.SectorSize,
|
|
|
|
|
|
Clusters = partition.End - partition.Start + 1
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
information = sb.ToString();
|
|
|
|
|
|
}
|
2014-04-14 01:14:20 +00:00
|
|
|
|
}
|