[Aaru.Filesystems] Reformat and cleanup.

This commit is contained in:
2023-10-03 23:22:08 +01:00
parent 51f35c80d9
commit 7a608e0061
296 changed files with 21000 additions and 18286 deletions

View File

@@ -28,25 +28,25 @@
// Commit count
using commitcnt_t = System.Int32;
using commitcnt_t = int;
// Disk address
using daddr_t = System.Int32;
using daddr_t = int;
// Fstore
using fstore_t = System.Int32;
using fstore_t = int;
// Global File System number
using gfs_t = System.Int32;
using gfs_t = int;
// Inode number
using ino_t = System.Int32;
using ino_t = int;
// Filesystem pack number
using pckno_t = System.Int16;
using pckno_t = short;
// Timestamp
using time_t = System.Int32;
using time_t = int;
// ReSharper disable UnusedMember.Local
// ReSharper disable UnusedType.Local

View File

@@ -30,25 +30,25 @@
using System;
using System.Diagnostics.CodeAnalysis;
using commitcnt_t = System.Int32;
using commitcnt_t = int;
// Disk address
using daddr_t = System.Int32;
using daddr_t = int;
// Fstore
using fstore_t = System.Int32;
using fstore_t = int;
// Global File System number
using gfs_t = System.Int32;
using gfs_t = int;
// Inode number
using ino_t = System.Int32;
using ino_t = int;
// Filesystem pack number
using pckno_t = System.Int16;
using pckno_t = short;
// Timestamp
using time_t = System.Int32;
using time_t = int;
// ReSharper disable UnusedMember.Local
// ReSharper disable UnusedType.Local
@@ -59,26 +59,40 @@ namespace Aaru.Filesystems;
/// <summary>Implements detection of the Locus filesystem</summary>
public sealed partial class Locus
{
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"),
Flags]
#region Nested type: Flags
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")]
[Flags]
enum Flags : ushort
{
SB_RDONLY = 0x1, /* no writes on filesystem */ SB_CLEAN = 0x2, /* fs unmounted cleanly (or checks run) */
SB_DIRTY = 0x4, /* fs mounted without CLEAN bit set */ SB_RMV = 0x8, /* fs is a removable file system */
SB_PRIMPACK = 0x10, /* This is the primary pack of the filesystem */
SB_REPLTYPE = 0x20, /* This is a replicated type filesystem. */
SB_USER = 0x40, /* This is a "user" replicated filesystem. */
SB_BACKBONE = 0x80, /* backbone pack ; complete copy of primary pack but not modifiable */
SB_RDONLY = 0x1, /* no writes on filesystem */
SB_CLEAN = 0x2, /* fs unmounted cleanly (or checks run) */
SB_DIRTY = 0x4, /* fs mounted without CLEAN bit set */
SB_RMV = 0x8, /* fs is a removable file system */
SB_PRIMPACK = 0x10, /* This is the primary pack of the filesystem */
SB_REPLTYPE = 0x20, /* This is a replicated type filesystem. */
SB_USER = 0x40, /* This is a "user" replicated filesystem. */
SB_BACKBONE = 0x80, /* backbone pack ; complete copy of primary pack but not modifiable */
SB_NFS = 0x100, /* This is a NFS type filesystem */
SB_BYHAND = 0x200, /* Inhibits automatic fscks on a mangled file system */
SB_NOSUID = 0x400, /* Set-uid/Set-gid is disabled */ SB_SYNCW = 0x800 /* Synchronous Write */
SB_NOSUID = 0x400, /* Set-uid/Set-gid is disabled */
SB_SYNCW = 0x800 /* Synchronous Write */
}
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"),
Flags]
#endregion
#region Nested type: Version
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")]
[Flags]
enum Version : byte
{
SB_SB4096 = 1, /* smallblock filesys with 4096 byte blocks */ SB_B1024 = 2, /* 1024 byte block filesystem */
NUMSCANDEV = 5 /* Used by scangfs(), refed in space.h */
SB_SB4096 = 1, /* smallblock filesys with 4096 byte blocks */
SB_B1024 = 2, /* 1024 byte block filesystem */
NUMSCANDEV = 5 /* Used by scangfs(), refed in space.h */
}
#endregion
}

View File

