From b7cf7148a5ff12baa5bdff8f59d46dd53c39f292 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Thu, 25 Apr 2019 01:25:13 +0100 Subject: [PATCH] Make FAT filesystem plugin implement IReadOnlyFilesystem. --- .../.idea/contentModel.xml | 11 +- .../DiscImageChef.Filesystems.csproj | 9 +- DiscImageChef.Filesystems/FAT/Consts.cs | 151 +++ DiscImageChef.Filesystems/FAT/Dir.cs | 59 ++ DiscImageChef.Filesystems/FAT/FAT.cs | 51 + DiscImageChef.Filesystems/FAT/File.cs | 48 + .../{FAT.cs => FAT/Info.cs} | 960 +----------------- DiscImageChef.Filesystems/FAT/Structs.cs | 870 ++++++++++++++++ DiscImageChef.Filesystems/FAT/Super.cs | 62 ++ DiscImageChef.Filesystems/FAT/Xattr.cs | 75 ++ DiscImageChef.Tests/Filesystems/FAT12.cs | 2 +- DiscImageChef.Tests/Filesystems/FAT16.cs | 2 +- DiscImageChef.Tests/Filesystems/FAT32.cs | 2 +- 13 files changed, 1340 insertions(+), 962 deletions(-) create mode 100644 DiscImageChef.Filesystems/FAT/Consts.cs create mode 100644 DiscImageChef.Filesystems/FAT/Dir.cs create mode 100644 DiscImageChef.Filesystems/FAT/FAT.cs create mode 100644 DiscImageChef.Filesystems/FAT/File.cs rename DiscImageChef.Filesystems/{FAT.cs => FAT/Info.cs} (63%) create mode 100644 DiscImageChef.Filesystems/FAT/Structs.cs create mode 100644 DiscImageChef.Filesystems/FAT/Super.cs create mode 100644 DiscImageChef.Filesystems/FAT/Xattr.cs diff --git a/.idea/.idea.DiscImageChef/.idea/contentModel.xml b/.idea/.idea.DiscImageChef/.idea/contentModel.xml index 429f3db1a..cdca9fc82 100644 --- a/.idea/.idea.DiscImageChef/.idea/contentModel.xml +++ b/.idea/.idea.DiscImageChef/.idea/contentModel.xml @@ -1246,7 +1246,16 @@ - + + + + + + + + + + diff --git a/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj b/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj index 085c780c7..1b1004f0c 100644 --- a/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj +++ b/DiscImageChef.Filesystems/DiscImageChef.Filesystems.csproj @@ -60,6 +60,14 @@ + + + + + + + + @@ -68,7 +76,6 @@ - diff --git a/DiscImageChef.Filesystems/FAT/Consts.cs b/DiscImageChef.Filesystems/FAT/Consts.cs new file mode 100644 index 000000000..ff5e29a41 --- /dev/null +++ b/DiscImageChef.Filesystems/FAT/Consts.cs @@ -0,0 +1,151 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Consts.cs +// Author(s) : Natalia Portillo +// +// Component : Microsoft FAT filesystem plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Microsoft FAT filesystem constants. +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2019 Natalia Portillo +// ****************************************************************************/ + +using System; + +namespace DiscImageChef.Filesystems.FAT +{ + public partial class FAT + { + const uint FSINFO_SIGNATURE1 = 0x41615252; + const uint FSINFO_SIGNATURE2 = 0x61417272; + const uint FSINFO_SIGNATURE3 = 0xAA550000; + + readonly (string hash, string name)[] knownBootHashes = + { + ("b639b4d5b25f63560e3b34a3a0feb732aa65486f", "Amstrad MS-DOS 3.20 (8-sector floppy)"), + ("9311151f13f7611b1431593da05ddd3153370574", "Amstrad MS-DOS 3.20 (Spanish)"), + ("55eda6a9b955f5199020e6b56a6954fa6fcb7dc6", "AT&T MS-DOS 2.11"), + ("d5e10822977efa96e4fbaec2b268ca008d74fe6f", "Atari TOS"), + ("17f11a12b96899d2a4976d889cef160502167f2d", "BeOS"), + ("d0e31673028fcfcea38dff71a7be13669aa20b8d", "Compaq MS-DOS 3.30"), + ("3aa4ce2fa6f9a297b5b15aaef930401af369fcbc", "Compaq MS-DOS 3.30 (8-sector floppy)"), + ("8f1d33520343f35034aa3ce47e4180b10e960b43", "Compaq MS-DOS 3.30 (8-sector floppy)"), + ("2f4011ae0670ff3aff2bdd412a4651f255b600a9", "Compaq MS-DOS 3.31"), + ("afc3fb751089a52c9f0bd37098d3137d32ab4982", "Concurrent DOS 6.0"), + ("c25e2d93d3b8bf9870043bf9d12580ef07f5375e", "CrossDOS"), + ("43fb2afa1ab3102b3f8d0fe901b652a5b0a973e1", "DR-DOS >=7.02"), + ("92d83b7e9e3bd4b73c6b98f8c6434206eac7212f", "DR-DOS 3.40"), + ("6a7aba05f91c5a7108edc5d5ccc9dac0ebf5dd28", "DR-DOS 3.40"), + ("715e78bb1e38b56452dd1c15db8c096dc506eea3", "DR-DOS 3.41"), + ("01e46cb2bc6d65ddd89ba28d254baf563d8fc609", "DR-DOS 5.00"), + ("dd297f159eef8a61f5eec638ce7318a098fa26f4", "DR-DOS 5.00"), + ("f590e53ae7f9caec5dba93241e557710be61b6fe", "DR-DOS 6.00"), + ("630e4aaf230f15eb2d09985f294815b6bc50384c", "DR-DOS 6.00"), + ("8851459816d714f53b9c469472e51460ebd44b98", "DR-DOS 7.03"), + ("cf24388b61eb1b137f2bb8a4c319e7461d460b72", "DR-DOS 7.03"), + ("26bf8efe8368e598397b1f79d635faccf5ca4f87", "DR-DOS 8.00"), + ("36ddd6bf8686801f5a2a3cbd4656afa175cabdfc", "DR-DOS 8.00"), + ("9ac09781e4090d9ba5e1a31816b4ebfa6b54f39e", "DR-DOS 8.00"), + ("f5d68f26abec8392ac23716581c4ab1d6e8456a2", "eComStation"), + ("e2a852db8c3eb3d86ca86a706186a9dd54cdc815", "Epson MS-DOS 3.10"), + ("74675d158dd0f6b5983bd30dda7018a814bd34dd", "Epson MS-DOS 3.20"), + ("683a04f34714555df5e862f709f9abc7de51488e", "Epson MS-DOS 5.00 (PC-98)"), + ("1b062df94fc576af069e40603bf2558000a2ca10", "FreeBSD, NetBSD, Mac OS X"), + ("33c8e306b3a51e09668fd60f099450019a1238ea", "FreeBSD, NetBSD, Mac OS X"), + ("ca386b1cefaf964a49192c2cd08077aff09b82af", "FreeDOS"), + ("26033e0db1ee4f439f07077b790e189d1b77688c", "HP MS-DOS 3.20"), + ("66867cd665e0e87c32de0bcb721ecfe91a551bc5", "mkfs.vfat"), + ("48d4811dbea5d724803017d6d45a49d604982b7b", "mkfs.vfat"), + ("02d615c5fb68bc49766bf89777dd36accb1428b7", "MS-DOS >=4.01, PC-DOS >=5.00 (8-sector floppy)"), + ("cffb1dc01bf9f533ba63d949c359c9ae97944c9b", "MS-DOS >=5.00"), + ("bd099151f2f9f8b3815eef7d9fed90abead52d97", "MS-DOS 3.21"), + ("f338eeff68f4e03ce489eb165e18fd94f8a0c63e", "MS-DOS 3.30A"), + ("0eb0c789e141d59d91f075ef14d63fd4255aeac2", "MS-DOS 3.30A, 5.00, 6.xx (8-sector floppy)"), + ("7aa06595490f92e542965b43805eaa0d6da9c86c", "MS-DOS 3.31"), + ("00401ca66900d7defcbc3d794654d1ba2376e83d", "MS-DOS 3.31"), + ("00e39a27d9b36e88f2b0caaa1959a8e17223bf31", "MS-DOS 3.31 (8-sector floppy)"), + ("1e74fbad5948582247280b116e7175b5a16bcede", "MS-DOS 3.31 (8-sector floppy)"), + ("1cfb2cc3a34c8164b8f5051c118643b23a60f4d0", "MS-DOS 4.01"), + ("d370551c8aca9cfcd964e2a1235071329f93cc03", "Multiuser DOS 7.22r4"), + ("7106ea11dd0b9a39649cbb4f6314a0fa1241da38", "NEC >=MS-DOS 5.00 (PC-98)"), + ("30d4f5f54215af0fc69236594e52b94989b35c21", "NEC MS-DOS 3.30 (PC-98)"), + ("eae42777f562eb81ed624f0c0479347ba11158c9", "Novell DOS 7.00"), + ("c67a7d0bab94a960cca8720d476f5317c960b2fb", "Novell DOS 7.00"), + ("0ed508c71bcf1418a1701b9267ddf166e7993b6b", "Olivetti MS-DOS 3.10"), + ("3e1a3f22973d9f2d15f9a053204c2f7b72de00a9", "OS/2 1.00"), + ("4acb13943f21a266f9eb110969980481783c41c4", "OS/2 1.10"), + ("cc7b32236c76d34edefdac3ca6a7be8e26163cea", "OS/2 1.20, 1.30"), + ("05c6706189fa0532ea83a7484b88d1dcba63e167", "OS/2 2.00"), + ("eefb4383b3e2b05f7f7e0051d58f4617a4f39e42", "OS/2 2.1x, Warp 3"), + ("b1d9666ae8781958242da27d319e73aa2dda6805", "OS/2 Warp 4"), + ("661d92970ab0f81cec453dc7584e0debdd1b4928", "PC-DOS >=5.00"), + ("78522b303fe5752f3cb37eabb6cb54e6cb0cd276", "PC-DOS 2.xx"), + ("277edfefdc3f05a219f9378076227c4126b6c8ef", "PC-DOS 3.00"), + ("f72ef6ff4c90a170bc8cdd1b01e8d98235c16a3b", "PC-DOS 3.10"), + ("cb6b6c1bc024e025710288da652d0d93527a71db", "PC-DOS 3.30"), + ("3b844e2a411182958c2d9e6ee17c6d4fff18bd73", "PC-DOS 4.00"), + ("45e82fcff4c6f8a9c31418323bc063011f5730e5", "PCExchange 2.0"), + ("707849fd75b6a52fd219c3cebe060ecb23c40fc7", "SCO OpenServer"), + ("9f7f146b513b00ff9e8b5b927aee24025c3f3fb8", "Toshiba MS-DOS 3.30"), + ("30eafc45a4606a7b840dcd5899dfb977a837c835", "Toshiba MS-DOS 4.01"), + ("5695a9a69637bd4d4eaa531b976d6f3b71e8d4ad", "Toshiba MS-DOS 4.01"), + ("036a59138d620c16e8d0dba45af4dec4ae1376f7", "Windows 10"), + ("3dd2941b79f0f6644b3a973c7d81e64e434c0b70", "Windows 2000"), + ("cd1e2fced2e49825df23c08a3d1e280c1cf468a7", "Windows 2000"), + ("c20c6e706be97091768da8654fffc2f3c0431318", "Windows 95"), + ("cf750cc0d2d52251a1a0fb9f2568fed3ff81717a", "Windows 95 >=OSR2"), + ("48865a298d4bbe73f89c4de10153e16250c1a9ae", "Windows 95 >=OSR2"), + ("1d2df8f3b1b336fc4aa1c6e49b21956194884b41", "Windows 98 (Spanish)"), + ("6e6fb4a3ea034415d716b1f81217ffecf78813c3", "Windows 98 (Spanish)"), + ("9b5e6be09200145a6ed7c22d14b1e6b4de2f362b", "Windows 98 (Spanish)"), + ("3cea1921d29fcd3343d36c090cb3e3dba926781d", "Windows 98, Me"), + ("037f9c8caed602d93c88f7e9d8f13a732b3ada76", "Windows NT"), + ("a63806bfe11140c873082318dd4da834068be327", "Windows Vista"), + ("8f024b3d501c39ee6e3f8ca28173ad6a780d3eb0", "Windows Vista, 8, 10"), + ("d3e93f8b82ef250db216037d827a4896dc97d2be", "TracerST"), // OEM ID: "TracerST" + //("b741f85ef40288ccc8887de1f6e849009097e1c9", "Norton Utilities"), // OEM ID: "IBM PNCI", need to confirm + ("c49b275537ac7237cac64d83f34d2024ae0ca96a", + "Windows NT (Spanish)"), // Need to check Windows >= 2000 (Spanish) + //("a48b0e4b696317eed829e960d1aa576562a4f185", "TracerST"), // Unknown OEM ID, apparently Tracer, unconfirmed + ("fe477972602ba76658ff7143859045b3c4036ca5", + "iomega"), // OEM ID: "SHIPDISK", contains timedate on boot code may not be unique + ("ef79a1f33e5237827eb812dda548f0e4e916d815", "GEOS"), // OEM ID: "GEOWORKS" + ("8524587ee91494cc51cc2c9d07453e84be0cdc33", "Hero Soft v1.10"), + ("681a0d9d662ba368e6acb0d0bf602e1f56411144", "Human68k 2.00") + }; + + [Flags] + enum FatAttributes : byte + { + ReadOnly = 0x01, + Hidden = 0x02, + System = 0x04, + VolumeLabel = 0x08, + Subdirectory = 0x10, + Archive = 0x20, + Device = 0x40, + Reserved = 0x80, + LFN = 0x0F + } + } +} \ No newline at end of file diff --git a/DiscImageChef.Filesystems/FAT/Dir.cs b/DiscImageChef.Filesystems/FAT/Dir.cs new file mode 100644 index 000000000..52d1e9019 --- /dev/null +++ b/DiscImageChef.Filesystems/FAT/Dir.cs @@ -0,0 +1,59 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Dir.cs +// Author(s) : Natalia Portillo +// +// Component : Microsoft FAT filesystem plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Methods to handle Microsoft FAT filesystem directories. +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2019 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using DiscImageChef.CommonTypes.Structs; + +namespace DiscImageChef.Filesystems.FAT +{ + public partial class FAT + { + /// + /// Solves a symbolic link. + /// + /// Link path. + /// Link destination. + public Errno ReadLink(string path, out string dest) + { + dest = null; + return Errno.NotSupported; + } + + /// + /// Lists contents from a directory. + /// + /// Directory path. + /// Directory contents. + public Errno ReadDir(string path, out List contents) => throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/DiscImageChef.Filesystems/FAT/FAT.cs b/DiscImageChef.Filesystems/FAT/FAT.cs new file mode 100644 index 000000000..ed2dd29d2 --- /dev/null +++ b/DiscImageChef.Filesystems/FAT/FAT.cs @@ -0,0 +1,51 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : FAT.cs +// Author(s) : Natalia Portillo +// +// Component : Microsoft FAT filesystem plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Identifies the Microsoft FAT 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2019 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Text; +using DiscImageChef.CommonTypes.Interfaces; +using Schemas; + +namespace DiscImageChef.Filesystems.FAT +{ + // TODO: Differentiate between Atari and X68k FAT, as this one uses a standard BPB. + // X68K uses cdate/adate from direntry for extending filename + public partial class FAT : IFilesystem + { + public FileSystemType XmlFsType { get; private set; } + + public Encoding Encoding { get; private set; } + public string Name => "Microsoft File Allocation Table"; + public Guid Id => new Guid("33513B2C-0D26-0D2D-32C3-79D8611158E0"); + public string Author => "Natalia Portillo"; + } +} \ No newline at end of file diff --git a/DiscImageChef.Filesystems/FAT/File.cs b/DiscImageChef.Filesystems/FAT/File.cs new file mode 100644 index 000000000..e8cec1770 --- /dev/null +++ b/DiscImageChef.Filesystems/FAT/File.cs @@ -0,0 +1,48 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : File.cs +// Author(s) : Natalia Portillo +// +// Component : Microsoft FAT filesystem plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Methods to handle files. +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2019 Natalia Portillo +// ****************************************************************************/ + +using System; +using DiscImageChef.CommonTypes.Structs; + +namespace DiscImageChef.Filesystems.FAT +{ + public partial class FAT + { + public Errno MapBlock(string path, long fileBlock, out long deviceBlock) => throw new NotImplementedException(); + + public Errno GetAttributes(string path, out FileAttributes attributes) => throw new NotImplementedException(); + + public Errno Read(string path, long offset, long size, ref byte[] buf) => throw new NotImplementedException(); + + public Errno Stat(string path, out FileEntryInfo stat) => throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/DiscImageChef.Filesystems/FAT.cs b/DiscImageChef.Filesystems/FAT/Info.cs similarity index 63% rename from DiscImageChef.Filesystems/FAT.cs rename to DiscImageChef.Filesystems/FAT/Info.cs index 14590ae0e..b2fb4223a 100644 --- a/DiscImageChef.Filesystems/FAT.cs +++ b/DiscImageChef.Filesystems/FAT/Info.cs @@ -2,7 +2,7 @@ // The Disc Image Chef // ---------------------------------------------------------------------------- // -// Filename : FAT.cs +// Filename : Info.cs // Author(s) : Natalia Portillo // // Component : Microsoft FAT filesystem plugin. @@ -33,7 +33,6 @@ using System; using System.IO; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using DiscImageChef.Checksums; using DiscImageChef.CommonTypes; @@ -42,119 +41,11 @@ using DiscImageChef.CommonTypes.Interfaces; using DiscImageChef.Console; using DiscImageChef.Helpers; using Schemas; -using Marshal = DiscImageChef.Helpers.Marshal; -namespace DiscImageChef.Filesystems +namespace DiscImageChef.Filesystems.FAT { - // TODO: Differentiate between Atari and X68k FAT, as this one uses a standard BPB. - // X68K uses cdate/adate from direntry for extending filename - public class FAT : IFilesystem + public partial class FAT { - const uint FSINFO_SIGNATURE1 = 0x41615252; - const uint FSINFO_SIGNATURE2 = 0x61417272; - const uint FSINFO_SIGNATURE3 = 0xAA550000; - - readonly (string hash, string name)[] knownBootHashes = - { - ("b639b4d5b25f63560e3b34a3a0feb732aa65486f", "Amstrad MS-DOS 3.20 (8-sector floppy)"), - ("9311151f13f7611b1431593da05ddd3153370574", "Amstrad MS-DOS 3.20 (Spanish)"), - ("55eda6a9b955f5199020e6b56a6954fa6fcb7dc6", "AT&T MS-DOS 2.11"), - ("d5e10822977efa96e4fbaec2b268ca008d74fe6f", "Atari TOS"), - ("17f11a12b96899d2a4976d889cef160502167f2d", "BeOS"), - ("d0e31673028fcfcea38dff71a7be13669aa20b8d", "Compaq MS-DOS 3.30"), - ("3aa4ce2fa6f9a297b5b15aaef930401af369fcbc", "Compaq MS-DOS 3.30 (8-sector floppy)"), - ("8f1d33520343f35034aa3ce47e4180b10e960b43", "Compaq MS-DOS 3.30 (8-sector floppy)"), - ("2f4011ae0670ff3aff2bdd412a4651f255b600a9", "Compaq MS-DOS 3.31"), - ("afc3fb751089a52c9f0bd37098d3137d32ab4982", "Concurrent DOS 6.0"), - ("c25e2d93d3b8bf9870043bf9d12580ef07f5375e", "CrossDOS"), - ("43fb2afa1ab3102b3f8d0fe901b652a5b0a973e1", "DR-DOS >=7.02"), - ("92d83b7e9e3bd4b73c6b98f8c6434206eac7212f", "DR-DOS 3.40"), - ("6a7aba05f91c5a7108edc5d5ccc9dac0ebf5dd28", "DR-DOS 3.40"), - ("715e78bb1e38b56452dd1c15db8c096dc506eea3", "DR-DOS 3.41"), - ("01e46cb2bc6d65ddd89ba28d254baf563d8fc609", "DR-DOS 5.00"), - ("dd297f159eef8a61f5eec638ce7318a098fa26f4", "DR-DOS 5.00"), - ("f590e53ae7f9caec5dba93241e557710be61b6fe", "DR-DOS 6.00"), - ("630e4aaf230f15eb2d09985f294815b6bc50384c", "DR-DOS 6.00"), - ("8851459816d714f53b9c469472e51460ebd44b98", "DR-DOS 7.03"), - ("cf24388b61eb1b137f2bb8a4c319e7461d460b72", "DR-DOS 7.03"), - ("26bf8efe8368e598397b1f79d635faccf5ca4f87", "DR-DOS 8.00"), - ("36ddd6bf8686801f5a2a3cbd4656afa175cabdfc", "DR-DOS 8.00"), - ("9ac09781e4090d9ba5e1a31816b4ebfa6b54f39e", "DR-DOS 8.00"), - ("f5d68f26abec8392ac23716581c4ab1d6e8456a2", "eComStation"), - ("e2a852db8c3eb3d86ca86a706186a9dd54cdc815", "Epson MS-DOS 3.10"), - ("74675d158dd0f6b5983bd30dda7018a814bd34dd", "Epson MS-DOS 3.20"), - ("683a04f34714555df5e862f709f9abc7de51488e", "Epson MS-DOS 5.00 (PC-98)"), - ("1b062df94fc576af069e40603bf2558000a2ca10", "FreeBSD, NetBSD, Mac OS X"), - ("33c8e306b3a51e09668fd60f099450019a1238ea", "FreeBSD, NetBSD, Mac OS X"), - ("ca386b1cefaf964a49192c2cd08077aff09b82af", "FreeDOS"), - ("26033e0db1ee4f439f07077b790e189d1b77688c", "HP MS-DOS 3.20"), - ("66867cd665e0e87c32de0bcb721ecfe91a551bc5", "mkfs.vfat"), - ("48d4811dbea5d724803017d6d45a49d604982b7b", "mkfs.vfat"), - ("02d615c5fb68bc49766bf89777dd36accb1428b7", "MS-DOS >=4.01, PC-DOS >=5.00 (8-sector floppy)"), - ("cffb1dc01bf9f533ba63d949c359c9ae97944c9b", "MS-DOS >=5.00"), - ("bd099151f2f9f8b3815eef7d9fed90abead52d97", "MS-DOS 3.21"), - ("f338eeff68f4e03ce489eb165e18fd94f8a0c63e", "MS-DOS 3.30A"), - ("0eb0c789e141d59d91f075ef14d63fd4255aeac2", "MS-DOS 3.30A, 5.00, 6.xx (8-sector floppy)"), - ("7aa06595490f92e542965b43805eaa0d6da9c86c", "MS-DOS 3.31"), - ("00401ca66900d7defcbc3d794654d1ba2376e83d", "MS-DOS 3.31"), - ("00e39a27d9b36e88f2b0caaa1959a8e17223bf31", "MS-DOS 3.31 (8-sector floppy)"), - ("1e74fbad5948582247280b116e7175b5a16bcede", "MS-DOS 3.31 (8-sector floppy)"), - ("1cfb2cc3a34c8164b8f5051c118643b23a60f4d0", "MS-DOS 4.01"), - ("d370551c8aca9cfcd964e2a1235071329f93cc03", "Multiuser DOS 7.22r4"), - ("7106ea11dd0b9a39649cbb4f6314a0fa1241da38", "NEC >=MS-DOS 5.00 (PC-98)"), - ("30d4f5f54215af0fc69236594e52b94989b35c21", "NEC MS-DOS 3.30 (PC-98)"), - ("eae42777f562eb81ed624f0c0479347ba11158c9", "Novell DOS 7.00"), - ("c67a7d0bab94a960cca8720d476f5317c960b2fb", "Novell DOS 7.00"), - ("0ed508c71bcf1418a1701b9267ddf166e7993b6b", "Olivetti MS-DOS 3.10"), - ("3e1a3f22973d9f2d15f9a053204c2f7b72de00a9", "OS/2 1.00"), - ("4acb13943f21a266f9eb110969980481783c41c4", "OS/2 1.10"), - ("cc7b32236c76d34edefdac3ca6a7be8e26163cea", "OS/2 1.20, 1.30"), - ("05c6706189fa0532ea83a7484b88d1dcba63e167", "OS/2 2.00"), - ("eefb4383b3e2b05f7f7e0051d58f4617a4f39e42", "OS/2 2.1x, Warp 3"), - ("b1d9666ae8781958242da27d319e73aa2dda6805", "OS/2 Warp 4"), - ("661d92970ab0f81cec453dc7584e0debdd1b4928", "PC-DOS >=5.00"), - ("78522b303fe5752f3cb37eabb6cb54e6cb0cd276", "PC-DOS 2.xx"), - ("277edfefdc3f05a219f9378076227c4126b6c8ef", "PC-DOS 3.00"), - ("f72ef6ff4c90a170bc8cdd1b01e8d98235c16a3b", "PC-DOS 3.10"), - ("cb6b6c1bc024e025710288da652d0d93527a71db", "PC-DOS 3.30"), - ("3b844e2a411182958c2d9e6ee17c6d4fff18bd73", "PC-DOS 4.00"), - ("45e82fcff4c6f8a9c31418323bc063011f5730e5", "PCExchange 2.0"), - ("707849fd75b6a52fd219c3cebe060ecb23c40fc7", "SCO OpenServer"), - ("9f7f146b513b00ff9e8b5b927aee24025c3f3fb8", "Toshiba MS-DOS 3.30"), - ("30eafc45a4606a7b840dcd5899dfb977a837c835", "Toshiba MS-DOS 4.01"), - ("5695a9a69637bd4d4eaa531b976d6f3b71e8d4ad", "Toshiba MS-DOS 4.01"), - ("036a59138d620c16e8d0dba45af4dec4ae1376f7", "Windows 10"), - ("3dd2941b79f0f6644b3a973c7d81e64e434c0b70", "Windows 2000"), - ("cd1e2fced2e49825df23c08a3d1e280c1cf468a7", "Windows 2000"), - ("c20c6e706be97091768da8654fffc2f3c0431318", "Windows 95"), - ("cf750cc0d2d52251a1a0fb9f2568fed3ff81717a", "Windows 95 >=OSR2"), - ("48865a298d4bbe73f89c4de10153e16250c1a9ae", "Windows 95 >=OSR2"), - ("1d2df8f3b1b336fc4aa1c6e49b21956194884b41", "Windows 98 (Spanish)"), - ("6e6fb4a3ea034415d716b1f81217ffecf78813c3", "Windows 98 (Spanish)"), - ("9b5e6be09200145a6ed7c22d14b1e6b4de2f362b", "Windows 98 (Spanish)"), - ("3cea1921d29fcd3343d36c090cb3e3dba926781d", "Windows 98, Me"), - ("037f9c8caed602d93c88f7e9d8f13a732b3ada76", "Windows NT"), - ("a63806bfe11140c873082318dd4da834068be327", "Windows Vista"), - ("8f024b3d501c39ee6e3f8ca28173ad6a780d3eb0", "Windows Vista, 8, 10"), - ("d3e93f8b82ef250db216037d827a4896dc97d2be", "TracerST"), // OEM ID: "TracerST" - //("b741f85ef40288ccc8887de1f6e849009097e1c9", "Norton Utilities"), // OEM ID: "IBM PNCI", need to confirm - ("c49b275537ac7237cac64d83f34d2024ae0ca96a", - "Windows NT (Spanish)"), // Need to check Windows >= 2000 (Spanish) - //("a48b0e4b696317eed829e960d1aa576562a4f185", "TracerST"), // Unknown OEM ID, apparently Tracer, unconfirmed - ("fe477972602ba76658ff7143859045b3c4036ca5", - "iomega"), // OEM ID: "SHIPDISK", contains timedate on boot code may not be unique - ("ef79a1f33e5237827eb812dda548f0e4e916d815", "GEOS"), // OEM ID: "GEOWORKS" - ("8524587ee91494cc51cc2c9d07453e84be0cdc33", "Hero Soft v1.10"), - ("681a0d9d662ba368e6acb0d0bf602e1f56411144", "Human68k 2.00") - }; - - public FileSystemType XmlFsType { get; private set; } - - public Encoding Encoding { get; private set; } - public string Name => "Microsoft File Allocation Table"; - public Guid Id => new Guid("33513B2C-0D26-0D2D-32C3-79D8611158E0"); - public string Author => "Natalia Portillo"; - public bool Identify(IMediaImage imagePlugin, Partition partition) { if(2 + partition.Start >= partition.End) return false; @@ -1593,850 +1484,5 @@ namespace DiscImageChef.Filesystems information = sb.ToString(); } - - /// - /// BIOS Parameter Block as used by Atari ST GEMDOS on FAT12 volumes. - /// - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct AtariParameterBlock - { - /// 68000 BRA.S jump or x86 loop - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - public readonly byte[] jump; - /// OEM Name, 6 bytes, space-padded, "Loader" for Atari ST boot loader - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] - public readonly byte[] oem_name; - /// Volume serial number - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] serial_no; - /// Bytes per sector - public readonly ushort bps; - /// Sectors per cluster - public readonly byte spc; - /// Reserved sectors between BPB and FAT (inclusive) - public readonly ushort rsectors; - /// Number of FATs - public readonly byte fats_no; - /// Number of entries on root directory - public readonly ushort root_ent; - /// Sectors in volume - public ushort sectors; - /// Media descriptor, unused by GEMDOS - public readonly byte media; - /// Sectors per FAT - public readonly ushort spfat; - /// Sectors per track - public readonly ushort sptrk; - /// Heads - public readonly ushort heads; - /// Hidden sectors before BPB, unused by GEMDOS - public readonly ushort hsectors; - /// Word to be loaded in the cmdload system variable. Big-endian. - public readonly ushort execflag; - /// - /// Word indicating load mode. If zero, file named is located and loaded. It not, sectors - /// specified in and are loaded. Big endian. - /// - public readonly ushort ldmode; - /// Starting sector of boot code. - public readonly ushort ssect; - /// Count of sectors of boot code. - public readonly ushort sectcnt; - /// Address where boot code should be loaded. - public readonly ushort ldaaddr; - /// Padding. - public readonly ushort padding; - /// Address where FAT and root directory sectors must be loaded. - public readonly ushort fatbuf; - /// Unknown. - public readonly ushort unknown; - /// Filename to be loaded for booting. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] - public readonly byte[] fname; - /// Reserved - public readonly ushort reserved; - /// Boot code. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 455)] - public readonly byte[] boot_code; - /// Big endian word to make big endian sum of all sector words be equal to 0x1234 if disk is bootable. - public readonly ushort checksum; - } - - /// - /// BIOS Parameter Block as used by MSX-DOS 2. - /// - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct MsxParameterBlock - { - /// x86 loop - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] jump; - /// OEM Name, 8 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] oem_name; - /// Bytes per sector - public readonly ushort bps; - /// Sectors per cluster - public readonly byte spc; - /// Reserved sectors between BPB and FAT (inclusive) - public readonly ushort rsectors; - /// Number of FATs - public readonly byte fats_no; - /// Number of entries on root directory - public readonly ushort root_ent; - /// Sectors in volume - public ushort sectors; - /// Media descriptor - public readonly byte media; - /// Sectors per FAT - public readonly ushort spfat; - /// Sectors per track - public readonly ushort sptrk; - /// Heads - public readonly ushort heads; - /// Hidden sectors before BPB - public readonly ushort hsectors; - /// Jump for MSX-DOS 1 boot code - public readonly ushort msxdos_jmp; - /// Set to "VOL_ID" by MSX-DOS 2 - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] - public readonly byte[] vol_id; - /// Bigger than 0 if there are deleted files (MSX-DOS 2) - public readonly byte undelete_flag; - /// Volume serial number (MSX-DOS 2) - public readonly uint serial_no; - /// Reserved (MSX-DOS 2) - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] - public readonly byte[] reserved; - /// Jump for MSX-DOS 2 boot code (MSX-DOS 2) - public readonly ushort msxdos2_jmp; - /// Boot code. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 460)] - public readonly byte[] boot_code; - /// Always 0x55 0xAA. - public readonly ushort boot_signature; - } - - /// DOS 2.0 BIOS Parameter Block. - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BiosParameterBlock2 - { - /// x86 jump - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] jump; - /// OEM Name, 8 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] oem_name; - /// Bytes per sector - public readonly ushort bps; - /// Sectors per cluster - public readonly byte spc; - /// Reserved sectors between BPB and FAT - public readonly ushort rsectors; - /// Number of FATs - public readonly byte fats_no; - /// Number of entries on root directory - public readonly ushort root_ent; - /// Sectors in volume - public ushort sectors; - /// Media descriptor - public readonly byte media; - /// Sectors per FAT - public readonly ushort spfat; - /// Boot code. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 486)] - public readonly byte[] boot_code; - /// 0x55 0xAA if bootable. - public readonly ushort boot_signature; - } - - /// DOS 3.0 BIOS Parameter Block. - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BiosParameterBlock30 - { - /// x86 jump - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] jump; - /// OEM Name, 8 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] oem_name; - /// Bytes per sector - public readonly ushort bps; - /// Sectors per cluster - public readonly byte spc; - /// Reserved sectors between BPB and FAT - public readonly ushort rsectors; - /// Number of FATs - public readonly byte fats_no; - /// Number of entries on root directory - public readonly ushort root_ent; - /// Sectors in volume - public ushort sectors; - /// Media descriptor - public readonly byte media; - /// Sectors per FAT - public readonly ushort spfat; - /// Sectors per track - public readonly ushort sptrk; - /// Heads - public readonly ushort heads; - /// Hidden sectors before BPB - public readonly ushort hsectors; - /// Boot code. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 480)] - public readonly byte[] boot_code; - /// Always 0x55 0xAA. - public readonly ushort boot_signature; - } - - /// DOS 3.2 BIOS Parameter Block. - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BiosParameterBlock32 - { - /// x86 jump - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] jump; - /// OEM Name, 8 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] oem_name; - /// Bytes per sector - public readonly ushort bps; - /// Sectors per cluster - public readonly byte spc; - /// Reserved sectors between BPB and FAT - public readonly ushort rsectors; - /// Number of FATs - public readonly byte fats_no; - /// Number of entries on root directory - public readonly ushort root_ent; - /// Sectors in volume - public ushort sectors; - /// Media descriptor - public readonly byte media; - /// Sectors per FAT - public readonly ushort spfat; - /// Sectors per track - public readonly ushort sptrk; - /// Heads - public readonly ushort heads; - /// Hidden sectors before BPB - public readonly ushort hsectors; - /// Total sectors including hidden ones - public readonly ushort total_sectors; - /// Boot code. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 478)] - public readonly byte[] boot_code; - /// Always 0x55 0xAA. - public readonly ushort boot_signature; - } - - /// DOS 3.31 BIOS Parameter Block. - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BiosParameterBlock33 - { - /// x86 jump - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] jump; - /// OEM Name, 8 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] oem_name; - /// Bytes per sector - public readonly ushort bps; - /// Sectors per cluster - public readonly byte spc; - /// Reserved sectors between BPB and FAT - public readonly ushort rsectors; - /// Number of FATs - public readonly byte fats_no; - /// Number of entries on root directory - public readonly ushort root_ent; - /// Sectors in volume - public ushort sectors; - /// Media descriptor - public readonly byte media; - /// Sectors per FAT - public readonly ushort spfat; - /// Sectors per track - public readonly ushort sptrk; - /// Heads - public readonly ushort heads; - /// Hidden sectors before BPB - public readonly uint hsectors; - /// Sectors in volume if > 65535 - public uint big_sectors; - /// Boot code. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 474)] - public readonly byte[] boot_code; - /// Always 0x55 0xAA. - public readonly ushort boot_signature; - } - - /// DOS 3.4 BIOS Parameter Block. - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BiosParameterBlockShortEbpb - { - /// x86 jump - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] jump; - /// OEM Name, 8 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] oem_name; - /// Bytes per sector - public readonly ushort bps; - /// Sectors per cluster - public readonly byte spc; - /// Reserved sectors between BPB and FAT - public readonly ushort rsectors; - /// Number of FATs - public readonly byte fats_no; - /// Number of entries on root directory - public readonly ushort root_ent; - /// Sectors in volume - public ushort sectors; - /// Media descriptor - public readonly byte media; - /// Sectors per FAT - public readonly ushort spfat; - /// Sectors per track - public readonly ushort sptrk; - /// Heads - public readonly ushort heads; - /// Hidden sectors before BPB - public readonly uint hsectors; - /// Sectors in volume if > 65535 - public uint big_sectors; - /// Drive number - public readonly byte drive_no; - /// Volume flags - public readonly byte flags; - /// EPB signature, 0x28 - public readonly byte signature; - /// Volume serial number - public readonly uint serial_no; - /// Boot code. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 467)] - public readonly byte[] boot_code; - /// Always 0x55 0xAA. - public readonly ushort boot_signature; - } - - /// DOS 4.0 or higher BIOS Parameter Block. - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct BiosParameterBlockEbpb - { - /// x86 jump - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public byte[] jump; - /// OEM Name, 8 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public byte[] oem_name; - /// Bytes per sector - public ushort bps; - /// Sectors per cluster - public byte spc; - /// Reserved sectors between BPB and FAT - public ushort rsectors; - /// Number of FATs - public byte fats_no; - /// Number of entries on root directory - public ushort root_ent; - /// Sectors in volume - public ushort sectors; - /// Media descriptor - public byte media; - /// Sectors per FAT - public ushort spfat; - /// Sectors per track - public ushort sptrk; - /// Heads - public ushort heads; - /// Hidden sectors before BPB - public uint hsectors; - /// Sectors in volume if > 65535 - public uint big_sectors; - /// Drive number - public byte drive_no; - /// Volume flags - public byte flags; - /// EPB signature, 0x29 - public byte signature; - /// Volume serial number - public uint serial_no; - /// Volume label, 11 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] - public readonly byte[] volume_label; - /// Filesystem type, 8 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] fs_type; - /// Boot code. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 448)] - public byte[] boot_code; - /// Always 0x55 0xAA. - public ushort boot_signature; - } - - /// FAT32 Parameter Block - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Fat32ParameterBlockShort - { - /// x86 jump - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] jump; - /// OEM Name, 8 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] oem_name; - /// Bytes per sector - public readonly ushort bps; - /// Sectors per cluster - public readonly byte spc; - /// Reserved sectors between BPB and FAT - public readonly ushort rsectors; - /// Number of FATs - public readonly byte fats_no; - /// Number of entries on root directory, set to 0 - public readonly ushort root_ent; - /// Sectors in volume, set to 0 - public ushort sectors; - /// Media descriptor - public readonly byte media; - /// Sectors per FAT, set to 0 - public readonly ushort spfat; - /// Sectors per track - public readonly ushort sptrk; - /// Heads - public readonly ushort heads; - /// Hidden sectors before BPB - public readonly uint hsectors; - /// Sectors in volume - public uint big_sectors; - /// Sectors per FAT - public readonly uint big_spfat; - /// FAT flags - public readonly ushort mirror_flags; - /// FAT32 version - public readonly ushort version; - /// Cluster of root directory - public readonly uint root_cluster; - /// Sector of FSINFO structure - public readonly ushort fsinfo_sector; - /// Sector of FAT32PB backup - public readonly ushort backup_sector; - /// Reserved - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] - public readonly byte[] reserved; - /// Drive number - public readonly byte drive_no; - /// Volume flags - public readonly byte flags; - /// Signature, should be 0x28 - public readonly byte signature; - /// Volume serial number - public readonly uint serial_no; - /// Volume label, 11 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] - public readonly byte[] reserved2; - /// Sectors in volume if equals 0 - public ulong huge_sectors; - /// Boot code. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 420)] - public readonly byte[] boot_code; - /// Always 0x55 0xAA. - public readonly ushort boot_signature; - } - - /// FAT32 Parameter Block - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct Fat32ParameterBlock - { - /// x86 jump - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] jump; - /// OEM Name, 8 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] oem_name; - /// Bytes per sector - public ushort bps; - /// Sectors per cluster - public byte spc; - /// Reserved sectors between BPB and FAT - public readonly ushort rsectors; - /// Number of FATs - public readonly byte fats_no; - /// Number of entries on root directory, set to 0 - public readonly ushort root_ent; - /// Sectors in volume, set to 0 - public ushort sectors; - /// Media descriptor - public readonly byte media; - /// Sectors per FAT, set to 0 - public readonly ushort spfat; - /// Sectors per track - public ushort sptrk; - /// Heads - public readonly ushort heads; - /// Hidden sectors before BPB - public uint hsectors; - /// Sectors in volume - public uint big_sectors; - /// Sectors per FAT - public uint big_spfat; - /// FAT flags - public readonly ushort mirror_flags; - /// FAT32 version - public readonly ushort version; - /// Cluster of root directory - public readonly uint root_cluster; - /// Sector of FSINFO structure - public readonly ushort fsinfo_sector; - /// Sector of FAT32PB backup - public readonly ushort backup_sector; - /// Reserved - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] - public readonly byte[] reserved; - /// Drive number - public readonly byte drive_no; - /// Volume flags - public readonly byte flags; - /// Signature, should be 0x29 - public readonly byte signature; - /// Volume serial number - public readonly uint serial_no; - /// Volume label, 11 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] - public readonly byte[] volume_label; - /// Filesystem type, 8 bytes, space-padded, must be "FAT32 " - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] fs_type; - /// Boot code. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 419)] - public readonly byte[] boot_code; - /// Always 0x55 0xAA. - public readonly ushort boot_signature; - } - - /// Apricot Label. - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ApricotLabel - { - /// Version of format which created disk - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] version; - /// Operating system. - public readonly byte operatingSystem; - /// Software write protection. - [MarshalAs(UnmanagedType.U1)] - public readonly bool writeProtected; - /// Copy protected. - [MarshalAs(UnmanagedType.U1)] - public readonly bool copyProtected; - /// Boot type. - public readonly byte bootType; - /// Partitions. - public readonly byte partitionCount; - /// Is hard disk?. - [MarshalAs(UnmanagedType.U1)] - public readonly bool winchester; - /// Sector size. - public readonly ushort sectorSize; - /// Sectors per track. - public readonly ushort spt; - /// Tracks per side. - public readonly uint cylinders; - /// Sides. - public readonly byte heads; - /// Interleave factor. - public readonly byte interleave; - /// Skew factor. - public readonly ushort skew; - /// Sector where boot code starts. - public readonly uint bootLocation; - /// Size in sectors of boot code. - public readonly ushort bootSize; - /// Address at which to load boot code. - public readonly uint bootAddress; - /// Offset where to jump to boot. - public readonly ushort bootOffset; - /// Segment where to jump to boot. - public readonly ushort bootSegment; - /// First data sector. - public readonly uint firstDataBlock; - /// Generation. - public readonly ushort generation; - /// Copy count. - public readonly ushort copyCount; - /// Maximum number of copies. - public readonly ushort maxCopies; - /// Serial number. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] serialNumber; - /// Part number. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] partNumber; - /// Copyright. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] - public readonly byte[] copyright; - /// BPB for whole disk. - public ApricotParameterBlock mainBPB; - /// Name of FONT file. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] fontName; - /// Name of KEYBOARD file. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] keyboardName; - /// Minor BIOS version. - public readonly byte biosMinorVersion; - /// Major BIOS version. - public readonly byte biosMajorVersion; - /// Diagnostics enabled?. - [MarshalAs(UnmanagedType.U1)] - public readonly bool diagnosticsFlag; - /// Printer device. - public readonly byte prnDevice; - /// Bell volume. - public readonly byte bellVolume; - /// Cache enabled?. - [MarshalAs(UnmanagedType.U1)] - public readonly bool enableCache; - /// Graphics enabled?. - [MarshalAs(UnmanagedType.U1)] - public readonly bool enableGraphics; - /// Length in sectors of DOS. - public readonly byte dosLength; - /// Length in sectors of FONT file. - public readonly byte fontLength; - /// Length in sectors of KEYBOARD file. - public readonly byte keyboardLength; - /// Starting sector of DOS. - public readonly ushort dosStart; - /// Starting sector of FONT file. - public readonly ushort fontStart; - /// Starting sector of KEYBOARD file. - public readonly ushort keyboardStart; - /// Keyboard click volume. - public readonly byte keyboardVolume; - /// Auto-repeat enabled?. - [MarshalAs(UnmanagedType.U1)] - public readonly bool autorepeat; - /// Auto-repeat lead-in. - public readonly byte autorepeatLeadIn; - /// Auto-repeat interval. - public readonly byte autorepeatInterval; - /// Microscreen mode. - public readonly byte microscreenMode; - /// Spare area for keyboard values expansion. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] - public readonly byte[] spareKeyboard; - /// Screen line mode. - public readonly byte lineMode; - /// Screen line width. - public readonly byte lineWidth; - /// Screen disabled?. - [MarshalAs(UnmanagedType.U1)] - public readonly bool imageOff; - /// Spare area for screen values expansion. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)] - public readonly byte[] spareScreen; - /// TX baud rate. - public readonly byte txBaudRate; - /// RX baud rate. - public readonly byte rxBaudRate; - /// TX bits. - public readonly byte txBits; - /// RX bits. - public readonly byte rxBits; - /// Stop bits. - public readonly byte stopBits; - /// Parity enabled?. - [MarshalAs(UnmanagedType.U1)] - public readonly bool parityCheck; - /// Parity type. - public readonly byte parityType; - /// Xon/Xoff enabled on TX. - [MarshalAs(UnmanagedType.U1)] - public readonly bool txXonXoff; - /// Xon/Xoff enabled on RX. - [MarshalAs(UnmanagedType.U1)] - public readonly bool rxXonXoff; - /// Xon character. - public readonly byte xonCharacter; - /// Xoff character. - public readonly byte xoffCharacter; - /// Xon/Xoff buffer on RX. - public readonly ushort rxXonXoffBuffer; - /// DTR/DSR enabled?. - [MarshalAs(UnmanagedType.U1)] - public readonly bool dtrDsr; - /// CTS/RTS enabled?. - [MarshalAs(UnmanagedType.U1)] - public readonly bool ctsRts; - /// NULLs after CR. - public readonly byte nullsAfterCr; - /// NULLs after 0xFF. - public readonly byte nullsAfterFF; - /// Send LF after CR in serial port. - [MarshalAs(UnmanagedType.U1)] - public readonly bool lfAfterCRSerial; - /// BIOS error report in serial port. - [MarshalAs(UnmanagedType.U1)] - public readonly bool biosErrorReportSerial; - /// Spare area for serial port values expansion. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)] - public readonly byte[] spareSerial; - /// Send LF after CR in parallel port. - [MarshalAs(UnmanagedType.U1)] - public readonly bool lfAfterCrParallel; - /// Select line supported?. - [MarshalAs(UnmanagedType.U1)] - public readonly bool selectLine; - /// Paper empty supported?. - [MarshalAs(UnmanagedType.U1)] - public readonly bool paperEmpty; - /// Fault line supported?. - [MarshalAs(UnmanagedType.U1)] - public readonly bool faultLine; - /// BIOS error report in parallel port. - [MarshalAs(UnmanagedType.U1)] - public readonly bool biosErrorReportParallel; - /// Spare area for parallel port values expansion. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] - public readonly byte[] spareParallel; - /// Spare area for Winchester values expansion. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] - public readonly byte[] spareWinchester; - /// Parking enabled?. - [MarshalAs(UnmanagedType.U1)] - public readonly bool parkingEnabled; - /// Format protection?. - [MarshalAs(UnmanagedType.U1)] - public readonly bool formatProtection; - /// Spare area for RAM disk values expansion. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] spareRamDisk; - /// List of bad blocks. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public readonly ushort[] badBlocks; - /// Array of partition BPBs. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly ApricotParameterBlock[] partitions; - /// Spare area. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 63)] - public readonly byte[] spare; - /// CP/M double side indicator?. - public readonly bool cpmDoubleSided; - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct ApricotParameterBlock - { - /// Bytes per sector - public readonly ushort bps; - /// Sectors per cluster - public readonly byte spc; - /// Reserved sectors between BPB and FAT - public readonly ushort rsectors; - /// Number of FATs - public readonly byte fats_no; - /// Number of entries on root directory - public readonly ushort root_ent; - /// Sectors in volume - public ushort sectors; - /// Media descriptor - public readonly byte media; - /// Sectors per FAT - public readonly ushort spfat; - /// Disk type - public readonly byte diskType; - /// Volume starting sector - public readonly ushort startSector; - } - - /// FAT32 FS Information Sector - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct FsInfoSector - { - /// Signature must be - public readonly uint signature1; - /// Reserved - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 480)] - public readonly byte[] reserved1; - /// Signature must be - public readonly uint signature2; - /// Free clusters - public readonly uint free_clusters; - /// cated cluster - public readonly uint last_cluster; - /// Reserved - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] - public readonly byte[] reserved2; - /// Signature must be - public readonly uint signature3; - } - - /// Human68k Parameter Block, big endian, 512 bytes even on 256 bytes/sector. - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct HumanParameterBlock - { - /// 68k bra.S - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] - public readonly byte[] jump; - /// OEM Name, 16 bytes, space-padded - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] - public readonly byte[] oem_name; - /// Bytes per cluster - public readonly ushort bpc; - /// Unknown, seen 1, 2 and 16 - public readonly byte unknown1; - /// Unknown, always 512? - public readonly ushort unknown2; - /// Unknown, always 1? - public readonly byte unknown3; - /// Number of entries on root directory - public readonly ushort root_ent; - /// Clusters, set to 0 if more than 65536 - public readonly ushort clusters; - /// Media descriptor - public readonly byte media; - /// Clusters per FAT, set to 0 - public readonly byte cpfat; - /// Clustersin volume - public readonly uint big_clusters; - /// Boot code. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 478)] - public readonly byte[] boot_code; - } - - [Flags] - enum FatAttributes : byte - { - ReadOnly = 0x01, - Hidden = 0x02, - System = 0x04, - VolumeLabel = 0x08, - Subdirectory = 0x10, - Archive = 0x20, - Device = 0x40, - Reserved = 0x80, - LFN = 0x0F - } - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - struct DirectoryEntry - { - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] - public readonly byte[] filename; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] - public readonly byte[] extension; - public readonly FatAttributes attributes; - public readonly byte caseinfo; - public readonly byte ctime_ms; - public readonly ushort ctime; - public readonly ushort cdate; - public readonly ushort adate; - public readonly ushort ea_handle; - public readonly ushort mtime; - public readonly ushort mdate; - public readonly ushort start_cluster; - public readonly uint size; - } } } \ No newline at end of file diff --git a/DiscImageChef.Filesystems/FAT/Structs.cs b/DiscImageChef.Filesystems/FAT/Structs.cs new file mode 100644 index 000000000..b958209cb --- /dev/null +++ b/DiscImageChef.Filesystems/FAT/Structs.cs @@ -0,0 +1,870 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Structs.cs +// Author(s) : Natalia Portillo +// +// Component : Microsoft FAT filesystem plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Microsoft FAT filesystem structures. +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2019 Natalia Portillo +// ****************************************************************************/ + +using System.Runtime.InteropServices; + +namespace DiscImageChef.Filesystems.FAT +{ + public partial class FAT + { + /// + /// BIOS Parameter Block as used by Atari ST GEMDOS on FAT12 volumes. + /// + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct AtariParameterBlock + { + /// 68000 BRA.S jump or x86 loop + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + public readonly byte[] jump; + /// OEM Name, 6 bytes, space-padded, "Loader" for Atari ST boot loader + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)] + public readonly byte[] oem_name; + /// Volume serial number + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] serial_no; + /// Bytes per sector + public readonly ushort bps; + /// Sectors per cluster + public readonly byte spc; + /// Reserved sectors between BPB and FAT (inclusive) + public readonly ushort rsectors; + /// Number of FATs + public readonly byte fats_no; + /// Number of entries on root directory + public readonly ushort root_ent; + /// Sectors in volume + public ushort sectors; + /// Media descriptor, unused by GEMDOS + public readonly byte media; + /// Sectors per FAT + public readonly ushort spfat; + /// Sectors per track + public readonly ushort sptrk; + /// Heads + public readonly ushort heads; + /// Hidden sectors before BPB, unused by GEMDOS + public readonly ushort hsectors; + /// Word to be loaded in the cmdload system variable. Big-endian. + public readonly ushort execflag; + /// + /// Word indicating load mode. If zero, file named is located and loaded. It not, sectors + /// specified in and are loaded. Big endian. + /// + public readonly ushort ldmode; + /// Starting sector of boot code. + public readonly ushort ssect; + /// Count of sectors of boot code. + public readonly ushort sectcnt; + /// Address where boot code should be loaded. + public readonly ushort ldaaddr; + /// Padding. + public readonly ushort padding; + /// Address where FAT and root directory sectors must be loaded. + public readonly ushort fatbuf; + /// Unknown. + public readonly ushort unknown; + /// Filename to be loaded for booting. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] + public readonly byte[] fname; + /// Reserved + public readonly ushort reserved; + /// Boot code. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 455)] + public readonly byte[] boot_code; + /// Big endian word to make big endian sum of all sector words be equal to 0x1234 if disk is bootable. + public readonly ushort checksum; + } + + /// + /// BIOS Parameter Block as used by MSX-DOS 2. + /// + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct MsxParameterBlock + { + /// x86 loop + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] jump; + /// OEM Name, 8 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] oem_name; + /// Bytes per sector + public readonly ushort bps; + /// Sectors per cluster + public readonly byte spc; + /// Reserved sectors between BPB and FAT (inclusive) + public readonly ushort rsectors; + /// Number of FATs + public readonly byte fats_no; + /// Number of entries on root directory + public readonly ushort root_ent; + /// Sectors in volume + public ushort sectors; + /// Media descriptor + public readonly byte media; + /// Sectors per FAT + public readonly ushort spfat; + /// Sectors per track + public readonly ushort sptrk; + /// Heads + public readonly ushort heads; + /// Hidden sectors before BPB + public readonly ushort hsectors; + /// Jump for MSX-DOS 1 boot code + public readonly ushort msxdos_jmp; + /// Set to "VOL_ID" by MSX-DOS 2 + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] + public readonly byte[] vol_id; + /// Bigger than 0 if there are deleted files (MSX-DOS 2) + public readonly byte undelete_flag; + /// Volume serial number (MSX-DOS 2) + public readonly uint serial_no; + /// Reserved (MSX-DOS 2) + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)] + public readonly byte[] reserved; + /// Jump for MSX-DOS 2 boot code (MSX-DOS 2) + public readonly ushort msxdos2_jmp; + /// Boot code. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 460)] + public readonly byte[] boot_code; + /// Always 0x55 0xAA. + public readonly ushort boot_signature; + } + + /// DOS 2.0 BIOS Parameter Block. + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct BiosParameterBlock2 + { + /// x86 jump + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] jump; + /// OEM Name, 8 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] oem_name; + /// Bytes per sector + public readonly ushort bps; + /// Sectors per cluster + public readonly byte spc; + /// Reserved sectors between BPB and FAT + public readonly ushort rsectors; + /// Number of FATs + public readonly byte fats_no; + /// Number of entries on root directory + public readonly ushort root_ent; + /// Sectors in volume + public ushort sectors; + /// Media descriptor + public readonly byte media; + /// Sectors per FAT + public readonly ushort spfat; + /// Boot code. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 486)] + public readonly byte[] boot_code; + /// 0x55 0xAA if bootable. + public readonly ushort boot_signature; + } + + /// DOS 3.0 BIOS Parameter Block. + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct BiosParameterBlock30 + { + /// x86 jump + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] jump; + /// OEM Name, 8 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] oem_name; + /// Bytes per sector + public readonly ushort bps; + /// Sectors per cluster + public readonly byte spc; + /// Reserved sectors between BPB and FAT + public readonly ushort rsectors; + /// Number of FATs + public readonly byte fats_no; + /// Number of entries on root directory + public readonly ushort root_ent; + /// Sectors in volume + public ushort sectors; + /// Media descriptor + public readonly byte media; + /// Sectors per FAT + public readonly ushort spfat; + /// Sectors per track + public readonly ushort sptrk; + /// Heads + public readonly ushort heads; + /// Hidden sectors before BPB + public readonly ushort hsectors; + /// Boot code. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 480)] + public readonly byte[] boot_code; + /// Always 0x55 0xAA. + public readonly ushort boot_signature; + } + + /// DOS 3.2 BIOS Parameter Block. + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct BiosParameterBlock32 + { + /// x86 jump + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] jump; + /// OEM Name, 8 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] oem_name; + /// Bytes per sector + public readonly ushort bps; + /// Sectors per cluster + public readonly byte spc; + /// Reserved sectors between BPB and FAT + public readonly ushort rsectors; + /// Number of FATs + public readonly byte fats_no; + /// Number of entries on root directory + public readonly ushort root_ent; + /// Sectors in volume + public ushort sectors; + /// Media descriptor + public readonly byte media; + /// Sectors per FAT + public readonly ushort spfat; + /// Sectors per track + public readonly ushort sptrk; + /// Heads + public readonly ushort heads; + /// Hidden sectors before BPB + public readonly ushort hsectors; + /// Total sectors including hidden ones + public readonly ushort total_sectors; + /// Boot code. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 478)] + public readonly byte[] boot_code; + /// Always 0x55 0xAA. + public readonly ushort boot_signature; + } + + /// DOS 3.31 BIOS Parameter Block. + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct BiosParameterBlock33 + { + /// x86 jump + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] jump; + /// OEM Name, 8 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] oem_name; + /// Bytes per sector + public readonly ushort bps; + /// Sectors per cluster + public readonly byte spc; + /// Reserved sectors between BPB and FAT + public readonly ushort rsectors; + /// Number of FATs + public readonly byte fats_no; + /// Number of entries on root directory + public readonly ushort root_ent; + /// Sectors in volume + public ushort sectors; + /// Media descriptor + public readonly byte media; + /// Sectors per FAT + public readonly ushort spfat; + /// Sectors per track + public readonly ushort sptrk; + /// Heads + public readonly ushort heads; + /// Hidden sectors before BPB + public readonly uint hsectors; + /// Sectors in volume if > 65535 + public uint big_sectors; + /// Boot code. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 474)] + public readonly byte[] boot_code; + /// Always 0x55 0xAA. + public readonly ushort boot_signature; + } + + /// DOS 3.4 BIOS Parameter Block. + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct BiosParameterBlockShortEbpb + { + /// x86 jump + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] jump; + /// OEM Name, 8 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] oem_name; + /// Bytes per sector + public readonly ushort bps; + /// Sectors per cluster + public readonly byte spc; + /// Reserved sectors between BPB and FAT + public readonly ushort rsectors; + /// Number of FATs + public readonly byte fats_no; + /// Number of entries on root directory + public readonly ushort root_ent; + /// Sectors in volume + public ushort sectors; + /// Media descriptor + public readonly byte media; + /// Sectors per FAT + public readonly ushort spfat; + /// Sectors per track + public readonly ushort sptrk; + /// Heads + public readonly ushort heads; + /// Hidden sectors before BPB + public readonly uint hsectors; + /// Sectors in volume if > 65535 + public uint big_sectors; + /// Drive number + public readonly byte drive_no; + /// Volume flags + public readonly byte flags; + /// EPB signature, 0x28 + public readonly byte signature; + /// Volume serial number + public readonly uint serial_no; + /// Boot code. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 467)] + public readonly byte[] boot_code; + /// Always 0x55 0xAA. + public readonly ushort boot_signature; + } + + /// DOS 4.0 or higher BIOS Parameter Block. + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct BiosParameterBlockEbpb + { + /// x86 jump + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public byte[] jump; + /// OEM Name, 8 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public byte[] oem_name; + /// Bytes per sector + public ushort bps; + /// Sectors per cluster + public byte spc; + /// Reserved sectors between BPB and FAT + public ushort rsectors; + /// Number of FATs + public byte fats_no; + /// Number of entries on root directory + public ushort root_ent; + /// Sectors in volume + public ushort sectors; + /// Media descriptor + public byte media; + /// Sectors per FAT + public ushort spfat; + /// Sectors per track + public ushort sptrk; + /// Heads + public ushort heads; + /// Hidden sectors before BPB + public uint hsectors; + /// Sectors in volume if > 65535 + public uint big_sectors; + /// Drive number + public byte drive_no; + /// Volume flags + public byte flags; + /// EPB signature, 0x29 + public byte signature; + /// Volume serial number + public uint serial_no; + /// Volume label, 11 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] + public readonly byte[] volume_label; + /// Filesystem type, 8 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] fs_type; + /// Boot code. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 448)] + public byte[] boot_code; + /// Always 0x55 0xAA. + public ushort boot_signature; + } + + /// FAT32 Parameter Block + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct Fat32ParameterBlockShort + { + /// x86 jump + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] jump; + /// OEM Name, 8 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] oem_name; + /// Bytes per sector + public readonly ushort bps; + /// Sectors per cluster + public readonly byte spc; + /// Reserved sectors between BPB and FAT + public readonly ushort rsectors; + /// Number of FATs + public readonly byte fats_no; + /// Number of entries on root directory, set to 0 + public readonly ushort root_ent; + /// Sectors in volume, set to 0 + public ushort sectors; + /// Media descriptor + public readonly byte media; + /// Sectors per FAT, set to 0 + public readonly ushort spfat; + /// Sectors per track + public readonly ushort sptrk; + /// Heads + public readonly ushort heads; + /// Hidden sectors before BPB + public readonly uint hsectors; + /// Sectors in volume + public uint big_sectors; + /// Sectors per FAT + public readonly uint big_spfat; + /// FAT flags + public readonly ushort mirror_flags; + /// FAT32 version + public readonly ushort version; + /// Cluster of root directory + public readonly uint root_cluster; + /// Sector of FSINFO structure + public readonly ushort fsinfo_sector; + /// Sector of FAT32PB backup + public readonly ushort backup_sector; + /// Reserved + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public readonly byte[] reserved; + /// Drive number + public readonly byte drive_no; + /// Volume flags + public readonly byte flags; + /// Signature, should be 0x28 + public readonly byte signature; + /// Volume serial number + public readonly uint serial_no; + /// Volume label, 11 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] + public readonly byte[] reserved2; + /// Sectors in volume if equals 0 + public ulong huge_sectors; + /// Boot code. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 420)] + public readonly byte[] boot_code; + /// Always 0x55 0xAA. + public readonly ushort boot_signature; + } + + /// FAT32 Parameter Block + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct Fat32ParameterBlock + { + /// x86 jump + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] jump; + /// OEM Name, 8 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] oem_name; + /// Bytes per sector + public ushort bps; + /// Sectors per cluster + public byte spc; + /// Reserved sectors between BPB and FAT + public readonly ushort rsectors; + /// Number of FATs + public readonly byte fats_no; + /// Number of entries on root directory, set to 0 + public readonly ushort root_ent; + /// Sectors in volume, set to 0 + public ushort sectors; + /// Media descriptor + public readonly byte media; + /// Sectors per FAT, set to 0 + public readonly ushort spfat; + /// Sectors per track + public ushort sptrk; + /// Heads + public readonly ushort heads; + /// Hidden sectors before BPB + public uint hsectors; + /// Sectors in volume + public uint big_sectors; + /// Sectors per FAT + public uint big_spfat; + /// FAT flags + public readonly ushort mirror_flags; + /// FAT32 version + public readonly ushort version; + /// Cluster of root directory + public readonly uint root_cluster; + /// Sector of FSINFO structure + public readonly ushort fsinfo_sector; + /// Sector of FAT32PB backup + public readonly ushort backup_sector; + /// Reserved + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public readonly byte[] reserved; + /// Drive number + public readonly byte drive_no; + /// Volume flags + public readonly byte flags; + /// Signature, should be 0x29 + public readonly byte signature; + /// Volume serial number + public readonly uint serial_no; + /// Volume label, 11 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] + public readonly byte[] volume_label; + /// Filesystem type, 8 bytes, space-padded, must be "FAT32 " + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] fs_type; + /// Boot code. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 419)] + public readonly byte[] boot_code; + /// Always 0x55 0xAA. + public readonly ushort boot_signature; + } + + /// Apricot Label. + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct ApricotLabel + { + /// Version of format which created disk + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] version; + /// Operating system. + public readonly byte operatingSystem; + /// Software write protection. + [MarshalAs(UnmanagedType.U1)] + public readonly bool writeProtected; + /// Copy protected. + [MarshalAs(UnmanagedType.U1)] + public readonly bool copyProtected; + /// Boot type. + public readonly byte bootType; + /// Partitions. + public readonly byte partitionCount; + /// Is hard disk?. + [MarshalAs(UnmanagedType.U1)] + public readonly bool winchester; + /// Sector size. + public readonly ushort sectorSize; + /// Sectors per track. + public readonly ushort spt; + /// Tracks per side. + public readonly uint cylinders; + /// Sides. + public readonly byte heads; + /// Interleave factor. + public readonly byte interleave; + /// Skew factor. + public readonly ushort skew; + /// Sector where boot code starts. + public readonly uint bootLocation; + /// Size in sectors of boot code. + public readonly ushort bootSize; + /// Address at which to load boot code. + public readonly uint bootAddress; + /// Offset where to jump to boot. + public readonly ushort bootOffset; + /// Segment where to jump to boot. + public readonly ushort bootSegment; + /// First data sector. + public readonly uint firstDataBlock; + /// Generation. + public readonly ushort generation; + /// Copy count. + public readonly ushort copyCount; + /// Maximum number of copies. + public readonly ushort maxCopies; + /// Serial number. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] serialNumber; + /// Part number. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] partNumber; + /// Copyright. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] + public readonly byte[] copyright; + /// BPB for whole disk. + public ApricotParameterBlock mainBPB; + /// Name of FONT file. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] fontName; + /// Name of KEYBOARD file. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] keyboardName; + /// Minor BIOS version. + public readonly byte biosMinorVersion; + /// Major BIOS version. + public readonly byte biosMajorVersion; + /// Diagnostics enabled?. + [MarshalAs(UnmanagedType.U1)] + public readonly bool diagnosticsFlag; + /// Printer device. + public readonly byte prnDevice; + /// Bell volume. + public readonly byte bellVolume; + /// Cache enabled?. + [MarshalAs(UnmanagedType.U1)] + public readonly bool enableCache; + /// Graphics enabled?. + [MarshalAs(UnmanagedType.U1)] + public readonly bool enableGraphics; + /// Length in sectors of DOS. + public readonly byte dosLength; + /// Length in sectors of FONT file. + public readonly byte fontLength; + /// Length in sectors of KEYBOARD file. + public readonly byte keyboardLength; + /// Starting sector of DOS. + public readonly ushort dosStart; + /// Starting sector of FONT file. + public readonly ushort fontStart; + /// Starting sector of KEYBOARD file. + public readonly ushort keyboardStart; + /// Keyboard click volume. + public readonly byte keyboardVolume; + /// Auto-repeat enabled?. + [MarshalAs(UnmanagedType.U1)] + public readonly bool autorepeat; + /// Auto-repeat lead-in. + public readonly byte autorepeatLeadIn; + /// Auto-repeat interval. + public readonly byte autorepeatInterval; + /// Microscreen mode. + public readonly byte microscreenMode; + /// Spare area for keyboard values expansion. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] + public readonly byte[] spareKeyboard; + /// Screen line mode. + public readonly byte lineMode; + /// Screen line width. + public readonly byte lineWidth; + /// Screen disabled?. + [MarshalAs(UnmanagedType.U1)] + public readonly bool imageOff; + /// Spare area for screen values expansion. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)] + public readonly byte[] spareScreen; + /// TX baud rate. + public readonly byte txBaudRate; + /// RX baud rate. + public readonly byte rxBaudRate; + /// TX bits. + public readonly byte txBits; + /// RX bits. + public readonly byte rxBits; + /// Stop bits. + public readonly byte stopBits; + /// Parity enabled?. + [MarshalAs(UnmanagedType.U1)] + public readonly bool parityCheck; + /// Parity type. + public readonly byte parityType; + /// Xon/Xoff enabled on TX. + [MarshalAs(UnmanagedType.U1)] + public readonly bool txXonXoff; + /// Xon/Xoff enabled on RX. + [MarshalAs(UnmanagedType.U1)] + public readonly bool rxXonXoff; + /// Xon character. + public readonly byte xonCharacter; + /// Xoff character. + public readonly byte xoffCharacter; + /// Xon/Xoff buffer on RX. + public readonly ushort rxXonXoffBuffer; + /// DTR/DSR enabled?. + [MarshalAs(UnmanagedType.U1)] + public readonly bool dtrDsr; + /// CTS/RTS enabled?. + [MarshalAs(UnmanagedType.U1)] + public readonly bool ctsRts; + /// NULLs after CR. + public readonly byte nullsAfterCr; + /// NULLs after 0xFF. + public readonly byte nullsAfterFF; + /// Send LF after CR in serial port. + [MarshalAs(UnmanagedType.U1)] + public readonly bool lfAfterCRSerial; + /// BIOS error report in serial port. + [MarshalAs(UnmanagedType.U1)] + public readonly bool biosErrorReportSerial; + /// Spare area for serial port values expansion. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 13)] + public readonly byte[] spareSerial; + /// Send LF after CR in parallel port. + [MarshalAs(UnmanagedType.U1)] + public readonly bool lfAfterCrParallel; + /// Select line supported?. + [MarshalAs(UnmanagedType.U1)] + public readonly bool selectLine; + /// Paper empty supported?. + [MarshalAs(UnmanagedType.U1)] + public readonly bool paperEmpty; + /// Fault line supported?. + [MarshalAs(UnmanagedType.U1)] + public readonly bool faultLine; + /// BIOS error report in parallel port. + [MarshalAs(UnmanagedType.U1)] + public readonly bool biosErrorReportParallel; + /// Spare area for parallel port values expansion. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] + public readonly byte[] spareParallel; + /// Spare area for Winchester values expansion. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] + public readonly byte[] spareWinchester; + /// Parking enabled?. + [MarshalAs(UnmanagedType.U1)] + public readonly bool parkingEnabled; + /// Format protection?. + [MarshalAs(UnmanagedType.U1)] + public readonly bool formatProtection; + /// Spare area for RAM disk values expansion. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] spareRamDisk; + /// List of bad blocks. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] + public readonly ushort[] badBlocks; + /// Array of partition BPBs. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly ApricotParameterBlock[] partitions; + /// Spare area. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 63)] + public readonly byte[] spare; + /// CP/M double side indicator?. + public readonly bool cpmDoubleSided; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct ApricotParameterBlock + { + /// Bytes per sector + public readonly ushort bps; + /// Sectors per cluster + public readonly byte spc; + /// Reserved sectors between BPB and FAT + public readonly ushort rsectors; + /// Number of FATs + public readonly byte fats_no; + /// Number of entries on root directory + public readonly ushort root_ent; + /// Sectors in volume + public ushort sectors; + /// Media descriptor + public readonly byte media; + /// Sectors per FAT + public readonly ushort spfat; + /// Disk type + public readonly byte diskType; + /// Volume starting sector + public readonly ushort startSector; + } + + /// FAT32 FS Information Sector + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct FsInfoSector + { + /// Signature must be + public readonly uint signature1; + /// Reserved + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 480)] + public readonly byte[] reserved1; + /// Signature must be + public readonly uint signature2; + /// Free clusters + public readonly uint free_clusters; + /// cated cluster + public readonly uint last_cluster; + /// Reserved + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public readonly byte[] reserved2; + /// Signature must be + public readonly uint signature3; + } + + /// Human68k Parameter Block, big endian, 512 bytes even on 256 bytes/sector. + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct HumanParameterBlock + { + /// 68k bra.S + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] + public readonly byte[] jump; + /// OEM Name, 16 bytes, space-padded + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] + public readonly byte[] oem_name; + /// Bytes per cluster + public readonly ushort bpc; + /// Unknown, seen 1, 2 and 16 + public readonly byte unknown1; + /// Unknown, always 512? + public readonly ushort unknown2; + /// Unknown, always 1? + public readonly byte unknown3; + /// Number of entries on root directory + public readonly ushort root_ent; + /// Clusters, set to 0 if more than 65536 + public readonly ushort clusters; + /// Media descriptor + public readonly byte media; + /// Clusters per FAT, set to 0 + public readonly byte cpfat; + /// Clustersin volume + public readonly uint big_clusters; + /// Boot code. + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 478)] + public readonly byte[] boot_code; + } + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + struct DirectoryEntry + { + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)] + public readonly byte[] filename; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)] + public readonly byte[] extension; + public readonly FatAttributes attributes; + public readonly byte caseinfo; + public readonly byte ctime_ms; + public readonly ushort ctime; + public readonly ushort cdate; + public readonly ushort adate; + public readonly ushort ea_handle; + public readonly ushort mtime; + public readonly ushort mdate; + public readonly ushort start_cluster; + public readonly uint size; + } + } +} \ No newline at end of file diff --git a/DiscImageChef.Filesystems/FAT/Super.cs b/DiscImageChef.Filesystems/FAT/Super.cs new file mode 100644 index 000000000..a0a2309a1 --- /dev/null +++ b/DiscImageChef.Filesystems/FAT/Super.cs @@ -0,0 +1,62 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Super.cs +// Author(s) : Natalia Portillo +// +// Component : Microsoft FAT filesystem plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Handles mounting and umounting the Microsoft FAT filesystem. +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2019 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Text; +using DiscImageChef.CommonTypes; +using DiscImageChef.CommonTypes.Interfaces; +using DiscImageChef.CommonTypes.Structs; + +namespace DiscImageChef.Filesystems.FAT +{ + public partial class FAT + { + /// + /// Mounts an Apple Lisa filesystem + /// + public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding, + Dictionary options, string @namespace) => + throw new NotImplementedException(); + + /// + /// Umounts this Lisa filesystem + /// + public Errno Unmount() => throw new NotImplementedException(); + + /// + /// Gets information about the mounted volume. + /// + /// Information about the mounted volume. + public Errno StatFs(out FileSystemInfo stat) => throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/DiscImageChef.Filesystems/FAT/Xattr.cs b/DiscImageChef.Filesystems/FAT/Xattr.cs new file mode 100644 index 000000000..3dc2bfe1b --- /dev/null +++ b/DiscImageChef.Filesystems/FAT/Xattr.cs @@ -0,0 +1,75 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : Xattr.cs +// Author(s) : Natalia Portillo +// +// Component : Microsoft FAT filesystem plugin. +// +// --[ Description ] ---------------------------------------------------------- +// +// Methods to handle Microsoft FAT extended attributes. +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2019 Natalia Portillo +// ****************************************************************************/ + +using System; +using System.Collections.Generic; +using DiscImageChef.CommonTypes.Structs; + +namespace DiscImageChef.Filesystems.FAT +{ + public partial class FAT + { + /// + /// Lists all extended attributes, alternate data streams and forks of the given file. + /// + /// Error number. + /// Path. + /// List of extended attributes, alternate data streams and forks. + public Errno ListXAttr(string path, out List xattrs) => throw new NotImplementedException(); + + /// + /// Reads an extended attribute, alternate data stream or fork from the given file. + /// + /// Error number. + /// File path. + /// Extendad attribute, alternate data stream or fork name. + /// Buffer. + public Errno GetXattr(string path, string xattr, ref byte[] buf) => throw new NotImplementedException(); + + /// + /// Lists special Apple Lisa filesystem features as extended attributes + /// + /// Error number. + /// File identifier. + /// Extended attributes. + Errno ListXAttr(short fileId, out List xattrs) => throw new NotImplementedException(); + + /// + /// Lists special Apple Lisa filesystem features as extended attributes + /// + /// Error number. + /// File identifier. + /// Extended attribute name. + /// Buffer where the extended attribute will be stored. + Errno GetXattr(short fileId, string xattr, out byte[] buf) => throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/DiscImageChef.Tests/Filesystems/FAT12.cs b/DiscImageChef.Tests/Filesystems/FAT12.cs index 2faabea80..a6549146d 100644 --- a/DiscImageChef.Tests/Filesystems/FAT12.cs +++ b/DiscImageChef.Tests/Filesystems/FAT12.cs @@ -31,7 +31,7 @@ using System.IO; using DiscImageChef.CommonTypes; using DiscImageChef.CommonTypes.Interfaces; using DiscImageChef.DiscImages; -using DiscImageChef.Filesystems; +using DiscImageChef.Filesystems.FAT; using DiscImageChef.Filters; using NUnit.Framework; diff --git a/DiscImageChef.Tests/Filesystems/FAT16.cs b/DiscImageChef.Tests/Filesystems/FAT16.cs index 3172d512f..ddfb11942 100644 --- a/DiscImageChef.Tests/Filesystems/FAT16.cs +++ b/DiscImageChef.Tests/Filesystems/FAT16.cs @@ -31,7 +31,7 @@ using System.IO; using DiscImageChef.CommonTypes; using DiscImageChef.CommonTypes.Interfaces; using DiscImageChef.DiscImages; -using DiscImageChef.Filesystems; +using DiscImageChef.Filesystems.FAT; using DiscImageChef.Filters; using NUnit.Framework; diff --git a/DiscImageChef.Tests/Filesystems/FAT32.cs b/DiscImageChef.Tests/Filesystems/FAT32.cs index f9cf454ba..9da076886 100644 --- a/DiscImageChef.Tests/Filesystems/FAT32.cs +++ b/DiscImageChef.Tests/Filesystems/FAT32.cs @@ -31,7 +31,7 @@ using System.IO; using DiscImageChef.CommonTypes; using DiscImageChef.CommonTypes.Interfaces; using DiscImageChef.DiscImages; -using DiscImageChef.Filesystems; +using DiscImageChef.Filesystems.FAT; using DiscImageChef.Filters; using NUnit.Framework;