Files
Aaru/Aaru.Filesystems/Opera/Info.cs

91 lines
4.2 KiB
C#
Raw Normal View History

using System;
using System.Text;
2020-02-27 00:33:26 +00:00
using Aaru.CommonTypes;
using Aaru.CommonTypes.Interfaces;
using Aaru.Helpers;
2017-12-21 14:30:38 +00:00
using Schemas;
2020-02-27 00:33:26 +00:00
namespace Aaru.Filesystems
{
2019-08-01 16:21:10 +01:00
public partial class OperaFS
{
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
if(2 + partition.Start >= partition.End) return false;
2014-07-09 19:49:14 +01:00
byte[] sbSector = imagePlugin.ReadSector(0 + partition.Start);
byte[] syncBytes = new byte[5];
2016-04-19 02:11:47 +01:00
byte recordType = sbSector[0x000];
Array.Copy(sbSector, 0x001, syncBytes, 0, 5);
byte recordVersion = sbSector[0x006];
2016-04-19 02:11:47 +01:00
if(recordType != 1 || recordVersion != 1) return false;
2016-04-19 02:11:47 +01:00
return Encoding.ASCII.GetString(syncBytes) == SYNC;
}
2017-12-26 08:01:40 +00:00
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
2018-06-22 08:08:38 +01:00
Encoding encoding)
{
// TODO: Find correct default encoding
2018-06-22 08:08:38 +01:00
Encoding = Encoding.ASCII;
information = "";
StringBuilder superBlockMetadata = new StringBuilder();
byte[] sbSector = imagePlugin.ReadSector(0 + partition.Start);
SuperBlock sb = Marshal.ByteArrayToStructureBigEndian<SuperBlock>(sbSector);
2017-12-19 20:33:03 +00:00
if(sb.record_type != 1 || sb.record_version != 1) return;
if(Encoding.ASCII.GetString(sb.sync_bytes) != SYNC) return;
superBlockMetadata.AppendFormat("Opera filesystem disc.").AppendLine();
2017-12-26 08:01:40 +00:00
if(!string.IsNullOrEmpty(StringHandlers.CToString(sb.volume_label, Encoding)))
superBlockMetadata
2018-06-22 08:08:38 +01:00
.AppendFormat("Volume label: {0}", StringHandlers.CToString(sb.volume_label, Encoding)).AppendLine();
2017-12-26 08:01:40 +00:00
if(!string.IsNullOrEmpty(StringHandlers.CToString(sb.volume_comment, Encoding)))
superBlockMetadata
2018-06-22 08:08:38 +01:00
.AppendFormat("Volume comment: {0}", StringHandlers.CToString(sb.volume_comment, Encoding))
.AppendLine();
superBlockMetadata.AppendFormat("Volume identifier: 0x{0:X8}", sb.volume_id).AppendLine();
superBlockMetadata.AppendFormat("Block size: {0} bytes", sb.block_size).AppendLine();
if(imagePlugin.Info.SectorSize == 2336 || imagePlugin.Info.SectorSize == 2352 ||
imagePlugin.Info.SectorSize == 2448)
* FileSystemIDandChk/BigEndianBitConverter.cs: Added BitConverter for BigEndian * FileSystemIDandChk/FileSystemIDandChk.csproj: FileSystemIDandChk/BigEndianBitConverter.cs * FileSystemIDandChk/ImagePlugins/CDRWin.cs: Corrected parsing Implemented all ImagePlugin methods * FileSystemIDandChk/ImagePlugins/ImagePlugin.cs: Used document auto formatting * FileSystemIDandChk/Main.cs: * FileSystemIDandChk/Plugins/FAT.cs: * FileSystemIDandChk/Plugins/BFS.cs: * FileSystemIDandChk/Plugins/FFS.cs: * FileSystemIDandChk/Plugins/ODS.cs: * FileSystemIDandChk/Plugins/HPFS.cs: * FileSystemIDandChk/Plugins/SysV.cs: * FileSystemIDandChk/Plugins/NTFS.cs: * FileSystemIDandChk/Plugins/extFS.cs: * FileSystemIDandChk/Plugins/Opera.cs: * FileSystemIDandChk/Plugins/ext2FS.cs: * FileSystemIDandChk/Plugins/Plugin.cs: * FileSystemIDandChk/Plugins/UNIXBFS.cs: * FileSystemIDandChk/Plugins/SolarFS.cs: * FileSystemIDandChk/PartPlugins/MBR.cs: * FileSystemIDandChk/Plugins/MinixFS.cs: * FileSystemIDandChk/Plugins/ISO9660.cs: * FileSystemIDandChk/Plugins/PCEngine.cs: * FileSystemIDandChk/Plugins/AppleHFS.cs: * FileSystemIDandChk/PartPlugins/NeXT.cs: * FileSystemIDandChk/Plugins/AppleMFS.cs: * FileSystemIDandChk/PartPlugins/AppleMap.cs: * FileSystemIDandChk/Plugins/AppleHFSPlus.cs: Added support for disc image plugins * FileSystemIDandChk/PartPlugins/PartPlugin.cs: Added support for disc image plugins Added start sector and length in sectors to partitions * FileSystemIDandChk/Plugins/Symbian.cs: Commented til code is adapted for disc image plugins git-svn-id: svn://claunia.com/FileSystemIDandChk@27 17725271-3d32-4980-a8cb-9ff532f270ba
2014-04-14 01:14:20 +00:00
{
2016-04-19 02:11:47 +01:00
if(sb.block_size != 2048)
superBlockMetadata
2018-06-22 08:08:38 +01:00
.AppendFormat("WARNING: Filesystem indicates {0} bytes/block while device indicates {1} bytes/block",
sb.block_size, 2048);
* FileSystemIDandChk/BigEndianBitConverter.cs: Added BitConverter for BigEndian * FileSystemIDandChk/FileSystemIDandChk.csproj: FileSystemIDandChk/BigEndianBitConverter.cs * FileSystemIDandChk/ImagePlugins/CDRWin.cs: Corrected parsing Implemented all ImagePlugin methods * FileSystemIDandChk/ImagePlugins/ImagePlugin.cs: Used document auto formatting * FileSystemIDandChk/Main.cs: * FileSystemIDandChk/Plugins/FAT.cs: * FileSystemIDandChk/Plugins/BFS.cs: * FileSystemIDandChk/Plugins/FFS.cs: * FileSystemIDandChk/Plugins/ODS.cs: * FileSystemIDandChk/Plugins/HPFS.cs: * FileSystemIDandChk/Plugins/SysV.cs: * FileSystemIDandChk/Plugins/NTFS.cs: * FileSystemIDandChk/Plugins/extFS.cs: * FileSystemIDandChk/Plugins/Opera.cs: * FileSystemIDandChk/Plugins/ext2FS.cs: * FileSystemIDandChk/Plugins/Plugin.cs: * FileSystemIDandChk/Plugins/UNIXBFS.cs: * FileSystemIDandChk/Plugins/SolarFS.cs: * FileSystemIDandChk/PartPlugins/MBR.cs: * FileSystemIDandChk/Plugins/MinixFS.cs: * FileSystemIDandChk/Plugins/ISO9660.cs: * FileSystemIDandChk/Plugins/PCEngine.cs: * FileSystemIDandChk/Plugins/AppleHFS.cs: * FileSystemIDandChk/PartPlugins/NeXT.cs: * FileSystemIDandChk/Plugins/AppleMFS.cs: * FileSystemIDandChk/PartPlugins/AppleMap.cs: * FileSystemIDandChk/Plugins/AppleHFSPlus.cs: Added support for disc image plugins * FileSystemIDandChk/PartPlugins/PartPlugin.cs: Added support for disc image plugins Added start sector and length in sectors to partitions * FileSystemIDandChk/Plugins/Symbian.cs: Commented til code is adapted for disc image plugins git-svn-id: svn://claunia.com/FileSystemIDandChk@27 17725271-3d32-4980-a8cb-9ff532f270ba
2014-04-14 01:14:20 +00:00
}
else if(imagePlugin.Info.SectorSize != sb.block_size)
superBlockMetadata
2018-06-22 08:08:38 +01:00
.AppendFormat("WARNING: Filesystem indicates {0} bytes/block while device indicates {1} bytes/block",
sb.block_size, imagePlugin.Info.SectorSize);
superBlockMetadata
2018-06-22 08:08:38 +01:00
.AppendFormat("Volume size: {0} blocks, {1} bytes", sb.block_count, sb.block_size * sb.block_count)
.AppendLine();
if(sb.block_count > imagePlugin.Info.Sectors)
superBlockMetadata
2018-06-22 08:08:38 +01:00
.AppendFormat("WARNING: Filesystem indicates {0} blocks while device indicates {1} blocks",
sb.block_count, imagePlugin.Info.Sectors);
superBlockMetadata.AppendFormat("Root directory identifier: 0x{0:X8}", sb.root_dirid).AppendLine();
superBlockMetadata.AppendFormat("Root directory block size: {0} bytes", sb.rootdir_bsize).AppendLine();
superBlockMetadata.AppendFormat("Root directory size: {0} blocks, {1} bytes", sb.rootdir_blocks,
2017-12-19 20:33:03 +00:00
sb.rootdir_bsize * sb.rootdir_blocks).AppendLine();
superBlockMetadata.AppendFormat("Last root directory copy: {0}", sb.last_root_copy).AppendLine();
information = superBlockMetadata.ToString();
2017-12-26 08:01:40 +00:00
XmlFsType = new FileSystemType
2017-07-23 21:01:26 +01:00
{
2018-06-22 08:08:38 +01:00
Type = "Opera",
VolumeName = StringHandlers.CToString(sb.volume_label, Encoding),
ClusterSize = sb.block_size,
Clusters = sb.block_count
2017-07-23 21:01:26 +01:00
};
}
}
* FileSystemIDandChk/BigEndianBitConverter.cs: Added BitConverter for BigEndian * FileSystemIDandChk/FileSystemIDandChk.csproj: FileSystemIDandChk/BigEndianBitConverter.cs * FileSystemIDandChk/ImagePlugins/CDRWin.cs: Corrected parsing Implemented all ImagePlugin methods * FileSystemIDandChk/ImagePlugins/ImagePlugin.cs: Used document auto formatting * FileSystemIDandChk/Main.cs: * FileSystemIDandChk/Plugins/FAT.cs: * FileSystemIDandChk/Plugins/BFS.cs: * FileSystemIDandChk/Plugins/FFS.cs: * FileSystemIDandChk/Plugins/ODS.cs: * FileSystemIDandChk/Plugins/HPFS.cs: * FileSystemIDandChk/Plugins/SysV.cs: * FileSystemIDandChk/Plugins/NTFS.cs: * FileSystemIDandChk/Plugins/extFS.cs: * FileSystemIDandChk/Plugins/Opera.cs: * FileSystemIDandChk/Plugins/ext2FS.cs: * FileSystemIDandChk/Plugins/Plugin.cs: * FileSystemIDandChk/Plugins/UNIXBFS.cs: * FileSystemIDandChk/Plugins/SolarFS.cs: * FileSystemIDandChk/PartPlugins/MBR.cs: * FileSystemIDandChk/Plugins/MinixFS.cs: * FileSystemIDandChk/Plugins/ISO9660.cs: * FileSystemIDandChk/Plugins/PCEngine.cs: * FileSystemIDandChk/Plugins/AppleHFS.cs: * FileSystemIDandChk/PartPlugins/NeXT.cs: * FileSystemIDandChk/Plugins/AppleMFS.cs: * FileSystemIDandChk/PartPlugins/AppleMap.cs: * FileSystemIDandChk/Plugins/AppleHFSPlus.cs: Added support for disc image plugins * FileSystemIDandChk/PartPlugins/PartPlugin.cs: Added support for disc image plugins Added start sector and length in sectors to partitions * FileSystemIDandChk/Plugins/Symbian.cs: Commented til code is adapted for disc image plugins git-svn-id: svn://claunia.com/FileSystemIDandChk@27 17725271-3d32-4980-a8cb-9ff532f270ba
2014-04-14 01:14:20 +00:00
}