From 838b5f830777d37f3c4c974cbe6ec519eec15471 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Wed, 31 Jul 2019 17:44:51 +0100 Subject: [PATCH] Read CD-i filesystem. --- DiscImageChef.Filesystems/ISO9660/File.cs | 19 ++++++++++++++++--- DiscImageChef.Filesystems/ISO9660/Super.cs | 8 ++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/DiscImageChef.Filesystems/ISO9660/File.cs b/DiscImageChef.Filesystems/ISO9660/File.cs index 9b154ec9e..cef70e59d 100644 --- a/DiscImageChef.Filesystems/ISO9660/File.cs +++ b/DiscImageChef.Filesystems/ISO9660/File.cs @@ -69,9 +69,10 @@ namespace DiscImageChef.Filesystems.ISO9660 long sizeInSectors = (size + offsetInSector) / 2048; if((size + offsetInSector) % 2048 > 0) sizeInSectors++; - MemoryStream ms = new MemoryStream(); - - byte[] buffer = ReadSectors((ulong)(entry.Extent + firstSector), (uint)sizeInSectors); + // No need to check mode, if we know it is CD-DA + byte[] buffer = entry.CdiSystemArea?.attributes.HasFlag(CdiAttributes.DigitalAudio) == true + ? image.ReadSectors((ulong)(entry.Extent + firstSector), (uint)sizeInSectors) + : ReadSectors((ulong)(entry.Extent + firstSector), (uint)sizeInSectors); buf = new byte[size]; Array.Copy(buffer, offsetInSector, buf, 0, size); @@ -202,6 +203,18 @@ namespace DiscImageChef.Filesystems.ISO9660 if(entry.XattrLength == 0 || cdi || highSierra) return Errno.NoError; + if(entry.CdiSystemArea != null) + { + stat.UID = entry.CdiSystemArea.Value.owner; + stat.GID = entry.CdiSystemArea.Value.group; + if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.GroupExecute)) stat.Mode |= 8; + if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.GroupRead)) stat.Mode |= 32; + if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OtherExecute)) stat.Mode |= 1; + if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OtherRead)) stat.Mode |= 4; + if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OwnerExecute)) stat.Mode |= 64; + if(entry.CdiSystemArea.Value.attributes.HasFlag(CdiAttributes.OwnerRead)) stat.Mode |= 256; + } + // TODO: XA uint eaSizeInSectors = (uint)(entry.XattrLength / 2048); if(entry.XattrLength % 2048 > 0) eaSizeInSectors++; diff --git a/DiscImageChef.Filesystems/ISO9660/Super.cs b/DiscImageChef.Filesystems/ISO9660/Super.cs index c4c97d81e..4f7267bdc 100644 --- a/DiscImageChef.Filesystems/ISO9660/Super.cs +++ b/DiscImageChef.Filesystems/ISO9660/Super.cs @@ -202,7 +202,7 @@ namespace DiscImageChef.Filesystems.ISO9660 uint pathTableSizeInSectors = 0; uint pathTableMsbLocation; - uint pathTableLsbLocation; + uint pathTableLsbLocation = 0; // Initialize to 0 as ignored in CD-i image = imagePlugin; @@ -231,9 +231,6 @@ namespace DiscImageChef.Filesystems.ISO9660 // TODO: Until escape sequences are implemented this is the default CD-i encoding. Encoding = Encoding.GetEncoding("iso8859-1"); - - // TODO: Implement CD-i - return Errno.NotImplemented; } else { @@ -295,6 +292,9 @@ namespace DiscImageChef.Filesystems.ISO9660 useTransTbl = false; } + // In case the path table is incomplete + if(usePathTable && pathTableData.Length == 1) usePathTable = false; + if(rootLocation + rootSize >= imagePlugin.Info.Sectors) return Errno.InvalidArgument; byte[] rootDir = ReadSectors(rootLocation, rootSize);