diff --git a/Aaru.Filesystems/FFS/Info.cs b/Aaru.Filesystems/FFS/Info.cs index 1e82f9bc6..632eb3fb3 100644 --- a/Aaru.Filesystems/FFS/Info.cs +++ b/Aaru.Filesystems/FFS/Info.cs @@ -76,7 +76,7 @@ public sealed partial class FFSPlugin if(errno != ErrorNumber.NoError) continue; - uint magic = BitConverter.ToUInt32(ufsSbSectors, 0x055C); + var magic = BitConverter.ToUInt32(ufsSbSectors, 0x055C); if(magic is UFS_MAGIC or UFS_CIGAM @@ -111,13 +111,13 @@ public sealed partial class FFSPlugin uint sb_size_in_sectors; byte[] ufs_sb_sectors; ulong sb_offset = partition.Start; - bool fs_type_42bsd = false; - bool fs_type_43bsd = false; - bool fs_type_44bsd = false; - bool fs_type_ufs = false; - bool fs_type_ufs2 = false; - bool fs_type_sun = false; - bool fs_type_sun86 = false; + var fs_type_42bsd = false; + var fs_type_43bsd = false; + var fs_type_44bsd = false; + var fs_type_ufs = false; + var fs_type_ufs2 = false; + var fs_type_sun = false; + var fs_type_sun86 = false; if(imagePlugin.Info.SectorSize is 2336 or 2352 or 2448) sb_size_in_sectors = block_size / 2048; @@ -220,7 +220,7 @@ public sealed partial class FFSPlugin SuperBlock sb = Marshal.ByteArrayToStructureLittleEndian(ufs_sb_sectors); - SuperBlock bs_sfu = Marshal.ByteArrayToStructureBigEndian(ufs_sb_sectors); + SuperBlock bs_sfu = Marshal.ByteArrayToStructureBigEndianGenerated(ufs_sb_sectors); if(bs_sfu.fs_magic == UFS_MAGIC && sb.fs_magic == UFS_CIGAM || bs_sfu.fs_magic == UFS_MAGIC_BW && sb.fs_magic == UFS_CIGAM_BW || diff --git a/Aaru.Filesystems/FFS/Structs.cs b/Aaru.Filesystems/FFS/Structs.cs index 7f33b7c09..8cf5e6b63 100644 --- a/Aaru.Filesystems/FFS/Structs.cs +++ b/Aaru.Filesystems/FFS/Structs.cs @@ -28,6 +28,7 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; +using Aaru.CommonTypes.Attributes; namespace Aaru.Filesystems; @@ -40,7 +41,8 @@ public sealed partial class FFSPlugin #region Nested type: Checksum [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Checksum + [SwapEndian] + partial struct Checksum { /// number of directories public int cs_ndir; @@ -57,7 +59,8 @@ public sealed partial class FFSPlugin #region Nested type: csum_total [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct csum_total + [SwapEndian] + partial struct csum_total { /// number of directories public long cs_ndir; @@ -71,7 +74,7 @@ public sealed partial class FFSPlugin public long cs_numclusters; /// future expansion [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly long[] cs_spare; + public long[] cs_spare; } #endregion @@ -79,223 +82,224 @@ public sealed partial class FFSPlugin #region Nested type: SuperBlock [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct SuperBlock + [SwapEndian] + partial struct SuperBlock { /// linked list of file systems - public readonly uint fs_link; + public uint fs_link; /// used for incore super blocks on Sun: uint fs_rolled; // logging only: fs fully rolled - public readonly uint fs_rlink; + public uint fs_rlink; /// addr of super-block in filesys - public readonly int fs_sblkno; + public int fs_sblkno; /// offset of cyl-block in filesys - public readonly int fs_cblkno; + public int fs_cblkno; /// offset of inode-blocks in filesys - public readonly int fs_iblkno; + public int fs_iblkno; /// offset of first data after cg - public readonly int fs_dblkno; + public int fs_dblkno; /// cylinder group offset in cylinder - public readonly int fs_old_cgoffset; + public int fs_old_cgoffset; /// used to calc mod fs_ntrak - public readonly int fs_old_cgmask; + public int fs_old_cgmask; /// last time written - public readonly int fs_old_time; + public int fs_old_time; /// number of blocks in fs - public readonly int fs_old_size; + public int fs_old_size; /// number of data blocks in fs - public readonly int fs_old_dsize; + public int fs_old_dsize; /// number of cylinder groups - public readonly int fs_ncg; + public int fs_ncg; /// size of basic blocks in fs - public readonly int fs_bsize; + public int fs_bsize; /// size of frag blocks in fs - public readonly int fs_fsize; + public int fs_fsize; /// number of frags in a block in fs - public readonly int fs_frag; + public int fs_frag; /* these are configuration parameters */ /// minimum percentage of free blocks - public readonly int fs_minfree; + public int fs_minfree; /// num of ms for optimal next block - public readonly int fs_old_rotdelay; + public int fs_old_rotdelay; /// disk revolutions per second - public readonly int fs_old_rps; + public int fs_old_rps; /* these fields can be computed from the others */ /// ``blkoff'' calc of blk offsets - public readonly int fs_bmask; + public int fs_bmask; /// ``fragoff'' calc of frag offsets - public readonly int fs_fmask; + public int fs_fmask; /// ``lblkno'' calc of logical blkno - public readonly int fs_bshift; + public int fs_bshift; /// ``numfrags'' calc number of frags - public readonly int fs_fshift; + public int fs_fshift; /* these are configuration parameters */ /// max number of contiguous blks - public readonly int fs_maxcontig; + public int fs_maxcontig; /// max number of blks per cyl group - public readonly int fs_maxbpg; + public int fs_maxbpg; /* these fields can be computed from the others */ /// block to frag shift - public readonly int fs_fragshift; + public int fs_fragshift; /// fsbtodb and dbtofsb shift constant - public readonly int fs_fsbtodb; + public int fs_fsbtodb; /// actual size of super block - public readonly int fs_sbsize; + public int fs_sbsize; /// csum block offset - public readonly int fs_csmask; + public int fs_csmask; /// csum block number - public readonly int fs_csshift; + public int fs_csshift; /// value of NINDIR - public readonly int fs_nindir; + public int fs_nindir; /// value of INOPB - public readonly uint fs_inopb; + public uint fs_inopb; /// value of NSPF - public readonly int fs_old_nspf; + public int fs_old_nspf; /* yet another configuration parameter */ /// optimization preference, see below On SVR: int fs_state; // file system state - public readonly int fs_optim; + public int fs_optim; /// # sectors/track including spares - public readonly int fs_old_npsect; + public int fs_old_npsect; /// hardware sector interleave - public readonly int fs_old_interleave; + public int fs_old_interleave; /// sector 0 skew, per track On A/UX: int fs_state; // file system state - public readonly int fs_old_trackskew; + public int fs_old_trackskew; /// unique filesystem id On old: int fs_headswitch; // head switch time, usec - public readonly int fs_id_1; + public int fs_id_1; /// unique filesystem id On old: int fs_trkseek; // track-to-track seek, usec - public readonly int fs_id_2; + public int fs_id_2; /* sizes determined by number of cylinder groups and their sizes */ /// blk addr of cyl grp summary area - public readonly int fs_old_csaddr; + public int fs_old_csaddr; /// size of cyl grp summary area - public readonly int fs_cssize; + public int fs_cssize; /// cylinder group size - public readonly int fs_cgsize; + public int fs_cgsize; /* these fields are derived from the hardware */ /// tracks per cylinder - public readonly int fs_old_ntrak; + public int fs_old_ntrak; /// sectors per track - public readonly int fs_old_nsect; + public int fs_old_nsect; /// sectors per cylinder - public readonly int fs_old_spc; + public int fs_old_spc; /* this comes from the disk driver partitioning */ /// cylinders in filesystem - public readonly int fs_old_ncyl; + public int fs_old_ncyl; /* these fields can be computed from the others */ /// cylinders per group - public readonly int fs_old_cpg; + public int fs_old_cpg; /// inodes per group - public readonly int fs_ipg; + public int fs_ipg; /// blocks per group * fs_frag - public readonly int fs_fpg; + public int fs_fpg; /* this data must be re-computed after crashes */ /// cylinder summary information public Checksum fs_old_cstotal; /* these fields are cleared at mount time */ /// super block modified flag - public readonly sbyte fs_fmod; + public sbyte fs_fmod; /// filesystem is clean flag - public readonly sbyte fs_clean; + public sbyte fs_clean; /// mounted read-only flag - public readonly sbyte fs_ronly; + public sbyte fs_ronly; /// old FS_ flags - public readonly sbyte fs_old_flags; + public sbyte fs_old_flags; /// name mounted on [MarshalAs(UnmanagedType.ByValArray, SizeConst = 468)] - public readonly byte[] fs_fsmnt; + public byte[] fs_fsmnt; /// volume name [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly byte[] fs_volname; + public byte[] fs_volname; /// system-wide uid - public readonly ulong fs_swuid; + public ulong fs_swuid; /// due to alignment of fs_swuid - public readonly int fs_pad; + public int fs_pad; /* these fields retain the current block allocation info */ /// last cg searched - public readonly int fs_cgrotor; + public int fs_cgrotor; /// padding; was list of fs_cs buffers [MarshalAs(UnmanagedType.ByValArray, SizeConst = 28)] - public readonly uint[] fs_ocsp; + public uint[] fs_ocsp; /// (u) # of contig. allocated dirs - public readonly uint fs_contigdirs; + public uint fs_contigdirs; /// (u) cg summary info buffer - public readonly uint fs_csp; + public uint fs_csp; /// (u) max cluster in each cyl group - public readonly uint fs_maxcluster; + public uint fs_maxcluster; /// (u) used by snapshots to track fs - public readonly uint fs_active; + public uint fs_active; /// cyl per cycle in postbl - public readonly int fs_old_cpc; + public int fs_old_cpc; /// maximum blocking factor permitted - public readonly int fs_maxbsize; + public int fs_maxbsize; /// number of unreferenced inodes - public readonly long fs_unrefs; + public long fs_unrefs; /// size of underlying GEOM provider - public readonly long fs_providersize; + public long fs_providersize; /// size of area reserved for metadata - public readonly long fs_metaspace; + public long fs_metaspace; /// old rotation block list head [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] - public readonly long[] fs_sparecon64; + public long[] fs_sparecon64; /// byte offset of standard superblock - public readonly long fs_sblockloc; + public long fs_sblockloc; /// (u) cylinder summary information public csum_total fs_cstotal; /// last time written - public readonly long fs_time; + public long fs_time; /// number of blocks in fs - public readonly long fs_size; + public long fs_size; /// number of data blocks in fs - public readonly long fs_dsize; + public long fs_dsize; /// blk addr of cyl grp summary area - public readonly long fs_csaddr; + public long fs_csaddr; /// (u) blocks being freed - public readonly long fs_pendingblocks; + public long fs_pendingblocks; /// (u) inodes being freed - public readonly uint fs_pendinginodes; + public uint fs_pendinginodes; /// list of snapshot inode numbers [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)] - public readonly uint[] fs_snapinum; + public uint[] fs_snapinum; /// expected average file size - public readonly uint fs_avgfilesize; + public uint fs_avgfilesize; /// expected # of files per directory - public readonly uint fs_avgfpdir; + public uint fs_avgfpdir; /// save real cg size to use fs_bsize - public readonly int fs_save_cgsize; + public int fs_save_cgsize; /// Last mount or fsck time. - public readonly long fs_mtime; + public long fs_mtime; /// SUJ free list - public readonly int fs_sujfree; + public int fs_sujfree; /// reserved for future constants [MarshalAs(UnmanagedType.ByValArray, SizeConst = 23)] - public readonly int[] fs_sparecon32; + public int[] fs_sparecon32; /// see FS_ flags below - public readonly int fs_flags; + public int fs_flags; /// size of cluster summary array - public readonly int fs_contigsumsize; + public int fs_contigsumsize; /// max length of an internal symlink - public readonly int fs_maxsymlinklen; + public int fs_maxsymlinklen; /// format of on-disk inodes - public readonly int fs_old_inodefmt; + public int fs_old_inodefmt; /// maximum representable file size - public readonly ulong fs_maxfilesize; + public ulong fs_maxfilesize; /// ~fs_bmask for use with 64-bit size - public readonly long fs_qbmask; + public long fs_qbmask; /// ~fs_fmask for use with 64-bit size - public readonly long fs_qfmask; + public long fs_qfmask; /// validate fs_clean field - public readonly int fs_state; + public int fs_state; /// format of positional layout tables - public readonly int fs_old_postblformat; + public int fs_old_postblformat; /// number of rotational positions - public readonly int fs_old_nrpos; + public int fs_old_nrpos; /// (short) rotation block list head - public readonly int fs_old_postbloff; + public int fs_old_postbloff; /// (uchar_t) blocks for each rotation - public readonly int fs_old_rotbloff; + public int fs_old_rotbloff; /// magic number - public readonly uint fs_magic; + public uint fs_magic; /// list of blocks for each rotation [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] - public readonly byte[] fs_rotbl; + public byte[] fs_rotbl; } #endregion