2017-07-19 16:31:08 +01:00
|
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
|
// Aaru Data Preservation Suite
|
2016-09-02 06:49:59 +01:00
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
2022-12-07 13:07:31 +00:00
|
|
|
|
// Filename : Info.cs
|
2016-09-02 06:49:59 +01:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : IBM JFS filesystem plugin
|
2016-09-02 06:49:59 +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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-12-03 16:07:10 +00:00
|
|
|
|
// Copyright © 2011-2023 Natalia Portillo
|
2016-09-02 06:49:59 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
|
// ReSharper disable UnusedMember.Local
|
|
|
|
|
|
|
2016-09-02 06:49:59 +01:00
|
|
|
|
using System.Text;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes;
|
2021-09-19 21:16:47 +01:00
|
|
|
|
using Aaru.CommonTypes.Enums;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
2020-07-20 15:43:52 +01:00
|
|
|
|
using Aaru.Helpers;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using Schemas;
|
2016-09-02 06:49:59 +01:00
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
namespace Aaru.Filesystems;
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
/// <summary>Implements detection of IBM's Journaled File System</summary>
|
2022-12-07 13:07:31 +00:00
|
|
|
|
public sealed partial class JFS
|
2016-09-02 06:49:59 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public bool Identify(IMediaImage imagePlugin, Partition partition)
|
|
|
|
|
|
{
|
|
|
|
|
|
uint bootSectors = JFS_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize;
|
2017-12-19 20:33:03 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(partition.Start + bootSectors >= partition.End)
|
|
|
|
|
|
return false;
|
2021-09-19 21:16:47 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(partition.Start + bootSectors, out byte[] sector);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
|
return false;
|
2016-09-02 06:49:59 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sector.Length < 512)
|
|
|
|
|
|
return false;
|
2016-09-02 06:49:59 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
SuperBlock jfsSb = Marshal.ByteArrayToStructureLittleEndian<SuperBlock>(sector);
|
2016-09-02 06:49:59 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
return jfsSb.s_magic == JFS_MAGIC;
|
|
|
|
|
|
}
|
2021-09-19 21:16:47 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
/// <inheritdoc />
|
2022-03-07 07:36:44 +00:00
|
|
|
|
public void GetInformation(IMediaImage imagePlugin, Partition partition, out string information, Encoding encoding)
|
2022-03-06 13:29:38 +00:00
|
|
|
|
{
|
|
|
|
|
|
Encoding = encoding ?? Encoding.GetEncoding("iso-8859-15");
|
|
|
|
|
|
information = "";
|
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
uint bootSectors = JFS_BOOT_BLOCKS_SIZE / imagePlugin.Info.SectorSize;
|
|
|
|
|
|
ErrorNumber errno = imagePlugin.ReadSector(partition.Start + bootSectors, out byte[] sector);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(errno != ErrorNumber.NoError)
|
|
|
|
|
|
return;
|
2016-09-02 06:49:59 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(sector.Length < 512)
|
|
|
|
|
|
return;
|
2016-09-02 06:49:59 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
SuperBlock jfsSb = Marshal.ByteArrayToStructureLittleEndian<SuperBlock>(sector);
|
2016-09-02 06:49:59 +01:00
|
|
|
|
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.JFS_filesystem);
|
|
|
|
|
|
sb.AppendFormat(Localization.Version_0, jfsSb.s_version).AppendLine();
|
|
|
|
|
|
sb.AppendFormat(Localization._0_blocks_of_1_bytes, jfsSb.s_size, jfsSb.s_bsize).AppendLine();
|
|
|
|
|
|
sb.AppendFormat(Localization._0_blocks_per_allocation_group, jfsSb.s_agsize).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.Unicode))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_uses_Unicode_for_directory_entries);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.RemountRO))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_remounts_read_only_on_error);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.Continue))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_continues_on_error);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.Panic))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_panics_on_error);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.UserQuota))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_has_user_quotas_enabled);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.GroupQuota))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_has_group_quotas_enabled);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.NoJournal))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_is_not_using_any_journal);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.Discard))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_sends_TRIM_UNMAP_commands_to_underlying_device);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.GroupCommit))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_commits_in_groups_of_1);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.LazyCommit))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_commits_lazy);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.Temporary))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_does_not_commit_to_log);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.InlineLog))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_has_log_withing_itself);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.InlineMoving))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_has_log_withing_itself_and_is_moving_it_out);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.BadSAIT))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_has_bad_current_secondary_ait);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.Sparse))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_supports_sparse_files);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.DASDEnabled))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_has_DASD_limits_enabled);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.DASDPrime))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_primes_DASD_on_boot);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.SwapBytes))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_is_in_a_big_endian_system);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.DirIndex))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_has_persistent_indexes);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.Linux))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_supports_Linux);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.DFS))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_supports_DCE_DFS_LFS);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.OS2))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_supports_OS2_and_is_case_insensitive);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_flags.HasFlag(Flags.AIX))
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_supports_AIX);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_state != 0)
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendLine(Localization.Volume_is_dirty);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendFormat(Localization.Volume_was_last_updated_on_0_,
|
2022-03-07 07:36:44 +00:00
|
|
|
|
DateHandlers.UnixUnsignedToDateTime(jfsSb.s_time.tv_sec, jfsSb.s_time.tv_nsec)).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
if(jfsSb.s_version == 1)
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(jfsSb.s_fpack, Encoding)).AppendLine();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
else
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendFormat(Localization.Volume_name_0, StringHandlers.CToString(jfsSb.s_label, Encoding)).AppendLine();
|
2016-09-02 06:49:59 +01:00
|
|
|
|
|
2022-11-28 02:59:53 +00:00
|
|
|
|
sb.AppendFormat(Localization.Volume_UUID_0, jfsSb.s_uuid).AppendLine();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
XmlFsType = new FileSystemType
|
|
|
|
|
|
{
|
2022-11-28 02:59:53 +00:00
|
|
|
|
Type = FS_TYPE,
|
2022-03-06 13:29:38 +00:00
|
|
|
|
Clusters = jfsSb.s_size,
|
|
|
|
|
|
ClusterSize = jfsSb.s_bsize,
|
|
|
|
|
|
Bootable = true,
|
|
|
|
|
|
VolumeName = StringHandlers.CToString(jfsSb.s_version == 1 ? jfsSb.s_fpack : jfsSb.s_label, Encoding),
|
|
|
|
|
|
VolumeSerial = $"{jfsSb.s_uuid}",
|
|
|
|
|
|
ModificationDate = DateHandlers.UnixUnsignedToDateTime(jfsSb.s_time.tv_sec, jfsSb.s_time.tv_nsec),
|
|
|
|
|
|
ModificationDateSpecified = true
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if(jfsSb.s_state != 0)
|
|
|
|
|
|
XmlFsType.Dirty = true;
|
|
|
|
|
|
|
|
|
|
|
|
information = sb.ToString();
|
|
|
|
|
|
}
|
2016-09-02 06:49:59 +01:00
|
|
|
|
}
|