Fixed adding debug root directory entries in ISO9660. Fixes #267

This commit is contained in:
2020-01-07 06:39:55 +00:00
parent 75857860f2
commit 7c5b4418b5

View File

@@ -46,40 +46,53 @@ namespace DiscImageChef.Filesystems.ISO9660
{
public partial class ISO9660
{
public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
Dictionary<string, string> options, string @namespace)
public Errno Mount(IMediaImage imagePlugin, Partition partition, Encoding encoding,
Dictionary<string, string> options, string @namespace)
{
Encoding = encoding ?? Encoding.GetEncoding(1252);
byte[] vdMagic = new byte[5]; // Volume Descriptor magic "CD001"
byte[] hsMagic = new byte[5]; // Volume Descriptor magic "CDROM"
if(options == null) options = GetDefaultOptions();
if(options.TryGetValue("debug", out string debugString)) bool.TryParse(debugString, out debug);
if(options == null)
options = GetDefaultOptions();
if(options.TryGetValue("debug", out string debugString))
bool.TryParse(debugString, out debug);
if(options.TryGetValue("use_path_table", out string usePathTableString))
bool.TryParse(usePathTableString, out usePathTable);
if(options.TryGetValue("use_trans_tbl", out string useTransTblString))
bool.TryParse(useTransTblString, out useTransTbl);
if(options.TryGetValue("use_evd", out string useEvdString)) bool.TryParse(useEvdString, out useEvd);
if(options.TryGetValue("use_evd", out string useEvdString))
bool.TryParse(useEvdString, out useEvd);
// Default namespace
if(@namespace is null) @namespace = "joliet";
if(@namespace is null)
@namespace = "joliet";
switch(@namespace.ToLowerInvariant())
{
case "normal":
case"normal":
this.@namespace = Namespace.Normal;
break;
case "vms":
case"vms":
this.@namespace = Namespace.Vms;
break;
case "joliet":
case"joliet":
this.@namespace = Namespace.Joliet;
break;
case "rrip":
case"rrip":
this.@namespace = Namespace.Rrip;
break;
case "romeo":
case"romeo":
this.@namespace = Namespace.Romeo;
break;
default: return Errno.InvalidArgument;
}
@@ -91,10 +104,12 @@ namespace DiscImageChef.Filesystems.ISO9660
FileStructureVolumeDescriptor? fsvd = null;
// ISO9660 is designed for 2048 bytes/sector devices
if(imagePlugin.Info.SectorSize < 2048) return Errno.InvalidArgument;
if(imagePlugin.Info.SectorSize < 2048)
return Errno.InvalidArgument;
// ISO9660 Primary Volume Descriptor starts at sector 16, so that's minimal size.
if(partition.End < 16) return Errno.InvalidArgument;
if(partition.End < 16)
return Errno.InvalidArgument;
ulong counter = 0;
@@ -102,8 +117,11 @@ namespace DiscImageChef.Filesystems.ISO9660
int xaOff = vdSector.Length == 2336 ? 8 : 0;
Array.Copy(vdSector, 0x009 + xaOff, hsMagic, 0, 5);
highSierra = Encoding.GetString(hsMagic) == HIGH_SIERRA_MAGIC;
int hsOff = 0;
if(highSierra) hsOff = 8;
int hsOff = 0;
if(highSierra)
hsOff = 8;
cdi = false;
List<ulong> bvdSectors = new List<ulong>();
List<ulong> pvdSectors = new List<ulong>();
@@ -114,6 +132,7 @@ namespace DiscImageChef.Filesystems.ISO9660
while(true)
{
DicConsole.DebugWriteLine("ISO9660 plugin", "Processing VD loop no. {0}", counter);
// Seek to Volume Descriptor
DicConsole.DebugWriteLine("ISO9660 plugin", "Reading sector {0}", 16 + counter + partition.Start);
byte[] vdSectorTmp = imagePlugin.ReadSector(16 + counter + partition.Start);
@@ -125,7 +144,8 @@ namespace DiscImageChef.Filesystems.ISO9660
if(vdType == 255) // Supposedly we are in the PVD.
{
if(counter == 0) return Errno.InvalidArgument;
if(counter == 0)
return Errno.InvalidArgument;
break;
}
@@ -133,11 +153,13 @@ namespace DiscImageChef.Filesystems.ISO9660
Array.Copy(vdSector, 0x001, vdMagic, 0, 5);
Array.Copy(vdSector, 0x009, hsMagic, 0, 5);
if(Encoding.GetString(vdMagic) != ISO_MAGIC && Encoding.GetString(hsMagic) != HIGH_SIERRA_MAGIC &&
if(Encoding.GetString(vdMagic) != ISO_MAGIC &&
Encoding.GetString(hsMagic) != HIGH_SIERRA_MAGIC &&
Encoding.GetString(vdMagic) != CDI_MAGIC
) // Recognized, it is an ISO9660, now check for rest of data.
{
if(counter == 0) return Errno.InvalidArgument;
if(counter == 0)
return Errno.InvalidArgument;
break;
}
@@ -148,7 +170,8 @@ namespace DiscImageChef.Filesystems.ISO9660
{
case 0:
{
if(debug) bvdSectors.Add(16 + counter + partition.Start);
if(debug)
bvdSectors.Add(16 + counter + partition.Start);
break;
}
@@ -156,13 +179,15 @@ namespace DiscImageChef.Filesystems.ISO9660
case 1:
{
if(highSierra)
hsvd = Marshal
.ByteArrayToStructureLittleEndian<HighSierraPrimaryVolumeDescriptor>(vdSector);
hsvd = Marshal.
ByteArrayToStructureLittleEndian<HighSierraPrimaryVolumeDescriptor>(vdSector);
else if(cdi)
fsvd = Marshal.ByteArrayToStructureBigEndian<FileStructureVolumeDescriptor>(vdSector);
else pvd = Marshal.ByteArrayToStructureLittleEndian<PrimaryVolumeDescriptor>(vdSector);
else
pvd = Marshal.ByteArrayToStructureLittleEndian<PrimaryVolumeDescriptor>(vdSector);
if(debug) pvdSectors.Add(16 + counter + partition.Start);
if(debug)
pvdSectors.Add(16 + counter + partition.Start);
break;
}
@@ -176,17 +201,23 @@ namespace DiscImageChef.Filesystems.ISO9660
// Check if this is Joliet
if(svd.version == 1)
{
if(svd.escape_sequences[0] == '%' && svd.escape_sequences[1] == '/')
if(svd.escape_sequences[2] == '@' || svd.escape_sequences[2] == 'C' ||
svd.escape_sequences[2] == 'E') jolietvd = svd;
if(svd.escape_sequences[0] == '%' &&
svd.escape_sequences[1] == '/')
if(svd.escape_sequences[2] == '@' ||
svd.escape_sequences[2] == 'C' ||
svd.escape_sequences[2] == 'E')
jolietvd = svd;
else
DicConsole.WriteLine("ISO9660 plugin",
"Found unknown supplementary volume descriptor");
if(debug) svdSectors.Add(16 + counter + partition.Start);
if(debug)
svdSectors.Add(16 + counter + partition.Start);
}
else
{
if(debug) evdSectors.Add(16 + counter + partition.Start);
if(debug)
evdSectors.Add(16 + counter + partition.Start);
if(useEvd)
{
@@ -202,7 +233,8 @@ namespace DiscImageChef.Filesystems.ISO9660
case 3:
{
if(debug) vpdSectors.Add(16 + counter + partition.Start);
if(debug)
vpdSectors.Add(16 + counter + partition.Start);
break;
}
@@ -212,23 +244,31 @@ namespace DiscImageChef.Filesystems.ISO9660
}
DecodedVolumeDescriptor decodedVd;
DecodedVolumeDescriptor decodedJolietVd = new DecodedVolumeDescriptor();
var decodedJolietVd = new DecodedVolumeDescriptor();
XmlFsType = new FileSystemType();
if(pvd == null && hsvd == null && fsvd == null)
if(pvd == null &&
hsvd == null &&
fsvd == null)
{
DicConsole.ErrorWriteLine("ERROR: Could not find primary volume descriptor");
return Errno.InvalidArgument;
}
if(highSierra) decodedVd = DecodeVolumeDescriptor(hsvd.Value);
else if(cdi) decodedVd = DecodeVolumeDescriptor(fsvd.Value);
else decodedVd = DecodeVolumeDescriptor(pvd.Value);
if(highSierra)
decodedVd = DecodeVolumeDescriptor(hsvd.Value);
else if(cdi)
decodedVd = DecodeVolumeDescriptor(fsvd.Value);
else
decodedVd = DecodeVolumeDescriptor(pvd.Value);
if(jolietvd != null) decodedJolietVd = DecodeJolietDescriptor(jolietvd.Value);
if(jolietvd != null)
decodedJolietVd = DecodeJolietDescriptor(jolietvd.Value);
if(this.@namespace != Namespace.Romeo) Encoding = Encoding.ASCII;
if(this.@namespace != Namespace.Romeo)
Encoding = Encoding.ASCII;
string fsFormat;
byte[] pathTableData;
@@ -242,7 +282,9 @@ namespace DiscImageChef.Filesystems.ISO9660
if(highSierra)
{
pathTableSizeInSectors = hsvd.Value.path_table_size / 2048;
if(hsvd.Value.path_table_size % 2048 > 0) pathTableSizeInSectors++;
if(hsvd.Value.path_table_size % 2048 > 0)
pathTableSizeInSectors++;
pathTableData = ReadSectors(Swapping.Swap(hsvd.Value.mandatory_path_table_msb), pathTableSizeInSectors);
@@ -254,7 +296,9 @@ namespace DiscImageChef.Filesystems.ISO9660
else if(cdi)
{
pathTableSizeInSectors = fsvd.Value.path_table_size / 2048;
if(fsvd.Value.path_table_size % 2048 > 0) pathTableSizeInSectors++;
if(fsvd.Value.path_table_size % 2048 > 0)
pathTableSizeInSectors++;
pathTableData = ReadSectors(fsvd.Value.path_table_addr, pathTableSizeInSectors);
@@ -268,7 +312,9 @@ namespace DiscImageChef.Filesystems.ISO9660
else
{
pathTableSizeInSectors = pvd.Value.path_table_size / 2048;
if(pvd.Value.path_table_size % 2048 > 0) pathTableSizeInSectors++;
if(pvd.Value.path_table_size % 2048 > 0)
pathTableSizeInSectors++;
pathTableData = ReadSectors(Swapping.Swap(pvd.Value.type_m_path_table), pathTableSizeInSectors);
@@ -281,10 +327,14 @@ namespace DiscImageChef.Filesystems.ISO9660
pathTable = highSierra ? DecodeHighSierraPathTable(pathTableData) : DecodePathTable(pathTableData);
// High Sierra and CD-i do not support Joliet or RRIP
if((highSierra || cdi) && this.@namespace != Namespace.Normal && this.@namespace != Namespace.Vms)
if((highSierra || cdi) &&
this.@namespace != Namespace.Normal &&
this.@namespace != Namespace.Vms)
this.@namespace = Namespace.Normal;
if(jolietvd is null && this.@namespace == Namespace.Joliet) this.@namespace = Namespace.Normal;
if(jolietvd is null &&
this.@namespace == Namespace.Joliet)
this.@namespace = Namespace.Normal;
uint rootLocation;
uint rootSize;
@@ -292,23 +342,25 @@ namespace DiscImageChef.Filesystems.ISO9660
if(!cdi)
{
rootLocation = highSierra
? hsvd.Value.root_directory_record.extent
rootLocation = highSierra ? hsvd.Value.root_directory_record.extent
: pvd.Value.root_directory_record.extent;
rootXattrLength = highSierra
? hsvd.Value.root_directory_record.xattr_len
rootXattrLength = highSierra ? hsvd.Value.root_directory_record.xattr_len
: pvd.Value.root_directory_record.xattr_len;
if(highSierra)
{
rootSize = hsvd.Value.root_directory_record.size / hsvd.Value.logical_block_size;
if(hsvd.Value.root_directory_record.size % hsvd.Value.logical_block_size > 0) rootSize++;
if(hsvd.Value.root_directory_record.size % hsvd.Value.logical_block_size > 0)
rootSize++;
}
else
{
rootSize = pvd.Value.root_directory_record.size / pvd.Value.logical_block_size;
if(pvd.Value.root_directory_record.size % pvd.Value.logical_block_size > 0) rootSize++;
if(pvd.Value.root_directory_record.size % pvd.Value.logical_block_size > 0)
rootSize++;
}
}
else
@@ -316,19 +368,25 @@ namespace DiscImageChef.Filesystems.ISO9660
rootLocation = pathTable[0].Extent;
byte[] firstRootSector = ReadSectors(rootLocation, 1);
CdiDirectoryRecord rootEntry =
Marshal.ByteArrayToStructureBigEndian<CdiDirectoryRecord>(firstRootSector);
rootSize = rootEntry.size / fsvd.Value.logical_block_size;
if(rootEntry.size % fsvd.Value.logical_block_size > 0) rootSize++;
if(rootEntry.size % fsvd.Value.logical_block_size > 0)
rootSize++;
usePathTable = usePathTable || pathTable.Length == 1;
useTransTbl = false;
}
// In case the path table is incomplete
if(usePathTable && pathTableData.Length == 1) usePathTable = false;
if(usePathTable && pathTableData.Length == 1)
usePathTable = false;
if(rootLocation + rootSize >= imagePlugin.Info.Sectors) return Errno.InvalidArgument;
if(rootLocation + rootSize >= imagePlugin.Info.Sectors)
return Errno.InvalidArgument;
byte[] rootDir = ReadSectors(rootLocation, rootSize);
@@ -337,14 +395,16 @@ namespace DiscImageChef.Filesystems.ISO9660
Saturn.IPBin? saturn = Saturn.DecodeIPBin(ipbinSector);
Dreamcast.IPBin? dreamcast = Dreamcast.DecodeIPBin(ipbinSector);
if(this.@namespace == Namespace.Joliet || this.@namespace == Namespace.Rrip)
if(this.@namespace == Namespace.Joliet ||
this.@namespace == Namespace.Rrip)
{
usePathTable = false;
useTransTbl = false;
}
// Cannot traverse path table if we substitute the names for the ones in TRANS.TBL
if(useTransTbl) usePathTable = false;
if(useTransTbl)
usePathTable = false;
if(this.@namespace != Namespace.Joliet)
rootDirectoryCache = cdi
@@ -355,148 +415,19 @@ namespace DiscImageChef.Filesystems.ISO9660
XmlFsType.Type = fsFormat;
if(debug)
{
rootDirectoryCache.Add("$",
new DecodedDirectoryEntry
{
Extents =
new List<(uint extent, uint size)>
{
(rootLocation, (uint)rootDir.Length)
},
Filename = "$",
Size = (uint)rootDir.Length,
Timestamp = decodedVd.CreationTime
});
if(!cdi)
rootDirectoryCache.Add("$PATH_TABLE.LSB",
new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
(pathTableLsbLocation, (uint)pathTableData.Length)
},
Filename = "$PATH_TABLE.LSB",
Size = (uint)pathTableData.Length,
Timestamp = decodedVd.CreationTime
});
rootDirectoryCache.Add("$PATH_TABLE.MSB",
new DecodedDirectoryEntry
{
Extents =
new List<(uint extent, uint size)>
{
(pathTableMsbLocation, (uint)pathTableData.Length)
},
Filename = "$PATH_TABLE.MSB",
Size = (uint)pathTableData.Length,
Timestamp = decodedVd.CreationTime
});
for(int i = 0; i < bvdSectors.Count; i++)
rootDirectoryCache.Add(i == 0 ? "$BOOT" : $"$BOOT_{i}",
new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)> {((uint)i, 2048)},
Filename = i == 0 ? "$BOOT" : $"$BOOT_{i}",
Size = 2048,
Timestamp = decodedVd.CreationTime
});
for(int i = 0; i < pvdSectors.Count; i++)
rootDirectoryCache.Add(i == 0 ? "$PVD" : $"$PVD{i}",
new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)> {((uint)i, 2048)},
Filename = i == 0 ? "$PVD" : $"PVD_{i}",
Size = 2048,
Timestamp = decodedVd.CreationTime
});
for(int i = 0; i < svdSectors.Count; i++)
rootDirectoryCache.Add(i == 0 ? "$SVD" : $"$SVD_{i}",
new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)> {((uint)i, 2048)},
Filename = i == 0 ? "$SVD" : $"$SVD_{i}",
Size = 2048,
Timestamp = decodedVd.CreationTime
});
for(int i = 0; i < evdSectors.Count; i++)
rootDirectoryCache.Add(i == 0 ? "$EVD" : $"$EVD_{i}",
new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)> {((uint)i, 2048)},
Filename = i == 0 ? "$EVD" : $"$EVD_{i}",
Size = 2048,
Timestamp = decodedVd.CreationTime
});
for(int i = 0; i < vpdSectors.Count; i++)
rootDirectoryCache.Add(i == 0 ? "$VPD" : $"$VPD_{i}",
new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)> {((uint)i, 2048)},
Filename = i == 0 ? "$VPD" : $"$VPD_{i}",
Size = 2048,
Timestamp = decodedVd.CreationTime
});
if(segaCd != null)
rootDirectoryCache.Add("$IP.BIN",
new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
((uint)partition.Start, (uint)Marshal.SizeOf<CD.IPBin>())
},
Filename = "$IP.BIN",
Size = (uint)Marshal.SizeOf<CD.IPBin>(),
Timestamp = decodedVd.CreationTime
});
if(saturn != null)
rootDirectoryCache.Add("$IP.BIN",
new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
((uint)partition.Start, (uint)Marshal.SizeOf<Saturn.IPBin>())
},
Filename = "$IP.BIN",
Size = (uint)Marshal.SizeOf<Saturn.IPBin>(),
Timestamp = decodedVd.CreationTime
});
if(dreamcast != null)
rootDirectoryCache.Add("$IP.BIN",
new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
((uint)partition.Start,
(uint)Marshal.SizeOf<Dreamcast.IPBin>())
},
Filename = "$IP.BIN",
Size = (uint)Marshal.SizeOf<Dreamcast.IPBin>(),
Timestamp = decodedVd.CreationTime
});
}
if(jolietvd != null && (this.@namespace == Namespace.Joliet || this.@namespace == Namespace.Rrip))
if(jolietvd != null &&
(this.@namespace == Namespace.Joliet || this.@namespace == Namespace.Rrip))
{
rootLocation = jolietvd.Value.root_directory_record.extent;
rootXattrLength = jolietvd.Value.root_directory_record.xattr_len;
rootSize = jolietvd.Value.root_directory_record.size / jolietvd.Value.logical_block_size;
if(pvd.Value.root_directory_record.size % jolietvd.Value.logical_block_size > 0)
rootSize++;
if(rootLocation + rootSize >= imagePlugin.Info.Sectors) return Errno.InvalidArgument;
if(rootLocation + rootSize >= imagePlugin.Info.Sectors)
return Errno.InvalidArgument;
joliet = true;
@@ -508,24 +439,21 @@ namespace DiscImageChef.Filesystems.ISO9660
decodedVd.SystemIdentifier.Length > decodedJolietVd.SystemIdentifier.Length)
XmlFsType.SystemIdentifier = decodedVd.SystemIdentifier;
else
XmlFsType.SystemIdentifier = string.IsNullOrEmpty(decodedJolietVd.SystemIdentifier)
? null
XmlFsType.SystemIdentifier = string.IsNullOrEmpty(decodedJolietVd.SystemIdentifier) ? null
: decodedJolietVd.SystemIdentifier;
if(string.IsNullOrEmpty(decodedJolietVd.VolumeSetIdentifier) || decodedVd.VolumeSetIdentifier.Length >
decodedJolietVd.VolumeSetIdentifier.Length)
if(string.IsNullOrEmpty(decodedJolietVd.VolumeSetIdentifier) ||
decodedVd.VolumeSetIdentifier.Length > decodedJolietVd.VolumeSetIdentifier.Length)
XmlFsType.VolumeSetIdentifier = decodedVd.VolumeSetIdentifier;
else
XmlFsType.VolumeSetIdentifier = string.IsNullOrEmpty(decodedJolietVd.VolumeSetIdentifier)
? null
XmlFsType.VolumeSetIdentifier = string.IsNullOrEmpty(decodedJolietVd.VolumeSetIdentifier) ? null
: decodedJolietVd.VolumeSetIdentifier;
if(string.IsNullOrEmpty(decodedJolietVd.PublisherIdentifier) || decodedVd.PublisherIdentifier.Length >
decodedJolietVd.PublisherIdentifier.Length)
if(string.IsNullOrEmpty(decodedJolietVd.PublisherIdentifier) ||
decodedVd.PublisherIdentifier.Length > decodedJolietVd.PublisherIdentifier.Length)
XmlFsType.PublisherIdentifier = decodedVd.PublisherIdentifier;
else
XmlFsType.PublisherIdentifier = string.IsNullOrEmpty(decodedJolietVd.PublisherIdentifier)
? null
XmlFsType.PublisherIdentifier = string.IsNullOrEmpty(decodedJolietVd.PublisherIdentifier) ? null
: decodedJolietVd.PublisherIdentifier;
if(string.IsNullOrEmpty(decodedJolietVd.DataPreparerIdentifier) ||
@@ -533,19 +461,18 @@ namespace DiscImageChef.Filesystems.ISO9660
XmlFsType.DataPreparerIdentifier = decodedVd.DataPreparerIdentifier;
else
XmlFsType.DataPreparerIdentifier = string.IsNullOrEmpty(decodedJolietVd.DataPreparerIdentifier)
? null
: decodedJolietVd.DataPreparerIdentifier;
? null : decodedJolietVd.DataPreparerIdentifier;
if(string.IsNullOrEmpty(decodedJolietVd.ApplicationIdentifier) ||
decodedVd.ApplicationIdentifier.Length > decodedJolietVd.ApplicationIdentifier.Length)
XmlFsType.ApplicationIdentifier = decodedVd.ApplicationIdentifier;
else
XmlFsType.ApplicationIdentifier = string.IsNullOrEmpty(decodedJolietVd.ApplicationIdentifier)
? null
XmlFsType.ApplicationIdentifier = string.IsNullOrEmpty(decodedJolietVd.ApplicationIdentifier) ? null
: decodedJolietVd.ApplicationIdentifier;
XmlFsType.CreationDate = decodedJolietVd.CreationTime;
XmlFsType.CreationDateSpecified = true;
if(decodedJolietVd.HasModificationTime)
{
XmlFsType.ModificationDate = decodedJolietVd.ModificationTime;
@@ -563,6 +490,8 @@ namespace DiscImageChef.Filesystems.ISO9660
XmlFsType.EffectiveDate = decodedJolietVd.EffectiveTime;
XmlFsType.EffectiveDateSpecified = true;
}
decodedVd = decodedJolietVd;
}
else
{
@@ -574,6 +503,7 @@ namespace DiscImageChef.Filesystems.ISO9660
XmlFsType.ApplicationIdentifier = decodedVd.ApplicationIdentifier;
XmlFsType.CreationDate = decodedVd.CreationTime;
XmlFsType.CreationDateSpecified = true;
if(decodedVd.HasModificationTime)
{
XmlFsType.ModificationDate = decodedVd.ModificationTime;
@@ -593,20 +523,132 @@ namespace DiscImageChef.Filesystems.ISO9660
}
}
if(debug)
{
rootDirectoryCache.Add("$", new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
(rootLocation, (uint)rootDir.Length)
},
Filename = "$", Size = (uint)rootDir.Length, Timestamp = decodedVd.CreationTime
});
if(!cdi)
rootDirectoryCache.Add("$PATH_TABLE.LSB", new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
(pathTableLsbLocation, (uint)pathTableData.Length)
},
Filename = "$PATH_TABLE.LSB", Size = (uint)pathTableData.Length,
Timestamp = decodedVd.CreationTime
});
rootDirectoryCache.Add("$PATH_TABLE.MSB", new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
(pathTableMsbLocation, (uint)pathTableData.Length)
},
Filename = "$PATH_TABLE.MSB", Size = (uint)pathTableData.Length, Timestamp = decodedVd.CreationTime
});
for(int i = 0; i < bvdSectors.Count; i++)
rootDirectoryCache.Add(i == 0 ? "$BOOT" : $"$BOOT_{i}", new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
((uint)i, 2048)
},
Filename = i == 0 ? "$BOOT" : $"$BOOT_{i}", Size = 2048, Timestamp = decodedVd.CreationTime
});
for(int i = 0; i < pvdSectors.Count; i++)
rootDirectoryCache.Add(i == 0 ? "$PVD" : $"$PVD{i}", new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
((uint)i, 2048)
},
Filename = i == 0 ? "$PVD" : $"PVD_{i}", Size = 2048, Timestamp = decodedVd.CreationTime
});
for(int i = 0; i < svdSectors.Count; i++)
rootDirectoryCache.Add(i == 0 ? "$SVD" : $"$SVD_{i}", new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
((uint)i, 2048)
},
Filename = i == 0 ? "$SVD" : $"$SVD_{i}", Size = 2048, Timestamp = decodedVd.CreationTime
});
for(int i = 0; i < evdSectors.Count; i++)
rootDirectoryCache.Add(i == 0 ? "$EVD" : $"$EVD_{i}", new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
((uint)i, 2048)
},
Filename = i == 0 ? "$EVD" : $"$EVD_{i}", Size = 2048, Timestamp = decodedVd.CreationTime
});
for(int i = 0; i < vpdSectors.Count; i++)
rootDirectoryCache.Add(i == 0 ? "$VPD" : $"$VPD_{i}", new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
((uint)i, 2048)
},
Filename = i == 0 ? "$VPD" : $"$VPD_{i}", Size = 2048, Timestamp = decodedVd.CreationTime
});
if(segaCd != null)
rootDirectoryCache.Add("$IP.BIN", new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
((uint)partition.Start, (uint)Marshal.SizeOf<CD.IPBin>())
},
Filename = "$IP.BIN", Size = (uint)Marshal.SizeOf<CD.IPBin>(),
Timestamp = decodedVd.CreationTime
});
if(saturn != null)
rootDirectoryCache.Add("$IP.BIN", new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
((uint)partition.Start, (uint)Marshal.SizeOf<Saturn.IPBin>())
},
Filename = "$IP.BIN", Size = (uint)Marshal.SizeOf<Saturn.IPBin>(),
Timestamp = decodedVd.CreationTime
});
if(dreamcast != null)
rootDirectoryCache.Add("$IP.BIN", new DecodedDirectoryEntry
{
Extents = new List<(uint extent, uint size)>
{
((uint)partition.Start, (uint)Marshal.SizeOf<Dreamcast.IPBin>())
},
Filename = "$IP.BIN", Size = (uint)Marshal.SizeOf<Dreamcast.IPBin>(),
Timestamp = decodedVd.CreationTime
});
}
XmlFsType.Bootable |= bvd != null || segaCd != null || saturn != null || dreamcast != null;
XmlFsType.Clusters = decodedVd.Blocks;
XmlFsType.ClusterSize = decodedVd.BlockSize;
statfs = new FileSystemInfo
{
Blocks = decodedVd.Blocks,
FilenameLength = (ushort)(jolietvd != null
? this.@namespace == Namespace.Joliet
Blocks = decodedVd.Blocks, FilenameLength =
(ushort)(jolietvd != null ? this.@namespace == Namespace.Joliet
? 110
: 255
: 255),
PluginId = Id,
Type = fsFormat
: 255 : 255),
PluginId = Id, Type = fsFormat
};
directoryCache = new Dictionary<string, Dictionary<string, DecodedDirectoryEntry>>();
@@ -626,7 +668,8 @@ namespace DiscImageChef.Filesystems.ISO9660
public Errno Unmount()
{
if(!mounted) return Errno.AccessDenied;
if(!mounted)
return Errno.AccessDenied;
rootDirectoryCache = null;
directoryCache = null;
@@ -638,9 +681,12 @@ namespace DiscImageChef.Filesystems.ISO9660
public Errno StatFs(out FileSystemInfo stat)
{
stat = null;
if(!mounted) return Errno.AccessDenied;
if(!mounted)
return Errno.AccessDenied;
stat = statfs.ShallowCopy();
return Errno.NoError;
}
}