2017-07-19 16:31:08 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2016-09-14 02:31:20 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : VxFS.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : Veritas File System plugin.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Identifies the Veritas file system 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-02-18 10:02:53 +00:00
|
|
|
|
// Copyright © 2011-2022 Natalia Portillo
|
2016-09-14 02:31:20 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
namespace Aaru.Filesystems;
|
|
|
|
|
|
|
2016-09-14 02:31:20 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
using System.Text;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes;
|
2021-09-19 21:16:47 +01:00
|
|
|
|
using Aaru.CommonTypes.Enums;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
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;
|
2016-09-14 02:31:20 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
/// <summary>Implements detection of the Veritas filesystem</summary>
|
|
|
|
|
|
public sealed class VxFS : IFilesystem
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>Identifier for VxFS</summary>
|
|
|
|
|
|
const uint VXFS_MAGIC = 0xA501FCF5;
|
|
|
|
|
|
const uint VXFS_BASE = 0x400;
|
2017-10-12 23:54:02 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public FileSystemType XmlFsType { get; private set; }
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public Encoding Encoding { get; private set; }
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public string Name => "Veritas filesystem";
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public Guid Id => new("EC372605-7687-453C-8BEA-7E0DFF79CB03");
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public string Author => "Natalia Portillo";
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
|
|
|
|
|
{
|
|
|
|
|
|
ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(partition.Start + vmfsSuperOff >= partition.End)
|
|
|
|
|
|
return false;
|
2021-09-19 21:16:47 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector);
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
|
return false;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
var magic = BitConverter.ToUInt32(sector, 0x00);
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return magic == VXFS_MAGIC;
|
|
|
|
|
|
}
|
2021-09-19 21:16:47 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
2022-03-07 07:36:44 +00:00
|
|
|
|
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
Encoding = encoding ?? Encoding.UTF8;
|
|
|
|
|
|
information = "";
|
|
|
|
|
|
ulong vmfsSuperOff = VXFS_BASE / imagePlugin.Info.SectorSize;
|
|
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(partition.Start + vmfsSuperOff, out byte[] sector);
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
|
return;
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
SuperBlock vxSb = Marshal.ByteArrayToStructureLittleEndian<SuperBlock>(sector);
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
var sbInformation = new StringBuilder();
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sbInformation.AppendLine("Veritas file system");
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sbInformation.AppendFormat("Volume version {0}", vxSb.vs_version).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
sbInformation.AppendFormat("Volume name {0}", StringHandlers.CToString(vxSb.vs_fname, Encoding)).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
sbInformation.AppendFormat("Volume has {0} blocks of {1} bytes each", vxSb.vs_bsize, vxSb.vs_size).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sbInformation.AppendFormat("Volume has {0} inodes per block", vxSb.vs_inopb).AppendLine();
|
|
|
|
|
|
sbInformation.AppendFormat("Volume has {0} free inodes", vxSb.vs_ifree).AppendLine();
|
|
|
|
|
|
sbInformation.AppendFormat("Volume has {0} free blocks", vxSb.vs_free).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sbInformation.AppendFormat("Volume created on {0}",
|
|
|
|
|
|
DateHandlers.UnixUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime)).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
sbInformation.AppendFormat("Volume last modified on {0}",
|
|
|
|
|
|
DateHandlers.UnixUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime)).AppendLine();
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(vxSb.vs_clean != 0)
|
|
|
|
|
|
sbInformation.AppendLine("Volume is dirty");
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
information = sbInformation.ToString();
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
XmlFsType = new FileSystemType
|
2016-09-14 02:31:20 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Type = "Veritas file system",
|
|
|
|
|
|
CreationDate = DateHandlers.UnixUnsignedToDateTime(vxSb.vs_ctime, vxSb.vs_cutime),
|
|
|
|
|
|
CreationDateSpecified = true,
|
|
|
|
|
|
ModificationDate = DateHandlers.UnixUnsignedToDateTime(vxSb.vs_wtime, vxSb.vs_wutime),
|
|
|
|
|
|
ModificationDateSpecified = true,
|
|
|
|
|
|
Clusters = (ulong)vxSb.vs_size,
|
|
|
|
|
|
ClusterSize = (uint)vxSb.vs_bsize,
|
|
|
|
|
|
Dirty = vxSb.vs_clean != 0,
|
|
|
|
|
|
FreeClusters = (ulong)vxSb.vs_free,
|
|
|
|
|
|
FreeClustersSpecified = true
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
readonly struct SuperBlock
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>Magic number</summary>
|
|
|
|
|
|
public readonly uint vs_magic;
|
|
|
|
|
|
/// <summary>VxFS version</summary>
|
|
|
|
|
|
public readonly int vs_version;
|
|
|
|
|
|
/// <summary>create time - secs</summary>
|
|
|
|
|
|
public readonly uint vs_ctime;
|
|
|
|
|
|
/// <summary>create time - usecs</summary>
|
|
|
|
|
|
public readonly uint vs_cutime;
|
|
|
|
|
|
/// <summary>unused</summary>
|
|
|
|
|
|
public readonly int __unused1;
|
|
|
|
|
|
/// <summary>unused</summary>
|
|
|
|
|
|
public readonly int __unused2;
|
|
|
|
|
|
/// <summary>obsolete</summary>
|
|
|
|
|
|
public readonly int vs_old_logstart;
|
|
|
|
|
|
/// <summary>obsolete</summary>
|
|
|
|
|
|
public readonly int vs_old_logend;
|
|
|
|
|
|
/// <summary>block size</summary>
|
|
|
|
|
|
public readonly int vs_bsize;
|
|
|
|
|
|
/// <summary>number of blocks</summary>
|
|
|
|
|
|
public readonly int vs_size;
|
|
|
|
|
|
/// <summary>number of data blocks</summary>
|
|
|
|
|
|
public readonly int vs_dsize;
|
|
|
|
|
|
/// <summary>obsolete</summary>
|
|
|
|
|
|
public readonly uint vs_old_ninode;
|
|
|
|
|
|
/// <summary>obsolete</summary>
|
|
|
|
|
|
public readonly int vs_old_nau;
|
|
|
|
|
|
/// <summary>unused</summary>
|
|
|
|
|
|
public readonly int __unused3;
|
|
|
|
|
|
/// <summary>obsolete</summary>
|
|
|
|
|
|
public readonly int vs_old_defiextsize;
|
|
|
|
|
|
/// <summary>obsolete</summary>
|
|
|
|
|
|
public readonly int vs_old_ilbsize;
|
|
|
|
|
|
/// <summary>size of immediate data area</summary>
|
|
|
|
|
|
public readonly int vs_immedlen;
|
|
|
|
|
|
/// <summary>number of direct extentes</summary>
|
|
|
|
|
|
public readonly int vs_ndaddr;
|
|
|
|
|
|
/// <summary>address of first AU</summary>
|
|
|
|
|
|
public readonly int vs_firstau;
|
|
|
|
|
|
/// <summary>offset of extent map in AU</summary>
|
|
|
|
|
|
public readonly int vs_emap;
|
|
|
|
|
|
/// <summary>offset of inode map in AU</summary>
|
|
|
|
|
|
public readonly int vs_imap;
|
|
|
|
|
|
/// <summary>offset of ExtOp. map in AU</summary>
|
|
|
|
|
|
public readonly int vs_iextop;
|
|
|
|
|
|
/// <summary>offset of inode list in AU</summary>
|
|
|
|
|
|
public readonly int vs_istart;
|
|
|
|
|
|
/// <summary>offset of fdblock in AU</summary>
|
|
|
|
|
|
public readonly int vs_bstart;
|
|
|
|
|
|
/// <summary>aufirst + emap</summary>
|
|
|
|
|
|
public readonly int vs_femap;
|
|
|
|
|
|
/// <summary>aufirst + imap</summary>
|
|
|
|
|
|
public readonly int vs_fimap;
|
|
|
|
|
|
/// <summary>aufirst + iextop</summary>
|
|
|
|
|
|
public readonly int vs_fiextop;
|
|
|
|
|
|
/// <summary>aufirst + istart</summary>
|
|
|
|
|
|
public readonly int vs_fistart;
|
|
|
|
|
|
/// <summary>aufirst + bstart</summary>
|
|
|
|
|
|
public readonly int vs_fbstart;
|
|
|
|
|
|
/// <summary>number of entries in indir</summary>
|
|
|
|
|
|
public readonly int vs_nindir;
|
|
|
|
|
|
/// <summary>length of AU in blocks</summary>
|
|
|
|
|
|
public readonly int vs_aulen;
|
|
|
|
|
|
/// <summary>length of imap in blocks</summary>
|
|
|
|
|
|
public readonly int vs_auimlen;
|
|
|
|
|
|
/// <summary>length of emap in blocks</summary>
|
|
|
|
|
|
public readonly int vs_auemlen;
|
|
|
|
|
|
/// <summary>length of ilist in blocks</summary>
|
|
|
|
|
|
public readonly int vs_auilen;
|
|
|
|
|
|
/// <summary>length of pad in blocks</summary>
|
|
|
|
|
|
public readonly int vs_aupad;
|
|
|
|
|
|
/// <summary>data blocks in AU</summary>
|
|
|
|
|
|
public readonly int vs_aublocks;
|
|
|
|
|
|
/// <summary>log base 2 of aublocks</summary>
|
|
|
|
|
|
public readonly int vs_maxtier;
|
|
|
|
|
|
/// <summary>number of inodes per blk</summary>
|
|
|
|
|
|
public readonly int vs_inopb;
|
|
|
|
|
|
/// <summary>obsolete</summary>
|
|
|
|
|
|
public readonly int vs_old_inopau;
|
|
|
|
|
|
/// <summary>obsolete</summary>
|
|
|
|
|
|
public readonly int vs_old_inopilb;
|
|
|
|
|
|
/// <summary>obsolete</summary>
|
|
|
|
|
|
public readonly int vs_old_ndiripau;
|
|
|
|
|
|
/// <summary>size of indirect addr ext.</summary>
|
|
|
|
|
|
public readonly int vs_iaddrlen;
|
|
|
|
|
|
/// <summary>log base 2 of bsize</summary>
|
|
|
|
|
|
public readonly int vs_bshift;
|
|
|
|
|
|
/// <summary>log base 2 of inobp</summary>
|
|
|
|
|
|
public readonly int vs_inoshift;
|
|
|
|
|
|
/// <summary>~( bsize - 1 )</summary>
|
|
|
|
|
|
public readonly int vs_bmask;
|
|
|
|
|
|
/// <summary>bsize - 1</summary>
|
|
|
|
|
|
public readonly int vs_boffmask;
|
|
|
|
|
|
/// <summary>old_inopilb - 1</summary>
|
|
|
|
|
|
public readonly int vs_old_inomask;
|
|
|
|
|
|
/// <summary>checksum of V1 data</summary>
|
|
|
|
|
|
public readonly int vs_checksum;
|
|
|
|
|
|
/// <summary>number of free blocks</summary>
|
|
|
|
|
|
public readonly int vs_free;
|
|
|
|
|
|
/// <summary>number of free inodes</summary>
|
|
|
|
|
|
public readonly int vs_ifree;
|
|
|
|
|
|
/// <summary>number of free extents by size</summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
|
|
|
|
|
|
public readonly int[] vs_efree;
|
|
|
|
|
|
/// <summary>flags ?!?</summary>
|
|
|
|
|
|
public readonly int vs_flags;
|
|
|
|
|
|
/// <summary>filesystem has been changed</summary>
|
|
|
|
|
|
public readonly byte vs_mod;
|
|
|
|
|
|
/// <summary>clean FS</summary>
|
|
|
|
|
|
public readonly byte vs_clean;
|
|
|
|
|
|
/// <summary>unused</summary>
|
|
|
|
|
|
public readonly ushort __unused4;
|
|
|
|
|
|
/// <summary>mount time log ID</summary>
|
|
|
|
|
|
public readonly uint vs_firstlogid;
|
|
|
|
|
|
/// <summary>last time written - sec</summary>
|
|
|
|
|
|
public readonly uint vs_wtime;
|
|
|
|
|
|
/// <summary>last time written - usec</summary>
|
|
|
|
|
|
public readonly uint vs_wutime;
|
|
|
|
|
|
/// <summary>FS name</summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
|
|
|
|
|
|
public readonly byte[] vs_fname;
|
|
|
|
|
|
/// <summary>FS pack name</summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
|
|
|
|
|
|
public readonly byte[] vs_fpack;
|
|
|
|
|
|
/// <summary>log format version</summary>
|
|
|
|
|
|
public readonly int vs_logversion;
|
|
|
|
|
|
/// <summary>unused</summary>
|
|
|
|
|
|
public readonly int __unused5;
|
|
|
|
|
|
/// <summary>OLT extent and replica</summary>
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
|
|
|
|
|
public readonly int[] vs_oltext;
|
|
|
|
|
|
/// <summary>OLT extent size</summary>
|
|
|
|
|
|
public readonly int vs_oltsize;
|
|
|
|
|
|
/// <summary>size of inode map</summary>
|
|
|
|
|
|
public readonly int vs_iauimlen;
|
|
|
|
|
|
/// <summary>size of IAU in blocks</summary>
|
|
|
|
|
|
public readonly int vs_iausize;
|
|
|
|
|
|
/// <summary>size of inode in bytes</summary>
|
|
|
|
|
|
public readonly int vs_dinosize;
|
|
|
|
|
|
/// <summary>indir levels per inode</summary>
|
|
|
|
|
|
public readonly int vs_old_dniaddr;
|
|
|
|
|
|
/// <summary>checksum of V2 RO</summary>
|
|
|
|
|
|
public readonly int vs_checksum2;
|
2016-09-14 02:31:20 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|