2017-07-19 16:31:08 +01:00
|
|
|
|
// /***************************************************************************
|
2016-09-17 21:23:01 +01:00
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
2019-04-06 11:03:43 +01:00
|
|
|
|
// Filename : Info.cs
|
2016-09-17 21:23:01 +01:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
2019-04-06 11:03:43 +01:00
|
|
|
|
// Component : FATX filesystem plugin.
|
2016-09-17 21:23:01 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
2016-09-17 21:25:14 +01:00
|
|
|
|
// Identifies the FATX filesystem and shows information.
|
2016-09-17 21:23:01 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2018-12-29 17:34:38 +00:00
|
|
|
|
// Copyright © 2011-2019 Natalia Portillo
|
2016-09-17 21:23:01 +01:00
|
|
|
|
// ****************************************************************************/
|
2016-09-17 21:25:14 +01:00
|
|
|
|
|
|
|
|
|
|
using System.Text;
|
2017-07-19 16:31:08 +01:00
|
|
|
|
using DiscImageChef.CommonTypes;
|
2018-06-25 19:08:16 +01:00
|
|
|
|
using DiscImageChef.CommonTypes.Interfaces;
|
2019-04-06 11:03:43 +01:00
|
|
|
|
using DiscImageChef.Helpers;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using Schemas;
|
2016-09-17 21:25:14 +01:00
|
|
|
|
|
2019-04-06 11:03:43 +01:00
|
|
|
|
namespace DiscImageChef.Filesystems.FATX
|
2016-09-17 21:23:01 +01:00
|
|
|
|
{
|
2019-04-06 11:03:43 +01:00
|
|
|
|
public partial class XboxFatPlugin
|
2016-09-17 21:23:01 +01:00
|
|
|
|
{
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
2016-09-17 21:25:14 +01:00
|
|
|
|
{
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(imagePlugin.Info.SectorSize < 512) return false;
|
2016-09-17 21:25:14 +01:00
|
|
|
|
|
2017-07-19 16:37:11 +01:00
|
|
|
|
byte[] sector = imagePlugin.ReadSector(partition.Start);
|
2016-09-17 21:25:14 +01:00
|
|
|
|
|
2019-03-26 19:22:57 +00:00
|
|
|
|
Superblock sb = Marshal.ByteArrayToStructureBigEndian<Superblock>(sector);
|
2016-09-17 21:25:14 +01:00
|
|
|
|
|
2019-04-06 12:25:00 +01:00
|
|
|
|
return sb.magic == FATX_MAGIC || sb.magic == FATX_CIGAM;
|
2016-09-17 21:23:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-26 07:28:40 +00:00
|
|
|
|
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information,
|
2018-06-22 08:08:38 +01:00
|
|
|
|
Encoding encoding)
|
2016-09-17 21:25:14 +01:00
|
|
|
|
{
|
2018-06-22 08:08:38 +01:00
|
|
|
|
Encoding = Encoding.UTF8;
|
2016-09-17 21:25:14 +01:00
|
|
|
|
information = "";
|
2017-12-26 06:05:12 +00:00
|
|
|
|
if(imagePlugin.Info.SectorSize < 512) return;
|
2016-09-17 21:25:14 +01:00
|
|
|
|
|
2019-04-06 12:35:47 +01:00
|
|
|
|
bool bigEndian = true;
|
|
|
|
|
|
|
2017-07-19 16:37:11 +01:00
|
|
|
|
byte[] sector = imagePlugin.ReadSector(partition.Start);
|
2016-09-17 21:25:14 +01:00
|
|
|
|
|
2019-03-26 19:22:57 +00:00
|
|
|
|
Superblock fatxSb = Marshal.ByteArrayToStructureBigEndian<Superblock>(sector);
|
2016-09-17 21:25:14 +01:00
|
|
|
|
|
2019-04-06 12:35:47 +01:00
|
|
|
|
if(fatxSb.magic == FATX_CIGAM)
|
|
|
|
|
|
{
|
|
|
|
|
|
fatxSb = Marshal.ByteArrayToStructureLittleEndian<Superblock>(sector);
|
|
|
|
|
|
bigEndian = false;
|
|
|
|
|
|
}
|
2019-04-06 12:25:00 +01:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
if(fatxSb.magic != FATX_MAGIC) return;
|
2016-09-17 21:25:14 +01:00
|
|
|
|
|
2019-04-14 16:37:07 +01:00
|
|
|
|
int logicalSectorsPerPhysicalSectors = partition.Offset == 0 && !bigEndian ? 8 : 1;
|
2019-04-06 12:29:20 +01:00
|
|
|
|
|
2016-09-17 21:25:14 +01:00
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
sb.AppendLine("FATX filesystem");
|
2019-04-06 12:29:20 +01:00
|
|
|
|
sb.AppendFormat("{0} logical sectors ({1} bytes) per physical sector", logicalSectorsPerPhysicalSectors,
|
|
|
|
|
|
logicalSectorsPerPhysicalSectors * imagePlugin.Info.SectorSize).AppendLine();
|
2017-12-19 20:33:03 +00:00
|
|
|
|
sb.AppendFormat("{0} sectors ({1} bytes) per cluster", fatxSb.sectorsPerCluster,
|
2019-04-06 12:29:20 +01:00
|
|
|
|
fatxSb.sectorsPerCluster * logicalSectorsPerPhysicalSectors * imagePlugin.Info.SectorSize)
|
|
|
|
|
|
.AppendLine();
|
2016-09-17 21:25:14 +01:00
|
|
|
|
sb.AppendFormat("Root directory starts on cluster {0}", fatxSb.rootDirectoryCluster).AppendLine();
|
|
|
|
|
|
|
2019-04-06 12:35:47 +01:00
|
|
|
|
string volumeLabel = StringHandlers.CToString(fatxSb.volumeLabel,
|
|
|
|
|
|
bigEndian ? Encoding.BigEndianUnicode : Encoding.Unicode,
|
|
|
|
|
|
true);
|
|
|
|
|
|
|
|
|
|
|
|
sb.AppendFormat("Volume label: {0}", volumeLabel).AppendLine();
|
2019-04-06 12:37:46 +01:00
|
|
|
|
sb.AppendFormat("Volume serial: {0:X8}", fatxSb.id).AppendLine();
|
2019-04-06 12:35:47 +01:00
|
|
|
|
|
2016-09-17 21:25:14 +01:00
|
|
|
|
information = sb.ToString();
|
|
|
|
|
|
|
2017-12-26 08:01:40 +00:00
|
|
|
|
XmlFsType = new FileSystemType
|
2017-12-22 08:43:22 +00:00
|
|
|
|
{
|
2019-04-06 12:35:47 +01:00
|
|
|
|
Type = "FATX filesystem",
|
|
|
|
|
|
ClusterSize =
|
2019-04-23 01:38:33 +01:00
|
|
|
|
(uint)(fatxSb.sectorsPerCluster * logicalSectorsPerPhysicalSectors *
|
|
|
|
|
|
imagePlugin.Info.SectorSize),
|
2019-04-06 12:37:46 +01:00
|
|
|
|
VolumeName = volumeLabel,
|
|
|
|
|
|
VolumeSerial = $"{fatxSb.id:X8}"
|
2017-12-22 08:43:22 +00:00
|
|
|
|
};
|
2019-04-23 01:38:33 +01:00
|
|
|
|
XmlFsType.Clusters = (partition.End - partition.Start + 1) * imagePlugin.Info.SectorSize /
|
|
|
|
|
|
XmlFsType.ClusterSize;
|
2016-09-17 21:25:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|