2017-09-14 02:01:43 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : LIF.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : HP Logical Interchange Format plugin
|
2017-09-14 02:01:43 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Identifies the HP Logical Interchange Format and shows information.
|
2017-09-14 02:01:43 +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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2017-09-14 02:01:43 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using DiscImageChef.CommonTypes;
|
|
|
|
|
|
using DiscImageChef.Console;
|
2017-12-21 14:30:38 +00:00
|
|
|
|
using DiscImageChef.DiscImages;
|
|
|
|
|
|
using Schemas;
|
2017-09-14 02:01:43 +01:00
|
|
|
|
|
|
|
|
|
|
namespace DiscImageChef.Filesystems
|
|
|
|
|
|
{
|
|
|
|
|
|
// Information from http://www.hp9845.net/9845/projects/hpdir/#lif_filesystem
|
|
|
|
|
|
public class LIF : Filesystem
|
|
|
|
|
|
{
|
2017-12-22 08:43:22 +00:00
|
|
|
|
const uint LIF_MAGIC = 0x8000;
|
2017-09-14 02:01:43 +01:00
|
|
|
|
|
|
|
|
|
|
public LIF()
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "HP Logical Interchange Format Plugin";
|
2017-12-22 08:43:22 +00:00
|
|
|
|
PluginUuid = new Guid("41535647-77A5-477B-9206-DA727ACDC704");
|
2017-09-14 02:01:43 +01:00
|
|
|
|
CurrentEncoding = Encoding.GetEncoding("iso-8859-15");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-12 23:54:02 +01:00
|
|
|
|
public LIF(Encoding encoding)
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = "HP Logical Interchange Format Plugin";
|
2017-12-22 08:43:22 +00:00
|
|
|
|
PluginUuid = new Guid("41535647-77A5-477B-9206-DA727ACDC704");
|
|
|
|
|
|
CurrentEncoding = encoding ?? Encoding.GetEncoding("iso-8859-15");
|
2017-10-12 23:54:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-21 14:30:38 +00:00
|
|
|
|
public LIF(ImagePlugin imagePlugin, Partition partition, Encoding encoding)
|
2017-09-14 02:01:43 +01:00
|
|
|
|
{
|
|
|
|
|
|
Name = "HP Logical Interchange Format Plugin";
|
2017-12-22 08:43:22 +00:00
|
|
|
|
PluginUuid = new Guid("41535647-77A5-477B-9206-DA727ACDC704");
|
|
|
|
|
|
CurrentEncoding = encoding ?? Encoding.GetEncoding("iso-8859-15");
|
2017-09-14 02:01:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-21 14:30:38 +00:00
|
|
|
|
public override bool Identify(ImagePlugin imagePlugin, Partition partition)
|
2017-09-14 02:01:43 +01:00
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(imagePlugin.GetSectorSize() < 256) return false;
|
2017-09-14 02:01:43 +01:00
|
|
|
|
|
|
|
|
|
|
byte[] sector = imagePlugin.ReadSector(partition.Start);
|
2017-12-22 08:43:22 +00:00
|
|
|
|
LIF_SystemBlock lifSb = BigEndianMarshal.ByteArrayToStructureBigEndian<LIF_SystemBlock>(sector);
|
|
|
|
|
|
DicConsole.DebugWriteLine("LIF plugin", "magic 0x{0:X8} (expected 0x{1:X8})", lifSb.magic, LIF_MAGIC);
|
2017-09-14 02:01:43 +01:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
return lifSb.magic == LIF_MAGIC;
|
2017-09-14 02:01:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-24 02:37:41 +00:00
|
|
|
|
public override void GetInformation(ImagePlugin imagePlugin, Partition partition, out string information)
|
2017-09-14 02:01:43 +01:00
|
|
|
|
{
|
|
|
|
|
|
information = "";
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
if(imagePlugin.GetSectorSize() < 256) return;
|
2017-09-14 02:01:43 +01:00
|
|
|
|
|
|
|
|
|
|
byte[] sector = imagePlugin.ReadSector(partition.Start);
|
2017-12-22 08:43:22 +00:00
|
|
|
|
LIF_SystemBlock lifSb = BigEndianMarshal.ByteArrayToStructureBigEndian<LIF_SystemBlock>(sector);
|
2017-09-14 02:01:43 +01:00
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
if(lifSb.magic != LIF_MAGIC) return;
|
2017-09-14 02:01:43 +01:00
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
sb.AppendLine("HP Logical Interchange Format");
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("Directory starts at cluster {0}", lifSb.directoryStart).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("LIF identifier: {0}", lifSb.lifId).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("Directory size: {0} clusters", lifSb.directorySize).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("LIF version: {0}", lifSb.lifVersion).AppendLine();
|
2017-09-14 02:01:43 +01:00
|
|
|
|
// How is this related to volume size? I have only CDs to test and makes no sense there
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("{0} tracks", lifSb.tracks).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} heads", lifSb.heads).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("{0} sectors", lifSb.sectors).AppendLine();
|
|
|
|
|
|
sb.AppendFormat("Volume name: {0}", StringHandlers.CToString(lifSb.volumeLabel, CurrentEncoding))
|
2017-12-19 20:33:03 +00:00
|
|
|
|
.AppendLine();
|
2017-12-22 08:43:22 +00:00
|
|
|
|
sb.AppendFormat("Volume created on {0}", DateHandlers.LifToDateTime(lifSb.creationDate)).AppendLine();
|
2017-09-14 02:01:43 +01:00
|
|
|
|
|
|
|
|
|
|
information = sb.ToString();
|
|
|
|
|
|
|
2017-12-22 08:43:22 +00:00
|
|
|
|
XmlFsType = new FileSystemType
|
2017-09-14 02:01:43 +01:00
|
|
|
|
{
|
|
|
|
|
|
Type = "HP Logical Interchange Format",
|
|
|
|
|
|
ClusterSize = 256,
|
|
|
|
|
|
Clusters = (long)(partition.Size / 256),
|
2017-12-22 08:43:22 +00:00
|
|
|
|
CreationDate = DateHandlers.LifToDateTime(lifSb.creationDate),
|
2017-09-14 02:01:43 +01:00
|
|
|
|
CreationDateSpecified = true,
|
2017-12-22 08:43:22 +00:00
|
|
|
|
VolumeName = StringHandlers.CToString(lifSb.volumeLabel, CurrentEncoding)
|
2017-09-14 02:01:43 +01:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Errno Mount()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Errno.NotImplemented;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Errno Mount(bool debug)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Errno.NotImplemented;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
2017-12-24 02:37:41 +00:00
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
|
struct LIF_SystemBlock
|
|
|
|
|
|
{
|
|
|
|
|
|
public ushort magic;
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public byte[] volumeLabel;
|
|
|
|
|
|
public uint directoryStart;
|
|
|
|
|
|
public ushort lifId;
|
|
|
|
|
|
public ushort unused;
|
|
|
|
|
|
public uint directorySize;
|
|
|
|
|
|
public ushort lifVersion;
|
|
|
|
|
|
public ushort unused2;
|
|
|
|
|
|
public uint tracks;
|
|
|
|
|
|
public uint heads;
|
|
|
|
|
|
public uint sectors;
|
|
|
|
|
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] public byte[] creationDate;
|
|
|
|
|
|
}
|
2017-09-14 02:01:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|