2020-03-11 21:56:55 +00:00
|
|
|
// /***************************************************************************
|
|
|
|
|
// Aaru Data Preservation Suite
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : Structs.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
|
|
|
|
// Component : Opera 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
|
2020-03-11 21:56:55 +00:00
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
using System.Runtime.InteropServices;
|
2022-12-19 00:26:55 +00:00
|
|
|
using Aaru.CommonTypes.Interfaces;
|
2022-03-07 07:36:44 +00:00
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
namespace Aaru.Filesystems;
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public sealed partial class OperaFS
|
2019-08-01 16:21:10 +01:00
|
|
|
{
|
2023-10-03 23:22:08 +01:00
|
|
|
#region Nested type: DirectoryEntry
|
2019-08-01 17:00:30 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
readonly struct DirectoryEntry
|
|
|
|
|
{
|
|
|
|
|
/// <summary>File flags, see <see cref="FileFlags" /></summary>
|
|
|
|
|
public readonly uint flags;
|
|
|
|
|
/// <summary>Unique file identifier</summary>
|
|
|
|
|
public readonly uint id;
|
|
|
|
|
/// <summary>Entry type</summary>
|
|
|
|
|
public readonly uint type;
|
|
|
|
|
/// <summary>Block size</summary>
|
|
|
|
|
public readonly uint block_size;
|
|
|
|
|
/// <summary>Size in bytes</summary>
|
|
|
|
|
public readonly uint byte_count;
|
|
|
|
|
/// <summary>Block count</summary>
|
|
|
|
|
public readonly uint block_count;
|
|
|
|
|
/// <summary>Unknown</summary>
|
|
|
|
|
public readonly uint burst;
|
|
|
|
|
/// <summary>Unknown</summary>
|
|
|
|
|
public readonly uint gap;
|
|
|
|
|
/// <summary>Filename</summary>
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)]
|
|
|
|
|
public readonly byte[] name;
|
|
|
|
|
/// <summary>Last copy</summary>
|
|
|
|
|
public readonly uint last_copy;
|
|
|
|
|
}
|
2019-08-01 23:10:52 +01:00
|
|
|
|
2023-10-03 23:22:08 +01:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Nested type: DirectoryEntryWithPointers
|
|
|
|
|
|
2022-11-15 01:35:06 +00:00
|
|
|
sealed class DirectoryEntryWithPointers
|
2022-03-06 13:29:38 +00:00
|
|
|
{
|
|
|
|
|
public DirectoryEntry Entry;
|
|
|
|
|
public uint[] Pointers;
|
2019-08-01 16:21:10 +01:00
|
|
|
}
|
2022-12-19 00:26:55 +00:00
|
|
|
|
2023-10-03 23:22:08 +01:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Nested type: DirectoryHeader
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
readonly struct DirectoryHeader
|
|
|
|
|
{
|
|
|
|
|
/// <summary>Next block from this directory, -1 if last</summary>
|
|
|
|
|
public readonly int next_block;
|
|
|
|
|
/// <summary>Previous block from this directory, -1 if first</summary>
|
|
|
|
|
public readonly int prev_block;
|
|
|
|
|
/// <summary>Directory flags</summary>
|
|
|
|
|
public readonly uint flags;
|
|
|
|
|
/// <summary>Offset to first free unused byte in the directory</summary>
|
|
|
|
|
public readonly uint first_free;
|
|
|
|
|
/// <summary>Offset to first directory entry</summary>
|
|
|
|
|
public readonly uint first_used;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Nested type: OperaDirNode
|
|
|
|
|
|
|
|
|
|
sealed class OperaDirNode : IDirNode
|
|
|
|
|
{
|
|
|
|
|
internal string[] _contents;
|
|
|
|
|
internal int _position;
|
|
|
|
|
|
|
|
|
|
#region IDirNode Members
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
public string Path { get; init; }
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Nested type: OperaFileNode
|
|
|
|
|
|
2022-12-19 00:26:55 +00:00
|
|
|
sealed class OperaFileNode : IFileNode
|
|
|
|
|
{
|
|
|
|
|
internal DirectoryEntryWithPointers _dentry;
|
2023-10-03 23:22:08 +01:00
|
|
|
|
|
|
|
|
#region IFileNode Members
|
|
|
|
|
|
2022-12-19 00:26:55 +00:00
|
|
|
/// <inheritdoc />
|
|
|
|
|
public string Path { get; init; }
|
2023-10-03 23:22:08 +01:00
|
|
|
|
2022-12-19 00:26:55 +00:00
|
|
|
/// <inheritdoc />
|
|
|
|
|
public long Length { get; init; }
|
2023-10-03 23:22:08 +01:00
|
|
|
|
2022-12-19 00:26:55 +00:00
|
|
|
/// <inheritdoc />
|
2022-12-19 00:38:54 +00:00
|
|
|
public long Offset { get; set; }
|
2023-10-03 23:22:08 +01:00
|
|
|
|
|
|
|
|
#endregion
|
2022-12-19 00:26:55 +00:00
|
|
|
}
|
2022-12-21 19:10:51 +00:00
|
|
|
|
2023-10-03 23:22:08 +01:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Nested type: SuperBlock
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
readonly struct SuperBlock
|
2022-12-21 19:10:51 +00:00
|
|
|
{
|
2023-10-03 23:22:08 +01:00
|
|
|
/// <summary>0x000, Record type, must be 1</summary>
|
|
|
|
|
public readonly byte record_type;
|
|
|
|
|
/// <summary>0x001, 5 bytes, "ZZZZZ"</summary>
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
|
|
|
|
|
public readonly byte[] sync_bytes;
|
|
|
|
|
/// <summary>0x006, Record version, must be 1</summary>
|
|
|
|
|
public readonly byte record_version;
|
|
|
|
|
/// <summary>0x007, Volume flags</summary>
|
|
|
|
|
public readonly byte volume_flags;
|
|
|
|
|
/// <summary>0x008, 32 bytes, volume comment</summary>
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)]
|
|
|
|
|
public readonly byte[] volume_comment;
|
|
|
|
|
/// <summary>0x028, 32 bytes, volume label</summary>
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)]
|
|
|
|
|
public readonly byte[] volume_label;
|
|
|
|
|
/// <summary>0x048, Volume ID</summary>
|
|
|
|
|
public readonly uint volume_id;
|
|
|
|
|
/// <summary>0x04C, Block size in bytes</summary>
|
|
|
|
|
public readonly uint block_size;
|
|
|
|
|
/// <summary>0x050, Blocks in volume</summary>
|
|
|
|
|
public readonly uint block_count;
|
|
|
|
|
/// <summary>0x054, Root directory ID</summary>
|
|
|
|
|
public readonly uint root_dirid;
|
|
|
|
|
/// <summary>0x058, Root directory blocks</summary>
|
|
|
|
|
public readonly uint rootdir_blocks;
|
|
|
|
|
/// <summary>0x05C, Root directory block size</summary>
|
|
|
|
|
public readonly uint rootdir_bsize;
|
|
|
|
|
/// <summary>0x060, Last root directory copy</summary>
|
|
|
|
|
public readonly uint last_root_copy;
|
2022-12-21 19:10:51 +00:00
|
|
|
}
|
2023-10-03 23:22:08 +01:00
|
|
|
|
|
|
|
|
#endregion
|
2019-08-01 16:21:10 +01:00
|
|
|
}
|