@@ -34,26 +34,26 @@ using Aaru.CommonTypes.Enums;
using Aaru.CommonTypes.Interfaces;
using Aaru.Console;
using Aaru.Helpers;
using commitcnt_t = System.Int32;
using commitcnt_t = int;
// Disk address
using daddr_t = System.Int32;
using daddr_t = int;
// Fstore
using fstore_t = System.Int32;
using fstore_t = int;
// Global File System number
using gfs_t = System.Int32;
using gfs_t = int;
// Inode number
using ino_t = System.Int32;
using ino_t = int;
using Partition = Aaru.CommonTypes.Partition;
// Filesystem pack number
using pckno_t = System.Int16;
using pckno_t = short;
// Timestamp
using time_t = System.Int32;
using time_t = int;
// ReSharper disable UnusedMember.Local
// ReSharper disable UnusedType.Local
@@ -64,6 +64,8 @@ namespace Aaru.Filesystems;
/// <summary>Implements detection of the Locus filesystem</summary>
public sealed partial class Locus
{
#region IFilesystem Members
/// <inheritdoc />
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
@@ -72,7 +74,7 @@ public sealed partial class Locus
for(ulong location = 0; location <= 8; location++)
{
uint sbSize = (uint)(Marshal.SizeOf<Superblock>() / imagePlugin.Info.SectorSize);
var sbSize = (uint)(Marshal.SizeOf<Superblock>() / imagePlugin.Info.SectorSize);
if(Marshal.SizeOf<Superblock>() % imagePlugin.Info.SectorSize != 0)
sbSize++;
@@ -115,7 +117,7 @@ public sealed partial class Locus
for(ulong location = 0; location <= 8; location++)
{
uint sbSize = (uint)(Marshal.SizeOf<Superblock>() / imagePlugin.Info.SectorSize);
var sbSize = (uint)(Marshal.SizeOf<Superblock>() / imagePlugin.Info.SectorSize);
if(Marshal.SizeOf<Superblock>() % imagePlugin.Info.SectorSize != 0)
sbSize++;
@@ -150,7 +152,8 @@ public sealed partial class Locus
var sb = new StringBuilder();
sb.AppendLine(locusSb.s_magic == LOCUS_MAGIC_OLD ? Localization.Locus_filesystem_old
sb.AppendLine(locusSb.s_magic == LOCUS_MAGIC_OLD
? Localization.Locus_filesystem_old
: Localization.Locus_filesystem);
int blockSize = locusSb.s_version == Version.SB_SB4096 ? 4096 : 1024;
@@ -162,26 +165,26 @@ public sealed partial class Locus
string s_fpack = StringHandlers.CToString(locusSb.s_fpack, encoding);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_magic = 0x{0:X8}", locusSb.s_magic);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_gfs = {0}", locusSb.s_gfs);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_fsize = {0}", locusSb.s_fsize);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_lwm = {0}", locusSb.s_lwm);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_hwm = {0}", locusSb.s_hwm);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_llst = {0}", locusSb.s_llst);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_fstore = {0}", locusSb.s_fstore);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_time = {0}", locusSb.s_time);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_tfree = {0}", locusSb.s_tfree);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_isize = {0}", locusSb.s_isize);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_nfree = {0}", locusSb.s_nfree);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_flags = {0}", locusSb.s_flags);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_tinode = {0}", locusSb.s_tinode);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_lasti = {0}", locusSb.s_lasti);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_nbehind = {0}", locusSb.s_nbehind);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_gfspack = {0}", locusSb.s_gfspack);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_ninode = {0}", locusSb.s_ninode);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_flock = {0}", locusSb.s_flock);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_ilock = {0}", locusSb.s_ilock);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_fmod = {0}", locusSb.s_fmod);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_version = {0}", locusSb.s_version);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_gfs = {0}", locusSb.s_gfs);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_fsize = {0}", locusSb.s_fsize);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_lwm = {0}", locusSb.s_lwm);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_hwm = {0}", locusSb.s_hwm);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_llst = {0}", locusSb.s_llst);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_fstore = {0}", locusSb.s_fstore);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_time = {0}", locusSb.s_time);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_tfree = {0}", locusSb.s_tfree);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_isize = {0}", locusSb.s_isize);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_nfree = {0}", locusSb.s_nfree);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_flags = {0}", locusSb.s_flags);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_tinode = {0}", locusSb.s_tinode);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_lasti = {0}", locusSb.s_lasti);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_nbehind = {0}", locusSb.s_nbehind);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_gfspack = {0}", locusSb.s_gfspack);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_ninode = {0}", locusSb.s_ninode);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_flock = {0}", locusSb.s_flock);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_ilock = {0}", locusSb.s_ilock);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_fmod = {0}", locusSb.s_fmod);
AaruConsole.DebugWriteLine(MODULE_NAME, "LocusSb.s_version = {0}", locusSb.s_version);
sb.AppendFormat(Localization.Superblock_last_modified_on_0, DateHandlers.UnixToDateTime(locusSb.s_time)).
AppendLine();
@@ -233,9 +236,9 @@ public sealed partial class Locus
if(locusSb.s_flags.HasFlag(Flags.SB_SYNCW))
sb.AppendLine(Localization.Volume_uses_synchronous_writes);
sb.AppendFormat(Localization.Volume_label_0, s_fsmnt).AppendLine();
sb.AppendFormat(Localization.Physical_volume_name_0, s_fpack).AppendLine();
sb.AppendFormat(Localization.Global_File_System_number_0, locusSb.s_gfs).AppendLine();
sb.AppendFormat(Localization.Volume_label_0, s_fsmnt).AppendLine();
sb.AppendFormat(Localization.Physical_volume_name_0, s_fpack).AppendLine();
sb.AppendFormat(Localization.Global_File_System_number_0, locusSb.s_gfs).AppendLine();
sb.AppendFormat(Localization.Global_File_System_pack_number_0, locusSb.s_gfspack).AppendLine();
information = sb.ToString();
@@ -253,4 +256,6 @@ public sealed partial class Locus
FreeClusters = (ulong)locusSb.s_tfree
};
}
#endregion
}

