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

154 lines
6.1 KiB
C#
Raw Normal View History

2020-03-11 21:56:55 +00:00
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : Info.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Opera filesystem plugin.
//
// --[ License ] --------------------------------------------------------------
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
2024-05-01 04:17:32 +01:00
// Copyright © 2011-2024 Natalia Portillo
2020-03-11 21:56:55 +00:00
// ****************************************************************************/
using System;
using System.Text;
using Aaru.CommonTypes.AaruMetadata;
using Aaru.CommonTypes.Enums;
2020-02-27 00:33:26 +00:00
using Aaru.CommonTypes.Interfaces;
using Aaru.Helpers;
using Partition = Aaru.CommonTypes.Partition;
namespace Aaru.Filesystems;
2022-03-06 13:29:38 +00:00
public sealed partial class OperaFS
{
#region IReadOnlyFilesystem Members
2022-03-06 13:29:38 +00:00
/// <inheritdoc />
public bool Identify(IMediaImage imagePlugin, Partition partition)
{
2024-05-01 04:05:22 +01:00
if(2 + partition.Start >= partition.End) return false;
2022-03-06 13:29:38 +00:00
ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector);
2024-05-01 04:05:22 +01:00
if(errno != ErrorNumber.NoError) return false;
2016-04-19 02:11:47 +01:00
var syncBytes = new byte[5];
2016-04-19 02:11:47 +01:00
2022-03-06 13:29:38 +00:00
byte recordType = sbSector[0x000];
Array.Copy(sbSector, 0x001, syncBytes, 0, 5);
byte recordVersion = sbSector[0x006];
2016-04-19 02:11:47 +01:00
2024-05-01 04:05:22 +01:00
if(recordType != 1 || recordVersion != 1) return false;
2022-03-06 13:29:38 +00:00
return Encoding.ASCII.GetString(syncBytes) == SYNC;
}
2022-03-06 13:29:38 +00:00
/// <inheritdoc />
public void GetInformation(IMediaImage imagePlugin, Partition partition, Encoding encoding, out string information,
out FileSystem metadata)
2022-03-06 13:29:38 +00:00
{
// TODO: Find correct default encoding
encoding = Encoding.ASCII;
2022-03-06 13:29:38 +00:00
information = "";
metadata = new FileSystem();
var superBlockmetadata = new StringBuilder();
2022-03-06 13:29:38 +00:00
ErrorNumber errno = imagePlugin.ReadSector(0 + partition.Start, out byte[] sbSector);
2024-05-01 04:05:22 +01:00
if(errno != ErrorNumber.NoError) return;
2022-03-06 13:29:38 +00:00
SuperBlock sb = Marshal.ByteArrayToStructureBigEndian<SuperBlock>(sbSector);
2020-02-29 18:03:35 +00:00
2024-05-01 04:05:22 +01:00
if(sb.record_type != 1 || sb.record_version != 1) return;
2024-05-01 04:05:22 +01:00
if(Encoding.ASCII.GetString(sb.sync_bytes) != SYNC) return;
2020-02-29 18:03:35 +00:00
superBlockmetadata.AppendFormat(Localization.Opera_filesystem_disc).AppendLine();
2020-02-29 18:03:35 +00:00
if(!string.IsNullOrEmpty(StringHandlers.CToString(sb.volume_label, encoding)))
{
2024-05-01 04:05:22 +01:00
superBlockmetadata
.AppendFormat(Localization.Volume_label_0, StringHandlers.CToString(sb.volume_label, encoding))
.AppendLine();
}
2018-06-22 08:08:38 +01:00
if(!string.IsNullOrEmpty(StringHandlers.CToString(sb.volume_comment, encoding)))
{
2024-05-01 04:05:22 +01:00
superBlockmetadata
.AppendFormat(Localization.Volume_comment_0, StringHandlers.CToString(sb.volume_comment, encoding))
.AppendLine();
}
2020-02-29 18:03:35 +00:00
superBlockmetadata.AppendFormat(Localization.Volume_identifier_0_X8, sb.volume_id).AppendLine();
superBlockmetadata.AppendFormat(Localization.Block_size_0_bytes, sb.block_size).AppendLine();
2022-03-06 13:29:38 +00:00
2022-03-16 11:47:00 +00:00
if(imagePlugin.Info.SectorSize is 2336 or 2352 or 2448)
2022-03-06 13:29:38 +00:00
{
if(sb.block_size != 2048)
{
2024-05-01 04:05:22 +01:00
superBlockmetadata.AppendFormat(Localization
.WARNING_Filesystem_indicates_0_bytes_block_while_device_indicates_1_bytes_block,
sb.block_size,
2048);
}
2022-03-06 13:29:38 +00:00
}
else if(imagePlugin.Info.SectorSize != sb.block_size)
{
2024-05-01 04:05:22 +01:00
superBlockmetadata.AppendFormat(Localization
.WARNING_Filesystem_indicates_0_bytes_block_while_device_indicates_1_bytes_block,
sb.block_size,
imagePlugin.Info.SectorSize);
}
2020-02-29 18:03:35 +00:00
2024-05-01 04:05:22 +01:00
superBlockmetadata
.AppendFormat(Localization.Volume_size_0_blocks_1_bytes, sb.block_count, sb.block_size * sb.block_count)
.AppendLine();
2020-02-29 18:03:35 +00:00
2022-03-06 13:29:38 +00:00
if(sb.block_count > imagePlugin.Info.Sectors)
{
2024-05-01 04:05:22 +01:00
superBlockmetadata.AppendFormat(Localization
.WARNING__Filesystem_indicates_0_blocks_while_device_indicates_1_blocks,
sb.block_count,
imagePlugin.Info.Sectors);
}
2020-02-29 18:03:35 +00:00
superBlockmetadata.AppendFormat(Localization.Root_directory_identifier_0, sb.root_dirid).AppendLine();
superBlockmetadata.AppendFormat(Localization.Root_directory_block_size_0_bytes, sb.rootdir_bsize).AppendLine();
2024-05-01 04:05:22 +01:00
superBlockmetadata.AppendFormat(Localization.Root_directory_size_0_blocks_1_bytes,
sb.rootdir_blocks,
sb.rootdir_bsize * sb.rootdir_blocks)
.AppendLine();
superBlockmetadata.AppendFormat(Localization.Last_root_directory_copy_0, sb.last_root_copy).AppendLine();
2022-03-06 13:29:38 +00:00
information = superBlockmetadata.ToString();
2022-03-06 13:29:38 +00:00
metadata = new FileSystem
2022-03-06 13:29:38 +00:00
{
Type = FS_TYPE,
VolumeName = StringHandlers.CToString(sb.volume_label, encoding),
2022-03-06 13:29:38 +00:00
ClusterSize = sb.block_size,
Clusters = sb.block_count
};
}
#endregion
* 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
}