2017-07-19 16:31:08 +01:00
|
|
|
|
// /***************************************************************************
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : Opera.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : Opera filesystem plugin.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Identifies the Opera filesystem and shows information.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-05-19 20:28:49 +01:00
|
|
|
|
// Copyright © 2011-2017 Natalia Portillo
|
2016-07-28 18:13:49 +01:00
|
|
|
|
// ****************************************************************************/
|
2014-04-17 19:58:14 +00:00
|
|
|
|
|
2011-03-03 18:34:33 +00:00
|
|
|
|
using System;
|
2016-07-21 17:16:08 +01:00
|
|
|
|
using System.Collections.Generic;
|
2017-07-19 16:31:08 +01:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
using DiscImageChef.CommonTypes;
|
2014-04-17 19:58:14 +00:00
|
|
|
|
|
2016-07-21 16:15:39 +01:00
|
|
|
|
namespace DiscImageChef.Filesystems
|
2011-03-03 18:34:33 +00:00
|
|
|
|
{
|
2017-07-01 03:26:08 +01:00
|
|
|
|
public class OperaFS : Filesystem
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2015-10-05 20:04:05 +01:00
|
|
|
|
public OperaFS()
|
2011-03-03 18:34:33 +00:00
|
|
|
|
{
|
2014-04-14 02:29:13 +00:00
|
|
|
|
Name = "Opera Filesystem Plugin";
|
|
|
|
|
|
PluginUUID = new Guid("0ec84ec7-eae6-4196-83fe-943b3fe46dbd");
|
2017-06-06 21:23:20 +01:00
|
|
|
|
CurrentEncoding = Encoding.ASCII;
|
2011-03-03 18:34:33 +00:00
|
|
|
|
}
|
2014-04-14 02:29:13 +00:00
|
|
|
|
|
2017-07-19 16:31:08 +01:00
|
|
|
|
public OperaFS(ImagePlugins.ImagePlugin imagePlugin, Partition partition, Encoding encoding)
|
2016-07-27 13:32:45 +01:00
|
|
|
|
{
|
|
|
|
|
|
Name = "Opera Filesystem Plugin";
|
|
|
|
|
|
PluginUUID = new Guid("0ec84ec7-eae6-4196-83fe-943b3fe46dbd");
|
2017-06-06 21:23:20 +01:00
|
|
|
|
if(encoding == null) // TODO: Find correct default encoding
|
|
|
|
|
|
CurrentEncoding = Encoding.ASCII;
|
2016-07-27 13:32:45 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-07-19 16:31:08 +01:00
|
|
|
|
public override bool Identify(ImagePlugins.ImagePlugin imagePlugin, Partition partition)
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
2017-07-19 16:37:11 +01:00
|
|
|
|
if((2 + partition.Start) >= partition.End)
|
2014-07-09 19:49:14 +01:00
|
|
|
|
return false;
|
|
|
|
|
|
|
2017-07-19 16:37:11 +01:00
|
|
|
|
byte[] sb_sector = imagePlugin.ReadSector(0 + partition.Start);
|
2011-03-03 18:34:33 +00:00
|
|
|
|
|
|
|
|
|
|
byte record_type;
|
|
|
|
|
|
byte[] sync_bytes = new byte[5];
|
|
|
|
|
|
byte record_version;
|
2016-04-19 02:11:47 +01:00
|
|
|
|
|
2014-04-14 01:14:20 +00:00
|
|
|
|
record_type = sb_sector[0x000];
|
|
|
|
|
|
Array.Copy(sb_sector, 0x001, sync_bytes, 0, 5);
|
|
|
|
|
|
record_version = sb_sector[0x006];
|
2016-04-19 02:11:47 +01:00
|
|
|
|
|
|
|
|
|
|
if(record_type != 1 || record_version != 1)
|
2011-03-03 18:34:33 +00:00
|
|
|
|
return false;
|
2014-04-14 02:29:13 +00:00
|
|
|
|
return Encoding.ASCII.GetString(sync_bytes) == "ZZZZZ";
|
2016-04-19 02:11:47 +01:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-07-19 16:31:08 +01:00
|
|
|
|
public override void GetInformation(ImagePlugins.ImagePlugin imagePlugin, Partition partition, out string information)
|
2014-04-14 02:29:13 +00:00
|
|
|
|
{
|
|
|
|
|
|
information = "";
|
2011-03-03 18:34:33 +00:00
|
|
|
|
StringBuilder SuperBlockMetadata = new StringBuilder();
|
|
|
|
|
|
|
2017-07-19 16:37:11 +01:00
|
|
|
|
byte[] sb_sector = imagePlugin.ReadSector(0 + partition.Start);
|
2011-03-03 18:34:33 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
OperaSuperBlock sb = new OperaSuperBlock();
|
2014-04-14 01:14:20 +00:00
|
|
|
|
byte[] cString = new byte[32];
|
|
|
|
|
|
sb.sync_bytes = new byte[5];
|
2012-08-05 00:43:49 +00:00
|
|
|
|
|
2014-04-14 01:14:20 +00:00
|
|
|
|
sb.record_type = sb_sector[0x000];
|
|
|
|
|
|
Array.Copy(sb_sector, 0x001, sb.sync_bytes, 0, 5);
|
|
|
|
|
|
sb.record_version = sb_sector[0x006];
|
|
|
|
|
|
sb.volume_flags = sb_sector[0x007];
|
|
|
|
|
|
Array.Copy(sb_sector, 0x008, cString, 0, 32);
|
2014-04-14 02:29:13 +00:00
|
|
|
|
sb.volume_comment = StringHandlers.CToString(cString);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
Array.Copy(sb_sector, 0x028, cString, 0, 32);
|
2014-04-14 02:29:13 +00:00
|
|
|
|
sb.volume_label = StringHandlers.CToString(cString);
|
2014-04-14 01:14:20 +00:00
|
|
|
|
sb.volume_id = BigEndianBitConverter.ToInt32(sb_sector, 0x048);
|
|
|
|
|
|
sb.block_size = BigEndianBitConverter.ToInt32(sb_sector, 0x04C);
|
|
|
|
|
|
sb.block_count = BigEndianBitConverter.ToInt32(sb_sector, 0x050);
|
|
|
|
|
|
sb.root_dirid = BigEndianBitConverter.ToInt32(sb_sector, 0x054);
|
|
|
|
|
|
sb.rootdir_blocks = BigEndianBitConverter.ToInt32(sb_sector, 0x058);
|
|
|
|
|
|
sb.rootdir_bsize = BigEndianBitConverter.ToInt32(sb_sector, 0x05C);
|
|
|
|
|
|
sb.last_root_copy = BigEndianBitConverter.ToInt32(sb_sector, 0x060);
|
2012-08-05 00:43:49 +00:00
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(sb.record_type != 1 || sb.record_version != 1)
|
2011-03-03 18:34:33 +00:00
|
|
|
|
return;
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(Encoding.ASCII.GetString(sb.sync_bytes) != "ZZZZZ")
|
2011-03-03 18:34:33 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(sb.volume_comment.Length == 0)
|
2014-04-14 02:29:13 +00:00
|
|
|
|
sb.volume_comment = "Not set.";
|
2011-03-03 18:34:33 +00:00
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(sb.volume_label.Length == 0)
|
2014-04-14 02:29:13 +00:00
|
|
|
|
sb.volume_label = "Not set.";
|
2011-03-03 18:34:33 +00:00
|
|
|
|
|
|
|
|
|
|
SuperBlockMetadata.AppendFormat("Opera filesystem disc.").AppendLine();
|
2014-04-14 02:29:13 +00:00
|
|
|
|
SuperBlockMetadata.AppendFormat("Volume label: {0}", sb.volume_label).AppendLine();
|
|
|
|
|
|
SuperBlockMetadata.AppendFormat("Volume comment: {0}", sb.volume_comment).AppendLine();
|
|
|
|
|
|
SuperBlockMetadata.AppendFormat("Volume identifier: 0x{0:X8}", sb.volume_id).AppendLine();
|
|
|
|
|
|
SuperBlockMetadata.AppendFormat("Block size: {0} bytes", sb.block_size).AppendLine();
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(imagePlugin.GetSectorSize() == 2336 || imagePlugin.GetSectorSize() == 2352 || imagePlugin.GetSectorSize() == 2448)
|
2014-04-14 01:14:20 +00:00
|
|
|
|
{
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if(sb.block_size != 2048)
|
2014-04-14 01:14:20 +00:00
|
|
|
|
SuperBlockMetadata.AppendFormat("WARNING: Filesystem indicates {0} bytes/block while device indicates {1} bytes/block", sb.block_size, 2048);
|
|
|
|
|
|
}
|
2016-04-19 02:11:47 +01:00
|
|
|
|
else if(imagePlugin.GetSectorSize() != sb.block_size)
|
2014-04-14 01:14:20 +00:00
|
|
|
|
SuperBlockMetadata.AppendFormat("WARNING: Filesystem indicates {0} bytes/block while device indicates {1} bytes/block", sb.block_size, imagePlugin.GetSectorSize());
|
2014-04-14 02:29:13 +00:00
|
|
|
|
SuperBlockMetadata.AppendFormat("Volume size: {0} blocks, {1} bytes", sb.block_count, sb.block_size * sb.block_count).AppendLine();
|
2016-04-19 02:11:47 +01:00
|
|
|
|
if((ulong)sb.block_count > imagePlugin.GetSectors())
|
2014-04-14 01:14:20 +00:00
|
|
|
|
SuperBlockMetadata.AppendFormat("WARNING: Filesystem indicates {0} blocks while device indicates {1} blocks", sb.block_count, imagePlugin.GetSectors());
|
2014-04-14 02:29:13 +00:00
|
|
|
|
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, sb.rootdir_bsize * sb.rootdir_blocks).AppendLine();
|
|
|
|
|
|
SuperBlockMetadata.AppendFormat("Last root directory copy: {0}", sb.last_root_copy).AppendLine();
|
2011-03-03 18:34:33 +00:00
|
|
|
|
|
|
|
|
|
|
information = SuperBlockMetadata.ToString();
|
2015-12-05 17:10:27 +00:00
|
|
|
|
|
|
|
|
|
|
xmlFSType = new Schemas.FileSystemType();
|
|
|
|
|
|
xmlFSType.Type = "Opera";
|
|
|
|
|
|
xmlFSType.VolumeName = sb.volume_label;
|
|
|
|
|
|
xmlFSType.ClusterSize = sb.block_size;
|
|
|
|
|
|
xmlFSType.Clusters = sb.block_count;
|
2014-04-14 02:29:13 +00:00
|
|
|
|
}
|
2012-08-05 00:43:49 +00:00
|
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
|
struct OperaSuperBlock
|
|
|
|
|
|
{
|
2015-12-06 07:18:36 +00:00
|
|
|
|
/// <summary>0x000, Record type, must be 1</summary>
|
2014-04-14 02:29:13 +00:00
|
|
|
|
public byte record_type;
|
2015-12-06 07:18:36 +00:00
|
|
|
|
/// <summary>0x001, 5 bytes, "ZZZZZ"</summary>
|
2014-04-14 02:29:13 +00:00
|
|
|
|
public byte[] sync_bytes;
|
2015-12-06 07:18:36 +00:00
|
|
|
|
/// <summary>0x006, Record version, must be 1</summary>
|
2014-04-14 02:29:13 +00:00
|
|
|
|
public byte record_version;
|
2015-12-06 07:18:36 +00:00
|
|
|
|
/// <summary>0x007, Volume flags</summary>
|
2014-04-14 02:29:13 +00:00
|
|
|
|
public byte volume_flags;
|
2015-12-06 07:18:36 +00:00
|
|
|
|
/// <summary>0x008, 32 bytes, volume comment</summary>
|
2014-04-14 02:29:13 +00:00
|
|
|
|
public string volume_comment;
|
2015-12-06 07:18:36 +00:00
|
|
|
|
/// <summary>0x028, 32 bytes, volume label</summary>
|
2014-04-14 02:29:13 +00:00
|
|
|
|
public string volume_label;
|
2015-12-06 07:18:36 +00:00
|
|
|
|
/// <summary>0x048, Volume ID</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
public int volume_id;
|
2015-12-06 07:18:36 +00:00
|
|
|
|
/// <summary>0x04C, Block size in bytes</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
public int block_size;
|
2015-12-06 07:18:36 +00:00
|
|
|
|
/// <summary>0x050, Blocks in volume</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
public int block_count;
|
2015-12-06 07:18:36 +00:00
|
|
|
|
/// <summary>0x054, Root directory ID</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
public int root_dirid;
|
2015-12-06 07:18:36 +00:00
|
|
|
|
/// <summary>0x058, Root directory blocks</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
public int rootdir_blocks;
|
2015-12-06 07:18:36 +00:00
|
|
|
|
/// <summary>0x05C, Root directory block size</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
public int rootdir_bsize;
|
2015-12-06 07:18:36 +00:00
|
|
|
|
/// <summary>0x060, Last root directory copy</summary>
|
2016-07-28 22:25:26 +01:00
|
|
|
|
public int last_root_copy;
|
2014-04-14 02:29:13 +00:00
|
|
|
|
}
|
2016-07-21 17:16:08 +01:00
|
|
|
|
|
|
|
|
|
|
public override Errno Mount()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Errno.NotImplemented;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-07-22 00:43:22 +01:00
|
|
|
|
public override Errno Mount(bool debug)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Errno.NotImplemented;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-07-21 17:16:08 +01:00
|
|
|
|
public override Errno Unmount()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Errno.NotImplemented;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Errno MapBlock(string path, long fileBlock, ref long deviceBlock)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Errno.NotImplemented;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Errno GetAttributes(string path, ref FileAttributes attributes)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Errno.NotImplemented;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Errno ListXAttr(string path, ref List<string> xattrs)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Errno.NotImplemented;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Errno GetXattr(string path, string xattr, ref byte[] buf)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Errno.NotImplemented;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Errno Read(string path, long offset, long size, ref byte[] buf)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Errno.NotImplemented;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Errno ReadDir(string path, ref List<string> contents)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Errno.NotImplemented;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Errno StatFs(ref FileSystemInfo stat)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Errno.NotImplemented;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Errno Stat(string path, ref FileEntryInfo stat)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Errno.NotImplemented;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Errno ReadLink(string path, ref string dest)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Errno.NotImplemented;
|
|
|
|
|
|
}
|
2014-04-14 02:29:13 +00:00
|
|
|
|
}
|
2014-04-14 01:14:20 +00:00
|
|
|
|
}
|