Code cleanup.

This commit is contained in:
2018-06-22 08:08:38 +01:00
parent 82f474c7e3
commit 88da8fc019
581 changed files with 22423 additions and 20839 deletions

View File

@@ -92,15 +92,15 @@ namespace DiscImageChef.Filesystems
const short TS_PCL = 8;
const int TP_NINDIR = TP_BSIZE / 2;
const int LBLSIZE = 16;
const int NAMELEN = 64;
const int LBLSIZE = 16;
const int NAMELEN = 64;
const int NDADDR = 12;
const int NIADDR = 3;
public Encoding Encoding { get; private set; }
public string Name => "dump(8) Plugin";
public Guid Id => new Guid("E53B4D28-C858-4800-B092-DDAE80D361B9");
public Encoding Encoding { get; private set; }
public string Name => "dump(8) Plugin";
public Guid Id => new Guid("E53B4D28-C858-4800-B092-DDAE80D361B9");
public FileSystemType XmlFsType { get; private set; }
public bool Identify(IMediaImage imagePlugin, Partition partition)
@@ -110,9 +110,9 @@ namespace DiscImageChef.Filesystems
// It should be start of a tape or floppy or file
if(partition.Start != 0) return false;
spcl16 oldHdr = new spcl16();
spcl16 oldHdr = new spcl16();
spcl_aix aixHdr = new spcl_aix();
s_spcl newHdr = new s_spcl();
s_spcl newHdr = new s_spcl();
uint sbSize = (uint)(Marshal.SizeOf(newHdr) / imagePlugin.Info.SectorSize);
if(Marshal.SizeOf(newHdr) % imagePlugin.Info.SectorSize != 0) sbSize++;
@@ -139,23 +139,23 @@ namespace DiscImageChef.Filesystems
DicConsole.DebugWriteLine("dump(8) plugin", "aix magic = 0x{0:X8}", aixHdr.c_magic);
DicConsole.DebugWriteLine("dump(8) plugin", "new magic = 0x{0:X8}", newHdr.c_magic);
return oldHdr.c_magic == OFS_MAGIC || aixHdr.c_magic == XIX_MAGIC || aixHdr.c_magic == XIX_CIGAM ||
newHdr.c_magic == OFS_MAGIC || newHdr.c_magic == NFS_MAGIC || newHdr.c_magic == OFS_CIGAM ||
return oldHdr.c_magic == OFS_MAGIC || aixHdr.c_magic == XIX_MAGIC || aixHdr.c_magic == XIX_CIGAM ||
newHdr.c_magic == OFS_MAGIC || newHdr.c_magic == NFS_MAGIC || newHdr.c_magic == OFS_CIGAM ||
newHdr.c_magic == NFS_CIGAM || newHdr.c_magic == UFS2_MAGIC || newHdr.c_magic == UFS2_CIGAM;
}
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
Encoding encoding)
Encoding encoding)
{
Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15");
Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15");
information = "";
if(imagePlugin.Info.SectorSize < 512) return;
if(partition.Start != 0) return;
spcl16 oldHdr = new spcl16();
spcl16 oldHdr = new spcl16();
spcl_aix aixHdr = new spcl_aix();
s_spcl newHdr = new s_spcl();
s_spcl newHdr = new s_spcl();
uint sbSize = (uint)(Marshal.SizeOf(newHdr) / imagePlugin.Info.SectorSize);
if(Marshal.SizeOf(newHdr) % imagePlugin.Info.SectorSize != 0) sbSize++;
@@ -181,7 +181,7 @@ namespace DiscImageChef.Filesystems
bool useOld = false;
bool useAix = false;
if(newHdr.c_magic == OFS_MAGIC || newHdr.c_magic == NFS_MAGIC || newHdr.c_magic == OFS_CIGAM ||
if(newHdr.c_magic == OFS_MAGIC || newHdr.c_magic == NFS_MAGIC || newHdr.c_magic == OFS_CIGAM ||
newHdr.c_magic == NFS_CIGAM || newHdr.c_magic == UFS2_MAGIC || newHdr.c_magic == UFS2_CIGAM)
{
if(newHdr.c_magic == OFS_CIGAM || newHdr.c_magic == NFS_CIGAM || newHdr.c_magic == UFS2_CIGAM)
@@ -199,7 +199,7 @@ namespace DiscImageChef.Filesystems
useOld = true;
// Swap PDP-11 endian
oldHdr.c_date = (int)Swapping.PDPFromLittleEndian((uint)oldHdr.c_date);
oldHdr.c_date = (int)Swapping.PDPFromLittleEndian((uint)oldHdr.c_date);
oldHdr.c_ddate = (int)Swapping.PDPFromLittleEndian((uint)oldHdr.c_ddate);
}
else
@@ -218,16 +218,18 @@ namespace DiscImageChef.Filesystems
sb.AppendLine(XmlFsType.Type);
if(oldHdr.c_date > 0)
{
XmlFsType.CreationDate = DateHandlers.UnixToDateTime(oldHdr.c_date);
XmlFsType.CreationDate = DateHandlers.UnixToDateTime(oldHdr.c_date);
XmlFsType.CreationDateSpecified = true;
sb.AppendFormat("Dump created on {0}", XmlFsType.CreationDate).AppendLine();
}
if(oldHdr.c_ddate > 0)
{
XmlFsType.BackupDate = DateHandlers.UnixToDateTime(oldHdr.c_ddate);
XmlFsType.BackupDate = DateHandlers.UnixToDateTime(oldHdr.c_ddate);
XmlFsType.BackupDateSpecified = true;
sb.AppendFormat("Previous dump created on {0}", XmlFsType.BackupDate).AppendLine();
}
sb.AppendFormat("Dump volume number: {0}", oldHdr.c_volume).AppendLine();
}
else if(useAix)
@@ -236,16 +238,18 @@ namespace DiscImageChef.Filesystems
sb.AppendLine(XmlFsType.Type);
if(aixHdr.c_date > 0)
{
XmlFsType.CreationDate = DateHandlers.UnixToDateTime(aixHdr.c_date);
XmlFsType.CreationDate = DateHandlers.UnixToDateTime(aixHdr.c_date);
XmlFsType.CreationDateSpecified = true;
sb.AppendFormat("Dump created on {0}", XmlFsType.CreationDate).AppendLine();
}
if(aixHdr.c_ddate > 0)
{
XmlFsType.BackupDate = DateHandlers.UnixToDateTime(aixHdr.c_ddate);
XmlFsType.BackupDate = DateHandlers.UnixToDateTime(aixHdr.c_ddate);
XmlFsType.BackupDateSpecified = true;
sb.AppendFormat("Previous dump created on {0}", XmlFsType.BackupDate).AppendLine();
}
sb.AppendFormat("Dump volume number: {0}", aixHdr.c_volume).AppendLine();
}
else
@@ -254,28 +258,30 @@ namespace DiscImageChef.Filesystems
sb.AppendLine(XmlFsType.Type);
if(newHdr.c_ndate > 0)
{
XmlFsType.CreationDate = DateHandlers.UnixToDateTime(newHdr.c_ndate);
XmlFsType.CreationDate = DateHandlers.UnixToDateTime(newHdr.c_ndate);
XmlFsType.CreationDateSpecified = true;
sb.AppendFormat("Dump created on {0}", XmlFsType.CreationDate).AppendLine();
}
else if(newHdr.c_date > 0)
{
XmlFsType.CreationDate = DateHandlers.UnixToDateTime(newHdr.c_date);
XmlFsType.CreationDate = DateHandlers.UnixToDateTime(newHdr.c_date);
XmlFsType.CreationDateSpecified = true;
sb.AppendFormat("Dump created on {0}", XmlFsType.CreationDate).AppendLine();
}
if(newHdr.c_nddate > 0)
{
XmlFsType.BackupDate = DateHandlers.UnixToDateTime(newHdr.c_nddate);
XmlFsType.BackupDate = DateHandlers.UnixToDateTime(newHdr.c_nddate);
XmlFsType.BackupDateSpecified = true;
sb.AppendFormat("Previous dump created on {0}", XmlFsType.BackupDate).AppendLine();
}
else if(newHdr.c_ddate > 0)
{
XmlFsType.BackupDate = DateHandlers.UnixToDateTime(newHdr.c_ddate);
XmlFsType.BackupDate = DateHandlers.UnixToDateTime(newHdr.c_ddate);
XmlFsType.BackupDateSpecified = true;
sb.AppendFormat("Previous dump created on {0}", XmlFsType.BackupDate).AppendLine();
}
sb.AppendFormat("Dump volume number: {0}", newHdr.c_volume).AppendLine();
sb.AppendFormat("Dump level: {0}", newHdr.c_level).AppendLine();
string dumpname = StringHandlers.CToString(newHdr.c_label);
@@ -340,7 +346,7 @@ namespace DiscImageChef.Filesystems
public int c_tapea;
public uint c_inumber;
public uint c_magic;
public int c_checksum;
public int c_checksum;
// Unneeded for now
/*
public bsd_dinode bsd_c_dinode;
@@ -354,54 +360,59 @@ namespace DiscImageChef.Filesystems
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct s_spcl
{
public int c_type; /* record type (see below) */
public int c_date; /* date of this dump */
public int c_ddate; /* date of previous dump */
public int c_volume; /* dump volume number */
public int c_tapea; /* logical block of this record */
public uint c_inumber; /* number of inode */
public int c_magic; /* magic number (see above) */
public int c_checksum; /* record checksum */
public dinode c_dinode; /* ownership and mode of inode */
public int c_count; /* number of valid c_addr entries */
public int c_type; /* record type (see below) */
public int c_date; /* date of this dump */
public int c_ddate; /* date of previous dump */
public int c_volume; /* dump volume number */
public int c_tapea; /* logical block of this record */
public uint c_inumber; /* number of inode */
public int c_magic; /* magic number (see above) */
public int c_checksum; /* record checksum */
public dinode c_dinode; /* ownership and mode of inode */
public int c_count; /* number of valid c_addr entries */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TP_NINDIR)]
public byte[] c_addr; /* 1 => data; 0 => hole in inode */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LBLSIZE)] public byte[] c_label; /* dump label */
public int c_level; /* level of this dump */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = LBLSIZE)]
public byte[] c_label; /* dump label */
public int c_level; /* level of this dump */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NAMELEN)]
public byte[] c_filesys; /* name of dumpped file system */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NAMELEN)] public byte[] c_dev; /* name of dumpped device */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NAMELEN)] public byte[] c_host; /* name of dumpped host */
public int c_flags; /* additional information */
public int c_firstrec; /* first record on volume */
public long c_ndate; /* date of this dump */
public long c_nddate; /* date of previous dump */
public long c_ntapea; /* logical block of this record */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NAMELEN)]
public byte[] c_dev; /* name of dumpped device */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NAMELEN)]
public byte[] c_host; /* name of dumpped host */
public int c_flags; /* additional information */
public int c_firstrec; /* first record on volume */
public long c_ndate; /* date of this dump */
public long c_nddate; /* date of previous dump */
public long c_ntapea; /* logical block of this record */
public long c_nfirstrec; /* first record on volume */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public int[] c_spare; /* reserved for future uses */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public int[] c_spare; /* reserved for future uses */
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct dinode
{
public ushort di_mode; /* 0: IFMT, permissions; see below. */
public short di_nlink; /* 2: File link count. */
public int inumber; /* 4: Lfs: inode number. */
public ulong di_size; /* 8: File byte count. */
public int di_atime; /* 16: Last access time. */
public int di_atimensec; /* 20: Last access time. */
public int di_mtime; /* 24: Last modified time. */
public int di_mtimensec; /* 28: Last modified time. */
public int di_ctime; /* 32: Last inode change time. */
public int di_ctimensec; /* 36: Last inode change time. */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDADDR)] public int[] di_db; /* 40: Direct disk blocks. */
public ushort di_mode; /* 0: IFMT, permissions; see below. */
public short di_nlink; /* 2: File link count. */
public int inumber; /* 4: Lfs: inode number. */
public ulong di_size; /* 8: File byte count. */
public int di_atime; /* 16: Last access time. */
public int di_atimensec; /* 20: Last access time. */
public int di_mtime; /* 24: Last modified time. */
public int di_mtimensec; /* 28: Last modified time. */
public int di_ctime; /* 32: Last inode change time. */
public int di_ctimensec; /* 36: Last inode change time. */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NDADDR)]
public int[] di_db; /* 40: Direct disk blocks. */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = NIADDR)]
public int[] di_ib; /* 88: Indirect disk blocks. */
public uint di_flags; /* 100: Status flags (chflags). */
public int[] di_ib; /* 88: Indirect disk blocks. */
public uint di_flags; /* 100: Status flags (chflags). */
public uint di_blocks; /* 104: Blocks actually held. */
public int di_gen; /* 108: Generation number. */
public uint di_uid; /* 112: File owner. */
public uint di_gid; /* 116: File group. */
public int di_gen; /* 108: Generation number. */
public uint di_uid; /* 112: File owner. */
public uint di_gid; /* 116: File group. */
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
public int[] di_spare; /* 120: Reserved; currently unused */
}