View File

@@ -30,25 +30,25 @@
using System;
using Aaru.CommonTypes.Interfaces;
using commitcnt_t = System.Int32;
using commitcnt_t = int;
// Disk address
using daddr_t = System.Int32;
using daddr_t = int;
// Fstore
using fstore_t = System.Int32;
using fstore_t = int;
// Global File System number
using gfs_t = System.Int32;
using gfs_t = int;
// Inode number
using ino_t = System.Int32;
using ino_t = int;
// Filesystem pack number
using pckno_t = System.Int16;
using pckno_t = short;
// Timestamp
using time_t = System.Int32;
using time_t = int;
// ReSharper disable UnusedMember.Local
// ReSharper disable UnusedType.Local
@@ -59,11 +59,18 @@ namespace Aaru.Filesystems;
/// <summary>Implements detection of the Locus filesystem</summary>
public sealed partial class Locus : IFilesystem
{
const string MODULE_NAME = "Locus plugin";
#region IFilesystem Members
/// <inheritdoc />
public string Name => Localization.Locus_Name;
/// <inheritdoc />
public Guid Id => new("1A70B30A-437D-479A-88E1-D0C9C1797FF4");
/// <inheritdoc />
public string Author => Authors.NataliaPortillo;
const string MODULE_NAME = "Locus plugin";
#endregion
}

View File

