2017-07-05 06:54:50 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// The Disc Image Chef
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
2017-07-05 06:55:25 +01:00
|
|
|
|
// Filename : UDF.cs
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2017-07-05 06:54:50 +01:00
|
|
|
|
//
|
2017-12-19 03:50:57 +00:00
|
|
|
|
// Component : DiscImageChef unit testing.
|
2017-07-05 06:54:50 +01:00
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU General Public License as
|
|
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program 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 General Public License for more details.
|
|
|
|
|
|
//
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2018-12-29 17:34:38 +00:00
|
|
|
|
// Copyright © 2011-2019 Natalia Portillo
|
2017-07-05 06:54:50 +01:00
|
|
|
|
// ****************************************************************************/
|
2017-12-19 03:50:57 +00:00
|
|
|
|
|
2017-07-05 06:54:50 +01:00
|
|
|
|
using System.IO;
|
2020-02-27 00:33:26 +00:00
|
|
|
|
using Aaru.CommonTypes;
|
|
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
|
|
|
|
|
using Aaru.DiscImages;
|
|
|
|
|
|
using Aaru.Filesystems;
|
|
|
|
|
|
using Aaru.Filters;
|
2017-07-05 06:54:50 +01:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
2020-02-27 00:33:26 +00:00
|
|
|
|
namespace Aaru.Tests.Filesystems
|
2017-07-05 06:54:50 +01:00
|
|
|
|
{
|
|
|
|
|
|
[TestFixture]
|
2017-12-22 22:18:21 +00:00
|
|
|
|
public class Udf
|
2017-07-05 06:54:50 +01:00
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
|
readonly string[] testfiles =
|
|
|
|
|
|
{
|
2020-07-09 01:32:15 +01:00
|
|
|
|
"1.02/linux.aif", "1.02/macosx_10.11.aif", "1.50/linux.aif", "1.50/macosx_10.11.aif", "2.00/linux.aif",
|
|
|
|
|
|
"2.00/macosx_10.11.aif", "2.01/linux.aif", "2.01/macosx_10.11.aif", "2.50/linux.aif",
|
|
|
|
|
|
"2.50/macosx_10.11.aif", "2.60/macosx_10.11.aif", "1.50/solaris_7.aif", "1.50/solaris_9.aif",
|
|
|
|
|
|
"2.01/netbsd_7.1.aif", "1.02/linux_4.19_udf_1.02_flashdrive.aif", "1.50/linux_4.19_udf_1.50_flashdrive.aif",
|
|
|
|
|
|
"2.00/linux_4.19_udf_2.00_flashdrive.aif", "2.01/linux_4.19_udf_2.01_flashdrive.aif"
|
2017-07-05 06:54:50 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
readonly ulong[] sectors =
|
|
|
|
|
|
{
|
|
|
|
|
|
1024000, 204800, 1024000, 409600, 1024000, 614400, 1024000, 819200, 1024000, 1024000, 1228800, 8388608,
|
2019-05-11 19:52:34 +01:00
|
|
|
|
8388608, 8388608, 1024000, 1024000, 1024000, 1024000
|
2017-07-05 06:54:50 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
2019-05-11 19:52:34 +01:00
|
|
|
|
readonly uint[] sectorsize =
|
|
|
|
|
|
{
|
|
|
|
|
|
512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512
|
|
|
|
|
|
};
|
2017-07-05 06:54:50 +01:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
readonly long[] clusters =
|
|
|
|
|
|
{
|
|
|
|
|
|
1024000, 204800, 1024000, 409600, 1024000, 614400, 1024000, 819200, 1024000, 1024000, 1228800, 8388608,
|
2019-05-11 19:52:34 +01:00
|
|
|
|
8388608, 8388608, 1024000, 1024000, 1024000, 1024000
|
2017-07-05 06:54:50 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
2019-05-11 19:52:34 +01:00
|
|
|
|
readonly int[] clustersize =
|
|
|
|
|
|
{
|
|
|
|
|
|
512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512
|
|
|
|
|
|
};
|
2017-07-05 06:55:25 +01:00
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
readonly string[] udfversion =
|
|
|
|
|
|
{
|
|
|
|
|
|
"UDF v1.02", "UDF v1.02", "UDF v1.50", "UDF v1.50", "UDF v2.00", "UDF v2.00", "UDF v2.01", "UDF v2.01",
|
2019-05-11 19:52:34 +01:00
|
|
|
|
"UDF v2.50", "UDF v2.50", "UDF v2.60", "UDF v1.50", "UDF v1.50", "UDF v2.01", "UDF v2.01", "UDF v2.01",
|
|
|
|
|
|
"UDF v2.01", "UDF v2.01"
|
2017-07-05 06:54:50 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
readonly string[] volumename =
|
|
|
|
|
|
{
|
|
|
|
|
|
"Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "Volume label",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
"Volume label", "Volume label", "Volume label", "Volume label", "Volume label", "*NoLabel*", "*NoLabel*",
|
|
|
|
|
|
"anonymous", "DicSetter", "DicSetter", "DicSetter", "DicSetter", "DicSetter", "DicSetter"
|
2017-07-05 06:54:50 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
readonly string[] volumeserial =
|
|
|
|
|
|
{
|
|
|
|
|
|
"595c5cfa38ce8b66LinuxUDF", "6D02A231 (Mac OS X newfs_udf) UDF Volume Set", "595c5d00c5b3405aLinuxUDF",
|
|
|
|
|
|
"4DD0458B (Mac OS X newfs_udf) UDF Volume Set", "595c5d07f4fc8e8dLinuxUDF",
|
|
|
|
|
|
"5D91CB4F (Mac OS X newfs_udf) UDF Volume Set", "595c5d0bee60c3bbLinuxUDF",
|
|
|
|
|
|
"48847EB3 (Mac OS X newfs_udf) UDF Volume Set", "595c5d0e4f338552LinuxUDF",
|
2020-02-29 18:03:35 +00:00
|
|
|
|
"709E84A1 (Mac OS X newfs_udf) UDF Volume Set", "78CE3237 (Mac OS X newfs_udf) UDF Volume Set", "595EB2A9",
|
|
|
|
|
|
"595EB55A", "7cc94d726669d773", "5cc7882441a86e93LinuxUDF", "5cc78f8bba4dfe00LinuxUDF",
|
2019-05-11 19:52:34 +01:00
|
|
|
|
"5cc7f4183e0d5f7aLinuxUDF", "5cc8816fcb3a3b38LinuxUDF", "595EB55A", "7cc94d726669d773"
|
2017-07-05 06:54:50 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
2017-12-19 20:33:03 +00:00
|
|
|
|
readonly string[] oemid =
|
|
|
|
|
|
{
|
|
|
|
|
|
"*Linux UDFFS", "*Apple Mac OS X UDF FS", "*Linux UDFFS", "*Apple Mac OS X UDF FS", "*Linux UDFFS",
|
|
|
|
|
|
"*Apple Mac OS X UDF FS", "*Linux UDFFS", "*Apple Mac OS X UDF FS", "*Linux UDFFS",
|
|
|
|
|
|
"*Apple Mac OS X UDF FS", "*Apple Mac OS X UDF FS", "*SUN SOLARIS UDF", "*SUN SOLARIS UDF",
|
2019-05-11 19:52:34 +01:00
|
|
|
|
"*NetBSD userland UDF", "*Linux UDFFS", "*Linux UDFFS", "*Linux UDFFS", "*Linux UDFFS", "*Linux UDFFS",
|
|
|
|
|
|
"*Linux UDFFS"
|
2017-07-05 06:54:50 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Test()
|
|
|
|
|
|
{
|
|
|
|
|
|
for(int i = 0; i < testfiles.Length; i++)
|
|
|
|
|
|
{
|
2020-07-08 20:02:59 +01:00
|
|
|
|
string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format",
|
|
|
|
|
|
testfiles[i]);
|
|
|
|
|
|
|
2020-07-09 01:32:15 +01:00
|
|
|
|
IFilter filter = new ZZZNoFilter();
|
2017-07-05 06:54:50 +01:00
|
|
|
|
filter.Open(location);
|
2020-07-09 01:32:15 +01:00
|
|
|
|
IMediaImage image = new AaruFormat();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Assert.AreEqual(true, image.Open(filter), testfiles[i]);
|
|
|
|
|
|
Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
|
2017-12-26 06:05:12 +00:00
|
|
|
|
Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
|
2018-06-22 08:08:38 +01:00
|
|
|
|
IFilesystem fs = new UDF();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
var wholePart = new Partition
|
2017-07-19 16:31:08 +01:00
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Name = "Whole device", Length = image.Info.Sectors,
|
|
|
|
|
|
Size = image.Info.Sectors * image.Info.SectorSize
|
2017-07-19 16:31:08 +01:00
|
|
|
|
};
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2017-07-19 16:31:08 +01:00
|
|
|
|
Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]);
|
2017-12-26 06:05:12 +00:00
|
|
|
|
fs.GetInformation(image, wholePart, out _, null);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]);
|
|
|
|
|
|
Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]);
|
|
|
|
|
|
Assert.AreEqual(udfversion[i], fs.XmlFsType.Type, testfiles[i]);
|
|
|
|
|
|
Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]);
|
2017-12-26 06:05:12 +00:00
|
|
|
|
Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSetIdentifier, testfiles[i]);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]);
|
2018-01-16 18:08:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
|
public class UdfOptical
|
|
|
|
|
|
{
|
|
|
|
|
|
readonly string[] testfiles =
|
2018-12-31 13:17:27 +00:00
|
|
|
|
{
|
2020-07-09 01:32:15 +01:00
|
|
|
|
"1.50/ecs20.aif", "2.00/ecs20.aif", "2.01/ecs20.aif", "2.01/ecs20_cdrw.aif"
|
2018-12-31 13:17:27 +00:00
|
|
|
|
};
|
2018-01-16 18:08:20 +00:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
readonly ulong[] sectors =
|
|
|
|
|
|
{
|
|
|
|
|
|
2295104, 2295104, 2295104, 295264
|
|
|
|
|
|
};
|
2018-01-16 18:08:20 +00:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
readonly uint[] sectorsize =
|
|
|
|
|
|
{
|
|
|
|
|
|
2048, 2048, 2048, 2048
|
|
|
|
|
|
};
|
2018-01-16 18:08:20 +00:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
readonly long[] clusters =
|
|
|
|
|
|
{
|
|
|
|
|
|
2295104, 2295104, 2295104, 295264
|
|
|
|
|
|
};
|
2018-01-16 18:08:20 +00:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
readonly int[] clustersize =
|
|
|
|
|
|
{
|
|
|
|
|
|
2048, 2048, 2048, 2048
|
|
|
|
|
|
};
|
2018-01-16 18:08:20 +00:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
readonly string[] udfversion =
|
|
|
|
|
|
{
|
|
|
|
|
|
"UDF v2.01", "UDF v2.01", "UDF v2.01", "UDF v2.01"
|
|
|
|
|
|
};
|
2018-01-16 18:08:20 +00:00
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
readonly string[] volumename =
|
|
|
|
|
|
{
|
|
|
|
|
|
"Volume label", "UDF5A5DEF48", "VolLabel", "UDF5A5DFF10"
|
|
|
|
|
|
};
|
2018-01-16 18:08:20 +00:00
|
|
|
|
|
|
|
|
|
|
readonly string[] volumeserial =
|
|
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
"Volume Set ID not specified", "Volume Set ID not specified", "VolumeSetId", "Volume Set ID not specified"
|
2018-01-16 18:08:20 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
2020-02-29 18:03:35 +00:00
|
|
|
|
readonly string[] oemid =
|
|
|
|
|
|
{
|
|
|
|
|
|
"*ExpressUDF", "*ExpressUDF", "*ExpressUDF", "*ExpressUDF"
|
|
|
|
|
|
};
|
2018-01-16 18:08:20 +00:00
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public void Test()
|
|
|
|
|
|
{
|
|
|
|
|
|
for(int i = 0; i < testfiles.Length; i++)
|
|
|
|
|
|
{
|
2020-07-08 20:02:59 +01:00
|
|
|
|
string location = Path.Combine(Consts.TestFilesRoot, "Filesystems", "Universal Disc Format",
|
|
|
|
|
|
testfiles[i]);
|
|
|
|
|
|
|
2020-07-09 01:32:15 +01:00
|
|
|
|
IFilter filter = new ZZZNoFilter();
|
2018-01-16 18:08:20 +00:00
|
|
|
|
filter.Open(location);
|
2020-07-09 01:32:15 +01:00
|
|
|
|
IMediaImage image = new AaruFormat();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Assert.AreEqual(true, image.Open(filter), testfiles[i]);
|
|
|
|
|
|
Assert.AreEqual(sectors[i], image.Info.Sectors, testfiles[i]);
|
2018-01-16 18:08:20 +00:00
|
|
|
|
Assert.AreEqual(sectorsize[i], image.Info.SectorSize, testfiles[i]);
|
2018-06-22 08:08:38 +01:00
|
|
|
|
IFilesystem fs = new UDF();
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
|
|
|
|
|
var wholePart = new Partition
|
2018-01-16 18:08:20 +00:00
|
|
|
|
{
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Name = "Whole device", Length = image.Info.Sectors,
|
|
|
|
|
|
Size = image.Info.Sectors * image.Info.SectorSize
|
2018-01-16 18:08:20 +00:00
|
|
|
|
};
|
2020-02-29 18:03:35 +00:00
|
|
|
|
|
2018-01-16 18:08:20 +00:00
|
|
|
|
Assert.AreEqual(true, fs.Identify(image, wholePart), testfiles[i]);
|
|
|
|
|
|
fs.GetInformation(image, wholePart, out _, null);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Assert.AreEqual(clusters[i], fs.XmlFsType.Clusters, testfiles[i]);
|
|
|
|
|
|
Assert.AreEqual(clustersize[i], fs.XmlFsType.ClusterSize, testfiles[i]);
|
|
|
|
|
|
Assert.AreEqual(udfversion[i], fs.XmlFsType.Type, testfiles[i]);
|
|
|
|
|
|
Assert.AreEqual(volumename[i], fs.XmlFsType.VolumeName, testfiles[i]);
|
2018-01-16 18:08:20 +00:00
|
|
|
|
Assert.AreEqual(volumeserial[i], fs.XmlFsType.VolumeSetIdentifier, testfiles[i]);
|
2020-02-29 18:03:35 +00:00
|
|
|
|
Assert.AreEqual(oemid[i], fs.XmlFsType.SystemIdentifier, testfiles[i]);
|
2017-07-05 06:54:50 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
|
}
|