[UNICOS] Use new source generator based big endian marshaller

This commit is contained in:
2025-10-21 03:44:54 +01:00
parent 555b90a07a
commit 50f2daf7dc
2 changed files with 55 additions and 51 deletions

View File

@@ -61,7 +61,7 @@ public sealed partial class UNICOS
if(sector.Length < Marshal.SizeOf<Superblock>()) return false;
Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(sector);
Superblock unicosSb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sector);
AaruLogging.Debug(MODULE_NAME, Localization.magic_equals_0_expected_1, unicosSb.s_magic, UNICOS_MAGIC);
@@ -88,7 +88,7 @@ public sealed partial class UNICOS
if(sector.Length < Marshal.SizeOf<Superblock>()) return;
Superblock unicosSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(sector);
Superblock unicosSb = Marshal.ByteArrayToStructureBigEndianGenerated<Superblock>(sector);
if(unicosSb.s_magic != UNICOS_MAGIC) return;

View File

@@ -30,6 +30,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using Aaru.CommonTypes.Attributes;
using blkno_t = long;
using daddr_t = long;
using dev_t = long;
@@ -47,13 +48,14 @@ public sealed partial class UNICOS
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[SuppressMessage("ReSharper", "InconsistentNaming")]
readonly struct nc1fdev_sb
[SwapEndian]
partial struct nc1fdev_sb
{
public readonly long fd_name; /* Physical device name */
public readonly uint fd_sblk; /* Start block number */
public readonly uint fd_nblk; /* Number of blocks */
public long fd_name; /* Physical device name */
public uint fd_sblk; /* Start block number */
public uint fd_nblk; /* Number of blocks */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NC1_MAXIREG)]
public readonly nc1ireg_sb[] fd_ireg; /* Inode regions */
public nc1ireg_sb[] fd_ireg; /* Inode regions */
}
#endregion
@@ -62,11 +64,12 @@ public sealed partial class UNICOS
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[SuppressMessage("ReSharper", "InconsistentNaming")]
readonly struct nc1ireg_sb
[SwapEndian]
partial struct nc1ireg_sb
{
public readonly ushort i_unused; /* reserved */
public readonly ushort i_nblk; /* number of blocks */
public readonly uint i_sblk; /* start block number */
public ushort i_unused; /* reserved */
public ushort i_nblk; /* number of blocks */
public uint i_sblk; /* start block number */
}
#endregion
@@ -76,66 +79,67 @@ public sealed partial class UNICOS
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")]
readonly struct Superblock
[SwapEndian]
partial struct Superblock
{
public readonly ulong s_magic; /* magic number to indicate file system type */
public ulong s_magic; /* magic number to indicate file system type */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public readonly byte[] s_fname; /* file system name */
public byte[] s_fname; /* file system name */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public readonly byte[] s_fpack; /* file system pack name */
public readonly dev_t s_dev; /* major/minor device, for verification */
public byte[] s_fpack; /* file system pack name */
public dev_t s_dev; /* major/minor device, for verification */
public readonly daddr_t s_fsize; /* size in blocks of entire volume */
public readonly long s_isize; /* Number of total inodes */
public readonly long s_bigfile; /* number of bytes at which a file is big */
public readonly long s_bigunit; /* minimum number of blocks allocated for big files */
public readonly ulong s_secure; /* security: secure FS label */
public readonly long s_maxlvl; /* security: maximum security level */
public readonly long s_minlvl; /* security: minimum security level */
public readonly long s_valcmp; /* security: valid security compartments */
public readonly time_t s_time; /* last super block update */
public readonly blkno_t s_dboff; /* Dynamic block number */
public readonly ino_t s_root; /* root inode */
public readonly long s_error; /* Type of file system error detected */
public readonly blkno_t s_mapoff; /* Start map block number */
public readonly long s_mapblks; /* Last map block number */
public readonly long s_nscpys; /* Number of copies of s.b per partition */
public readonly long s_npart; /* Number of partitions */
public readonly long s_ifract; /* Ratio of inodes to blocks */
public readonly extent_t s_sfs; /* SFS only blocks */
public readonly long s_flag; /* Flag word */
public daddr_t s_fsize; /* size in blocks of entire volume */
public long s_isize; /* Number of total inodes */
public long s_bigfile; /* number of bytes at which a file is big */
public long s_bigunit; /* minimum number of blocks allocated for big files */
public ulong s_secure; /* security: secure FS label */
public long s_maxlvl; /* security: maximum security level */
public long s_minlvl; /* security: minimum security level */
public long s_valcmp; /* security: valid security compartments */
public time_t s_time; /* last super block update */
public blkno_t s_dboff; /* Dynamic block number */
public ino_t s_root; /* root inode */
public long s_error; /* Type of file system error detected */
public blkno_t s_mapoff; /* Start map block number */
public long s_mapblks; /* Last map block number */
public long s_nscpys; /* Number of copies of s.b per partition */
public long s_npart; /* Number of partitions */
public long s_ifract; /* Ratio of inodes to blocks */
public extent_t s_sfs; /* SFS only blocks */
public long s_flag; /* Flag word */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NC1_MAXPART)]
public readonly nc1fdev_sb[] s_part; /* Partition descriptors */
public readonly long s_iounit; /* Physical block size */
public readonly long s_numiresblks; /* number of inode reservation blocks */
public nc1fdev_sb[] s_part; /* Partition descriptors */
public long s_iounit; /* Physical block size */
public long s_numiresblks; /* number of inode reservation blocks */
/* per region (currently 1) */
/* 0 = 1*(AU) words, n = (n+1)*(AU) words */
public readonly long s_priparts; /* bitmap of primary partitions */
public readonly long s_priblock; /* block size of primary partition(s) */
public long s_priparts; /* bitmap of primary partitions */
public long s_priblock; /* block size of primary partition(s) */
/* 0 = 1*512 words, n = (n+1)*512 words */
public readonly long s_prinblks; /* number of 512 wds blocks in primary */
public readonly long s_secparts; /* bitmap of secondary partitions */
public readonly long s_secblock; /* block size of secondary partition(s) */
public long s_prinblks; /* number of 512 wds blocks in primary */
public long s_secparts; /* bitmap of secondary partitions */
public long s_secblock; /* block size of secondary partition(s) */
/* 0 = 1*512 words, n = (n+1)*512 words */
public readonly long s_secnblks; /* number of 512 wds blocks in secondary */
public readonly long s_sbdbparts; /* bitmap of partitions with file system data */
public long s_secnblks; /* number of 512 wds blocks in secondary */
public long s_sbdbparts; /* bitmap of partitions with file system data */
/* including super blocks, dynamic block */
/* and free block bitmaps (only primary */
/* partitions may contain these) */
public readonly long s_rootdparts; /* bitmap of partitions with root directory */
public long s_rootdparts; /* bitmap of partitions with root directory */
/* (only primary partitions) */
public readonly long s_nudparts; /* bitmap of no-user-data partitions */
public long s_nudparts; /* bitmap of no-user-data partitions */
/* (only primary partitions) */
public readonly long s_nsema; /* SFS: # fs semaphores to allocate */
public readonly long s_priactive; /* bitmap of primary partitions which contain */
public long s_nsema; /* SFS: # fs semaphores to allocate */
public long s_priactive; /* bitmap of primary partitions which contain */
/* active (up to date) dynamic blocks and */
/* free block bitmaps. All bits set indicate */
/* that all primary partitions are active, */
/* and no kernel manipulation of active flag */
/* is allowed. */
public readonly long s_sfs_arbiterid; /* SFS Arbiter ID */
public long s_sfs_arbiterid; /* SFS Arbiter ID */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 91)]
public readonly long[] s_fill; /* reserved */
public long[] s_fill; /* reserved */
}
#endregion