@@ -30,25 +30,25 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using commitcnt_t = System.Int32;
using commitcnt_t = int;
// Disk address
using daddr_t = System.Int32;
using daddr_t = int;
// Fstore
using fstore_t = System.Int32;
using fstore_t = int;
// Global File System number
using gfs_t = System.Int32;
using gfs_t = int;
// Inode number
using ino_t = System.Int32;
using ino_t = int;
// Filesystem pack number
using pckno_t = System.Int16;
using pckno_t = short;
// Timestamp
using time_t = System.Int32;
using time_t = int;
// ReSharper disable UnusedMember.Local
// ReSharper disable UnusedType.Local
@@ -59,8 +59,71 @@ namespace Aaru.Filesystems;
/// <summary>Implements detection of the Locus filesystem</summary>
public sealed partial class Locus
{
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"),
StructLayout(LayoutKind.Sequential, Pack = 1)]
#region Nested type: OldSuperblock
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")]
[StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct OldSuperblock
{
public readonly uint s_magic; /* identifies this as a locus filesystem */
/* defined as a constant below */
public readonly gfs_t s_gfs; /* global filesystem number */
public readonly daddr_t s_fsize; /* size in blocks of entire volume */
/* several ints for replicated filsystems */
public readonly commitcnt_t s_lwm; /* all prior commits propagated */
public readonly commitcnt_t s_hwm; /* highest commit propagated */
/* oldest committed version in the list.
* llst mod NCMTLST is the offset of commit #llst in the list,
* which wraps around from there.
*/
public readonly commitcnt_t s_llst;
public readonly fstore_t s_fstore; /* filesystem storage bit mask; if the
filsys is replicated and this is not a
primary or backbone copy, this bit mask
determines which files are stored */
public readonly time_t s_time; /* last super block update */
public readonly daddr_t s_tfree; /* total free blocks*/
public readonly ino_t s_isize; /* size in blocks of i-list */
public readonly short s_nfree; /* number of addresses in s_free */
public readonly Flags s_flags; /* filsys flags, defined below */
public readonly ino_t s_tinode; /* total free inodes */
public readonly ino_t s_lasti; /* start place for circular search */
public readonly ino_t s_nbehind; /* est # free inodes before s_lasti */
public readonly pckno_t s_gfspack; /* global filesystem pack number */
public readonly short s_ninode; /* number of i-nodes in s_inode */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public readonly short[] s_dinfo; /* interleave stuff */
//#define s_m s_dinfo[0]
//#define s_skip s_dinfo[0] /* AIX defines */
//#define s_n s_dinfo[1]
//#define s_cyl s_dinfo[1] /* AIX defines */
public readonly byte s_flock; /* lock during free list manipulation */
public readonly byte s_ilock; /* lock during i-list manipulation */
public readonly byte s_fmod; /* super block modified flag */
public readonly Version s_version; /* version of the data format in fs. */
/* defined below. */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] s_fsmnt; /* name of this file system */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public readonly byte[] s_fpack; /* name of this physical volume */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = OLDNICINOD)]
public readonly ino_t[] s_inode; /* free i-node list */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = OLDNICFREE)]
public readonly daddr_t[] su_free; /* free block list for non-replicated filsys */
public readonly byte s_byteorder; /* byte order of integers */
}
#endregion
#region Nested type: Superblock
[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle")]
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct Superblock
{
public readonly uint s_magic; /* identifies this as a locus filesystem */
@@ -114,58 +177,5 @@ public sealed partial class Locus
public readonly byte s_byteorder; /* byte order of integers */
}
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "BuiltInTypeReferenceStyle"),
StructLayout(LayoutKind.Sequential, Pack = 1)]
readonly struct OldSuperblock
{
public readonly uint s_magic; /* identifies this as a locus filesystem */
/* defined as a constant below */
public readonly gfs_t s_gfs; /* global filesystem number */
public readonly daddr_t s_fsize; /* size in blocks of entire volume */
/* several ints for replicated filsystems */
public readonly commitcnt_t s_lwm; /* all prior commits propagated */
public readonly commitcnt_t s_hwm; /* highest commit propagated */
/* oldest committed version in the list.
* llst mod NCMTLST is the offset of commit #llst in the list,
* which wraps around from there.
*/
public readonly commitcnt_t s_llst;
public readonly fstore_t s_fstore; /* filesystem storage bit mask; if the
filsys is replicated and this is not a
primary or backbone copy, this bit mask
determines which files are stored */
public readonly time_t s_time; /* last super block update */
public readonly daddr_t s_tfree; /* total free blocks*/
public readonly ino_t s_isize; /* size in blocks of i-list */
public readonly short s_nfree; /* number of addresses in s_free */
public readonly Flags s_flags; /* filsys flags, defined below */
public readonly ino_t s_tinode; /* total free inodes */
public readonly ino_t s_lasti; /* start place for circular search */
public readonly ino_t s_nbehind; /* est # free inodes before s_lasti */
public readonly pckno_t s_gfspack; /* global filesystem pack number */
public readonly short s_ninode; /* number of i-nodes in s_inode */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public readonly short[] s_dinfo; /* interleave stuff */
//#define s_m s_dinfo[0]
//#define s_skip s_dinfo[0] /* AIX defines */
//#define s_n s_dinfo[1]
//#define s_cyl s_dinfo[1] /* AIX defines */
public readonly byte s_flock; /* lock during free list manipulation */
public readonly byte s_ilock; /* lock during i-list manipulation */
public readonly byte s_fmod; /* super block modified flag */
public readonly Version s_version; /* version of the data format in fs. */
/* defined below. */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public readonly byte[] s_fsmnt; /* name of this file system */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public readonly byte[] s_fpack; /* name of this physical volume */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = OLDNICINOD)]
public readonly ino_t[] s_inode; /* free i-node list */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = OLDNICFREE)]
public readonly daddr_t[] su_free; /* free block list for non-replicated filsys */
public readonly byte s_byteorder; /* byte order of integers */
}
#endregion
}