using System.Runtime.InteropServices;
namespace Aaru.Filesystems
{
public partial class OperaFS
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct SuperBlock
{
/// 0x000, Record type, must be 1
public readonly byte record_type;
/// 0x001, 5 bytes, "ZZZZZ"
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public readonly byte[] sync_bytes;
/// 0x006, Record version, must be 1
public readonly byte record_version;
/// 0x007, Volume flags
public readonly byte volume_flags;
/// 0x008, 32 bytes, volume comment
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)]
public readonly byte[] volume_comment;
/// 0x028, 32 bytes, volume label
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)]
public readonly byte[] volume_label;
/// 0x048, Volume ID
public readonly uint volume_id;
/// 0x04C, Block size in bytes
public readonly uint block_size;
/// 0x050, Blocks in volume
public readonly uint block_count;
/// 0x054, Root directory ID
public readonly uint root_dirid;
/// 0x058, Root directory blocks
public readonly uint rootdir_blocks;
/// 0x05C, Root directory block size
public readonly uint rootdir_bsize;
/// 0x060, Last root directory copy
public readonly uint last_root_copy;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct DirectoryHeader
{
/// Next block from this directory, -1 if last
public readonly int next_block;
/// Previous block from this directory, -1 if first
public readonly int prev_block;
/// Directory flags
public readonly uint flags;
/// Offset to first free unused byte in the directory
public readonly uint first_free;
/// Offset to first directory entry
public readonly uint first_used;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct DirectoryEntry
{
/// File flags, see
public readonly uint flags;
/// Unique file identifier
public readonly uint id;
/// Entry type
public readonly uint type;
/// Block size
public readonly uint block_size;
/// Size in bytes
public readonly uint byte_count;
/// Block count
public readonly uint block_count;
/// Unknown
public readonly uint burst;
/// Unknown
public readonly uint gap;
/// Filename
[MarshalAs(UnmanagedType.ByValArray, SizeConst = MAX_NAME)]
public readonly byte[] name;
/// Last copy
public readonly uint last_copy;
}
class DirectoryEntryWithPointers
{
public DirectoryEntry entry;
public uint[] pointers;
}
}
}