2022-12-07 13:07:31 +00:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// Aaru Data Preservation Suite
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : Info.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : Veritas File System 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2024-05-01 04:17:32 +01:00
|
|
|
|
// Copyright © 2011-2024 Natalia Portillo
|
2022-12-07 13:07:31 +00:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Text;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using Aaru.CommonTypes.AaruMetadata;
|
2022-12-07 13:07:31 +00:00
|
|
|
|
using Aaru.CommonTypes.Enums;
|
|
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
|
|
|
|
|
using Aaru.Helpers;
|
2022-12-15 22:21:07 +00:00
|
|
|
|
using Partition = Aaru.CommonTypes.Partition;
|
2022-12-07 13:07:31 +00:00
|
|
|
|
|
|
|
|
|
|
namespace Aaru.Filesystems;
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
/// <summary>Implements detection of the Veritas filesystem</summary>
|
|
|
|
|
|
public sealed partial class VxFS
|
|
|
|
|
|
{
|
2023-10-03 23:22:08 +01:00
|
|
|
|
#region IFilesystem Members
|
|
|
|
|
|
|
2022-12-07 13:07:31 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
|
|
|
|
|
{
|
|
|
|
|
|
ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize;
|
|
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(partition.Start + vmfsSuperOff >= partition.End) return false;
|
2022-12-07 13:07:31 +00:00
|
|
|
|
|
|
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector);
|
|
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(errno != ErrorNumber.NoError) return false;
|
2022-12-07 13:07:31 +00:00
|
|
|
|
|
2023-10-03 23:22:08 +01:00
|
|
|
|
var magic = BitConverter.ToUInt32(sector, 0x00);
|
2022-12-07 13:07:31 +00:00
|
|
|
|
|
|
|
|
|
|
return magic == VXFS_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-12-07 13:07:31 +00:00
|
|
|
|
{
|
2022-12-17 23:17:18 +00:00
|
|
|
|
encoding ??= Encoding.UTF8;
|
|
|
|
|
|
information = "";
|
|
|
|
|
|
metadata = new FileSystem();
|
2022-12-07 13:07:31 +00:00
|
|
|
|
ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize;
|
|
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector);
|
|
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(errno != ErrorNumber.NoError) return;
|
2022-12-07 13:07:31 +00:00
|
|
|
|
|
|
|
|
|
|
SuperBlock vxSb = Marshal.ByteArrayToStructureLittleEndian<SuperBlock>(sector);
|
|
|
|
|
|
|
|
|
|
|
|
var sbInformation = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
sbInformation.AppendLine(Localization.Veritas_file_system);
|
|
|
|
|
|
|
|
|
|
|
|
sbInformation.AppendFormat(Localization.Volume_version_0, vxSb.vs_version).AppendLine();
|
|
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
sbInformation.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(vxSb.vs_fname, encoding))
|
|
|
|
|
|
.AppendLine();
|
2022-12-07 13:07:31 +00:00
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
sbInformation.AppendFormat(Localization.Volume_has_0_blocks_of_1_bytes_each, vxSb.vs_bsize, vxSb.vs_size)
|
|
|
|
|
|
.AppendLine();
|
2022-12-07 13:07:31 +00:00
|
|
|
|
|
|
|
|
|
|
sbInformation.AppendFormat(Localization.Volume_has_0_inodes_per_block, vxSb.vs_inopb).AppendLine();
|
2023-10-03 23:22:08 +01:00
|
|
|
|
sbInformation.AppendFormat(Localization.Volume_has_0_free_inodes, vxSb.vs_ifree).AppendLine();
|
|
|
|
|
|
sbInformation.AppendFormat(Localization.Volume_has_0_free_blocks, vxSb.vs_free).AppendLine();
|
2022-12-07 13:07:31 +00:00
|
|
|
|
|
|
|
|
|
|
sbInformation.AppendFormat(Localization.Volume_created_on_0,
|
2024-05-01 04:05:22 +01:00
|
|
|
|
DateHandlers.UnixUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime))
|
|
|
|
|
|
.AppendLine();
|
2022-12-07 13:07:31 +00:00
|
|
|
|
|
|
|
|
|
|
sbInformation.AppendFormat(Localization.Volume_last_modified_on_0,
|
2024-05-01 04:05:22 +01:00
|
|
|
|
DateHandlers.UnixUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime))
|
|
|
|
|
|
.AppendLine();
|
2022-12-07 13:07:31 +00:00
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(vxSb.vs_clean != 0) sbInformation.AppendLine(Localization.Volume_is_dirty);
|
2022-12-07 13:07:31 +00:00
|
|
|
|
|
|
|
|
|
|
information = sbInformation.ToString();
|
|
|
|
|
|
|
2022-12-17 22:41:56 +00:00
|
|
|
|
metadata = new FileSystem
|
2022-12-07 13:07:31 +00:00
|
|
|
|
{
|
2022-12-15 22:21:07 +00:00
|
|
|
|
Type = FS_TYPE,
|
|
|
|
|
|
CreationDate = DateHandlers.UnixUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime),
|
|
|
|
|
|
ModificationDate = DateHandlers.UnixUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime),
|
|
|
|
|
|
Clusters = (ulong)vxSb.vs_size,
|
|
|
|
|
|
ClusterSize = (uint)vxSb.vs_bsize,
|
|
|
|
|
|
Dirty = vxSb.vs_clean != 0,
|
|
|
|
|
|
FreeClusters = (ulong)vxSb.vs_free
|
2022-12-07 13:07:31 +00:00
|
|
|
|
};
|
|
|
|
|
|
}
|
2023-10-03 23:22:08 +01:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
2022-12-07 13:07:31 +00:00
|
|
|
|
}
|