mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Move filesystem metadata to GetInformation method for information only plugins.
This commit is contained in:
@@ -63,11 +63,11 @@ public sealed partial class FAT : IReadOnlyFilesystem
|
||||
FileSystemInfo _statfs;
|
||||
bool _useFirstFat;
|
||||
|
||||
/// <inheritdoc />
|
||||
public FileSystem Metadata { get; private set; }
|
||||
/// <inheritdoc />
|
||||
public Encoding Encoding { get; private set; }
|
||||
/// <inheritdoc />
|
||||
public FileSystem Metadata { get; private set; }
|
||||
/// <inheritdoc />
|
||||
public string Name => Localization.FAT_Name;
|
||||
/// <inheritdoc />
|
||||
public Guid Id => new("33513B2C-0D26-0D2D-32C3-79D8611158E0");
|
||||
|
||||
@@ -421,13 +421,14 @@ public sealed partial class FAT
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding)
|
||||
public void GetInformation(IMediaImage imagePlugin, Partition partition, Encoding encoding, out string information,
|
||||
out FileSystem metadata)
|
||||
{
|
||||
Encoding = encoding ?? Encoding.GetEncoding("IBM437");
|
||||
information = "";
|
||||
|
||||
var sb = new StringBuilder();
|
||||
Metadata = new FileSystem();
|
||||
metadata = new FileSystem();
|
||||
|
||||
uint sectorsPerBpb = imagePlugin.Info.SectorSize < 512 ? 512 / imagePlugin.Info.SectorSize : 1;
|
||||
|
||||
@@ -446,7 +447,7 @@ public sealed partial class FAT
|
||||
ulong rootDirectorySector = 0;
|
||||
string extraInfo = null;
|
||||
string bootChk = null;
|
||||
Metadata.Bootable = bootable;
|
||||
metadata.Bootable = bootable;
|
||||
|
||||
// This is needed because for FAT16, GEMDOS increases bytes per sector count instead of using big_sectors field.
|
||||
uint sectorsPerRealSector;
|
||||
@@ -486,12 +487,12 @@ public sealed partial class FAT
|
||||
if(fat32Bpb.version != 0)
|
||||
{
|
||||
sb.AppendLine(Localization.FAT_Plus);
|
||||
Metadata.Type = FS_TYPE_FAT_PLUS;
|
||||
metadata.Type = FS_TYPE_FAT_PLUS;
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendLine(Localization.Microsoft_FAT32);
|
||||
Metadata.Type = FS_TYPE_FAT32;
|
||||
metadata.Type = FS_TYPE_FAT32;
|
||||
}
|
||||
|
||||
if(fat32Bpb.oem_name != null)
|
||||
@@ -500,14 +501,14 @@ public sealed partial class FAT
|
||||
fat32Bpb.oem_name[7] == 0x43)
|
||||
sb.AppendLine(Localization.Volume_has_been_modified_by_Windows_9x_Me_Volume_Tracker);
|
||||
else
|
||||
Metadata.SystemIdentifier = StringHandlers.CToString(fat32Bpb.oem_name);
|
||||
metadata.SystemIdentifier = StringHandlers.CToString(fat32Bpb.oem_name);
|
||||
|
||||
if(!string.IsNullOrEmpty(Metadata.SystemIdentifier))
|
||||
sb.AppendFormat(Localization.OEM_name_0, Metadata.SystemIdentifier.Trim()).AppendLine();
|
||||
if(!string.IsNullOrEmpty(metadata.SystemIdentifier))
|
||||
sb.AppendFormat(Localization.OEM_name_0, metadata.SystemIdentifier.Trim()).AppendLine();
|
||||
|
||||
sb.AppendFormat(Localization._0_bytes_per_sector, fat32Bpb.bps).AppendLine();
|
||||
sb.AppendFormat(Localization._0_sectors_per_cluster, fat32Bpb.spc).AppendLine();
|
||||
Metadata.ClusterSize = (uint)(fat32Bpb.bps * fat32Bpb.spc);
|
||||
metadata.ClusterSize = (uint)(fat32Bpb.bps * fat32Bpb.spc);
|
||||
sb.AppendFormat(Localization._0_sectors_reserved_between_BPB_and_FAT, fat32Bpb.rsectors).AppendLine();
|
||||
|
||||
if(fat32Bpb is { big_sectors: 0, signature: 0x28 })
|
||||
@@ -515,24 +516,24 @@ public sealed partial class FAT
|
||||
sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, shortFat32Bpb.huge_sectors,
|
||||
shortFat32Bpb.huge_sectors * shortFat32Bpb.bps).AppendLine();
|
||||
|
||||
Metadata.Clusters = shortFat32Bpb.huge_sectors / shortFat32Bpb.spc;
|
||||
metadata.Clusters = shortFat32Bpb.huge_sectors / shortFat32Bpb.spc;
|
||||
}
|
||||
else if(fat32Bpb.sectors == 0)
|
||||
{
|
||||
sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, fat32Bpb.big_sectors,
|
||||
fat32Bpb.big_sectors * fat32Bpb.bps).AppendLine();
|
||||
|
||||
Metadata.Clusters = fat32Bpb.big_sectors / fat32Bpb.spc;
|
||||
metadata.Clusters = fat32Bpb.big_sectors / fat32Bpb.spc;
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.AppendFormat(Localization._0_sectors_on_volume_1_bytes, fat32Bpb.sectors,
|
||||
fat32Bpb.sectors * fat32Bpb.bps).AppendLine();
|
||||
|
||||
Metadata.Clusters = (ulong)(fat32Bpb.sectors / fat32Bpb.spc);
|
||||
metadata.Clusters = (ulong)(fat32Bpb.sectors / fat32Bpb.spc);
|
||||
}
|
||||
|
||||
sb.AppendFormat(Localization._0_clusters_on_volume, Metadata.Clusters).AppendLine();
|
||||
sb.AppendFormat(Localization._0_clusters_on_volume, metadata.Clusters).AppendLine();
|
||||
sb.AppendFormat(Localization.Media_descriptor_0, fat32Bpb.media).AppendLine();
|
||||
sb.AppendFormat(Localization._0_sectors_per_FAT, fat32Bpb.big_spfat).AppendLine();
|
||||
sb.AppendFormat(Localization._0_sectors_per_track, fat32Bpb.sptrk).AppendLine();
|
||||
@@ -546,14 +547,14 @@ public sealed partial class FAT
|
||||
|
||||
sb.AppendFormat(Localization.Drive_number_0, fat32Bpb.drive_no).AppendLine();
|
||||
sb.AppendFormat(Localization.Volume_Serial_Number_0, fat32Bpb.serial_no).AppendLine();
|
||||
Metadata.VolumeSerial = $"{fat32Bpb.serial_no:X8}";
|
||||
metadata.VolumeSerial = $"{fat32Bpb.serial_no:X8}";
|
||||
|
||||
if((fat32Bpb.flags & 0xF8) == 0x00)
|
||||
{
|
||||
if((fat32Bpb.flags & 0x01) == 0x01)
|
||||
{
|
||||
sb.AppendLine(Localization.Volume_should_be_checked_on_next_mount);
|
||||
Metadata.Dirty = true;
|
||||
metadata.Dirty = true;
|
||||
}
|
||||
|
||||
if((fat32Bpb.flags & 0x02) == 0x02)
|
||||
@@ -573,8 +574,8 @@ public sealed partial class FAT
|
||||
|
||||
if(fat32Bpb.signature == 0x29)
|
||||
{
|
||||
Metadata.VolumeName = StringHandlers.SpacePaddedToString(fat32Bpb.volume_label, Encoding);
|
||||
Metadata.VolumeName = Metadata.VolumeName?.Replace("\0", "");
|
||||
metadata.VolumeName = StringHandlers.SpacePaddedToString(fat32Bpb.volume_label, Encoding);
|
||||
metadata.VolumeName = metadata.VolumeName?.Replace("\0", "");
|
||||
|
||||
sb.AppendFormat(Localization.Filesystem_type_0, Encoding.ASCII.GetString(fat32Bpb.fs_type)).
|
||||
AppendLine();
|
||||
@@ -586,7 +587,7 @@ public sealed partial class FAT
|
||||
|
||||
// Check that jumps to a correct boot code position and has boot signature set.
|
||||
// This will mean that the volume will boot, even if just to say "this is not bootable change disk"......
|
||||
Metadata.Bootable =
|
||||
metadata.Bootable =
|
||||
(fat32Bpb.jump[0] == 0xEB && fat32Bpb.jump[1] >= minBootNearJump && fat32Bpb.jump[1] < 0x80) ||
|
||||
(fat32Bpb.jump[0] == 0xE9 && fat32Bpb.jump.Length >= 3 &&
|
||||
BitConverter.ToUInt16(fat32Bpb.jump, 1) >= minBootNearJump &&
|
||||
@@ -616,7 +617,7 @@ public sealed partial class FAT
|
||||
if(fsInfo.free_clusters < 0xFFFFFFFF)
|
||||
{
|
||||
sb.AppendFormat(Localization._0_free_clusters, fsInfo.free_clusters).AppendLine();
|
||||
Metadata.FreeClusters = fsInfo.free_clusters;
|
||||
metadata.FreeClusters = fsInfo.free_clusters;
|
||||
}
|
||||
|
||||
if(fsInfo.last_cluster is > 2 and < 0xFFFFFFFF)
|
||||
@@ -638,7 +639,7 @@ public sealed partial class FAT
|
||||
// TODO: Check this
|
||||
if(sum == 0x1234)
|
||||
{
|
||||
Metadata.Bootable = true;
|
||||
metadata.Bootable = true;
|
||||
var atariSb = new StringBuilder();
|
||||
|
||||
atariSb.AppendFormat(Localization.cmdload_will_be_loaded_with_value_0,
|
||||
@@ -679,7 +680,7 @@ public sealed partial class FAT
|
||||
}
|
||||
|
||||
case BpbKind.Human:
|
||||
Metadata.Bootable = true;
|
||||
metadata.Bootable = true;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -802,7 +803,7 @@ public sealed partial class FAT
|
||||
break;
|
||||
}
|
||||
|
||||
Metadata.Type = FS_TYPE_FAT12;
|
||||
metadata.Type = FS_TYPE_FAT12;
|
||||
}
|
||||
else if(isFat16)
|
||||
{
|
||||
@@ -813,7 +814,7 @@ public sealed partial class FAT
|
||||
_ => Localization.Microsoft_FAT16
|
||||
});
|
||||
|
||||
Metadata.Type = FS_TYPE_FAT16;
|
||||
metadata.Type = FS_TYPE_FAT16;
|
||||
}
|
||||
|
||||
if(bpbKind == BpbKind.Atari)
|
||||
@@ -823,13 +824,13 @@ public sealed partial class FAT
|
||||
atariBpb.serial_no[2] == 0x43)
|
||||
sb.AppendLine(Localization.Volume_has_been_modified_by_Windows_9x_Me_Volume_Tracker);
|
||||
else
|
||||
Metadata.VolumeSerial = $"{atariBpb.serial_no[0]:X2}{atariBpb.serial_no[1]:X2}{atariBpb.serial_no[2]
|
||||
metadata.VolumeSerial = $"{atariBpb.serial_no[0]:X2}{atariBpb.serial_no[1]:X2}{atariBpb.serial_no[2]
|
||||
:X2}";
|
||||
|
||||
Metadata.SystemIdentifier = StringHandlers.CToString(atariBpb.oem_name);
|
||||
metadata.SystemIdentifier = StringHandlers.CToString(atariBpb.oem_name);
|
||||
|
||||
if(string.IsNullOrEmpty(Metadata.SystemIdentifier))
|
||||
Metadata.SystemIdentifier = null;
|
||||
if(string.IsNullOrEmpty(metadata.SystemIdentifier))
|
||||
metadata.SystemIdentifier = null;
|
||||
}
|
||||
else if(fakeBpb.oem_name != null)
|
||||
{
|
||||
@@ -838,7 +839,7 @@ public sealed partial class FAT
|
||||
fakeBpb.oem_name[7] == 0x43)
|
||||
sb.AppendLine(Localization.Volume_has_been_modified_by_Windows_9x_Me_Volume_Tracker);
|
||||
else
|
||||
Metadata.SystemIdentifier = fakeBpb.oem_name[0] switch
|
||||
metadata.SystemIdentifier = fakeBpb.oem_name[0] switch
|
||||
{
|
||||
// Later versions of Windows create a DOS 3 BPB without OEM name on 8 sectors/track floppies
|
||||
// OEM ID should be ASCII, otherwise ignore it
|
||||
@@ -860,15 +861,15 @@ public sealed partial class FAT
|
||||
fakeBpb.oem_name[7] >= 0x20 &&
|
||||
fakeBpb.oem_name[7] <= 0x7F => StringHandlers.CToString(fakeBpb.oem_name, Encoding,
|
||||
start: 1),
|
||||
_ => Metadata.SystemIdentifier
|
||||
_ => metadata.SystemIdentifier
|
||||
};
|
||||
|
||||
if(fakeBpb.signature is 0x28 or 0x29)
|
||||
Metadata.VolumeSerial = $"{fakeBpb.serial_no:X8}";
|
||||
metadata.VolumeSerial = $"{fakeBpb.serial_no:X8}";
|
||||
}
|
||||
|
||||
if(Metadata.SystemIdentifier != null)
|
||||
sb.AppendFormat(Localization.OEM_name_0, Metadata.SystemIdentifier.Trim()).AppendLine();
|
||||
if(metadata.SystemIdentifier != null)
|
||||
sb.AppendFormat(Localization.OEM_name_0, metadata.SystemIdentifier.Trim()).AppendLine();
|
||||
|
||||
sb.AppendFormat(Localization._0_bytes_per_sector, fakeBpb.bps).AppendLine();
|
||||
|
||||
@@ -884,10 +885,10 @@ public sealed partial class FAT
|
||||
clusters * humanBpb.bpc / imagePlugin.Info.SectorSize, clusters * humanBpb.bpc).
|
||||
AppendLine();
|
||||
|
||||
Metadata.Clusters = clusters;
|
||||
metadata.Clusters = clusters;
|
||||
sb.AppendFormat(Localization._0_sectors_per_cluster, fakeBpb.spc).AppendLine();
|
||||
sb.AppendFormat(Localization._0_clusters_on_volume, Metadata.Clusters).AppendLine();
|
||||
Metadata.ClusterSize = (uint)(fakeBpb.bps * fakeBpb.spc);
|
||||
sb.AppendFormat(Localization._0_clusters_on_volume, metadata.Clusters).AppendLine();
|
||||
metadata.ClusterSize = (uint)(fakeBpb.bps * fakeBpb.spc);
|
||||
sb.AppendFormat(Localization._0_sectors_reserved_between_BPB_and_FAT, fakeBpb.rsectors).AppendLine();
|
||||
sb.AppendFormat(Localization._0_FATs, fakeBpb.fats_no).AppendLine();
|
||||
sb.AppendFormat(Localization._0_entries_on_root_directory, fakeBpb.root_ent).AppendLine();
|
||||
@@ -911,15 +912,15 @@ public sealed partial class FAT
|
||||
{
|
||||
sb.AppendFormat(Localization.Drive_number_0, fakeBpb.drive_no).AppendLine();
|
||||
|
||||
if(Metadata.VolumeSerial != null)
|
||||
sb.AppendFormat(Localization.Volume_Serial_Number_0, Metadata.VolumeSerial).AppendLine();
|
||||
if(metadata.VolumeSerial != null)
|
||||
sb.AppendFormat(Localization.Volume_Serial_Number_0, metadata.VolumeSerial).AppendLine();
|
||||
|
||||
if((fakeBpb.flags & 0xF8) == 0x00)
|
||||
{
|
||||
if((fakeBpb.flags & 0x01) == 0x01)
|
||||
{
|
||||
sb.AppendLine(Localization.Volume_should_be_checked_on_next_mount);
|
||||
Metadata.Dirty = true;
|
||||
metadata.Dirty = true;
|
||||
}
|
||||
|
||||
if((fakeBpb.flags & 0x02) == 0x02)
|
||||
@@ -928,28 +929,28 @@ public sealed partial class FAT
|
||||
|
||||
if(fakeBpb.signature == 0x29 || andosOemCorrect)
|
||||
{
|
||||
Metadata.VolumeName = StringHandlers.SpacePaddedToString(fakeBpb.volume_label, Encoding);
|
||||
Metadata.VolumeName = Metadata.VolumeName?.Replace("\0", "");
|
||||
metadata.VolumeName = StringHandlers.SpacePaddedToString(fakeBpb.volume_label, Encoding);
|
||||
metadata.VolumeName = metadata.VolumeName?.Replace("\0", "");
|
||||
|
||||
sb.AppendFormat(Localization.Filesystem_type_0, Encoding.ASCII.GetString(fakeBpb.fs_type)).
|
||||
AppendLine();
|
||||
}
|
||||
}
|
||||
else if(bpbKind == BpbKind.Atari &&
|
||||
Metadata.VolumeSerial != null)
|
||||
sb.AppendFormat(Localization.Volume_Serial_Number_0, Metadata.VolumeSerial).AppendLine();
|
||||
metadata.VolumeSerial != null)
|
||||
sb.AppendFormat(Localization.Volume_Serial_Number_0, metadata.VolumeSerial).AppendLine();
|
||||
|
||||
bootChk = Sha1Context.Data(fakeBpb.boot_code, out _);
|
||||
|
||||
// Workaround that PCExchange jumps into "FAT16 "...
|
||||
if(Metadata.SystemIdentifier == "PCX 2.0 ")
|
||||
if(metadata.SystemIdentifier == "PCX 2.0 ")
|
||||
fakeBpb.jump[1] += 8;
|
||||
|
||||
// Check that jumps to a correct boot code position and has boot signature set.
|
||||
// This will mean that the volume will boot, even if just to say "this is not bootable change disk"......
|
||||
if(Metadata.Bootable == false &&
|
||||
if(metadata.Bootable == false &&
|
||||
fakeBpb.jump != null)
|
||||
Metadata.Bootable |=
|
||||
metadata.Bootable |=
|
||||
(fakeBpb.jump[0] == 0xEB && fakeBpb.jump[1] >= minBootNearJump && fakeBpb.jump[1] < 0x80) ||
|
||||
(fakeBpb.jump[0] == 0xE9 && fakeBpb.jump.Length >= 3 &&
|
||||
BitConverter.ToUInt16(fakeBpb.jump, 1) >= minBootNearJump &&
|
||||
@@ -1020,22 +1021,22 @@ public sealed partial class FAT
|
||||
string volname = Encoding.GetString(fullname).Trim();
|
||||
|
||||
if(!string.IsNullOrEmpty(volname))
|
||||
Metadata.VolumeName = entry.caseinfo.HasFlag(CaseInfo.AllLowerCase) ? volname.ToLower() : volname;
|
||||
metadata.VolumeName = entry.caseinfo.HasFlag(CaseInfo.AllLowerCase) ? volname.ToLower() : volname;
|
||||
|
||||
if(entry is { ctime: > 0, cdate: > 0 })
|
||||
{
|
||||
Metadata.CreationDate = DateHandlers.DosToDateTime(entry.cdate, entry.ctime);
|
||||
metadata.CreationDate = DateHandlers.DosToDateTime(entry.cdate, entry.ctime);
|
||||
|
||||
if(entry.ctime_ms > 0)
|
||||
Metadata.CreationDate = Metadata.CreationDate?.AddMilliseconds(entry.ctime_ms * 10);
|
||||
metadata.CreationDate = metadata.CreationDate?.AddMilliseconds(entry.ctime_ms * 10);
|
||||
|
||||
sb.AppendFormat(Localization.Volume_created_on_0, Metadata.CreationDate).AppendLine();
|
||||
sb.AppendFormat(Localization.Volume_created_on_0, metadata.CreationDate).AppendLine();
|
||||
}
|
||||
|
||||
if(entry is { mtime: > 0, mdate: > 0 })
|
||||
{
|
||||
Metadata.ModificationDate = DateHandlers.DosToDateTime(entry.mdate, entry.mtime);
|
||||
sb.AppendFormat(Localization.Volume_last_modified_on_0, Metadata.ModificationDate).AppendLine();
|
||||
metadata.ModificationDate = DateHandlers.DosToDateTime(entry.mdate, entry.mtime);
|
||||
sb.AppendFormat(Localization.Volume_last_modified_on_0, metadata.ModificationDate).AppendLine();
|
||||
}
|
||||
|
||||
if(entry.adate > 0)
|
||||
@@ -1046,10 +1047,10 @@ public sealed partial class FAT
|
||||
}
|
||||
}
|
||||
|
||||
if(!string.IsNullOrEmpty(Metadata.VolumeName))
|
||||
sb.AppendFormat(Localization.Volume_label_0, Metadata.VolumeName).AppendLine();
|
||||
if(!string.IsNullOrEmpty(metadata.VolumeName))
|
||||
sb.AppendFormat(Localization.Volume_label_0, metadata.VolumeName).AppendLine();
|
||||
|
||||
if(Metadata.Bootable)
|
||||
if(metadata.Bootable)
|
||||
{
|
||||
switch(bpbSector[0])
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user