mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Implemente remote Get PCMCIA Data packet.
This commit is contained in:
@@ -656,51 +656,62 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
#region PCMCIA
|
#region PCMCIA
|
||||||
|
|
||||||
if (PlatformId == PlatformID.Linux)
|
if(remote is null)
|
||||||
{
|
{
|
||||||
if (devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
|
if (PlatformId == PlatformID.Linux)
|
||||||
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
|
|
||||||
devicePath.StartsWith("/dev/st", StringComparison.Ordinal))
|
|
||||||
{
|
{
|
||||||
var devPath = devicePath.Substring(5);
|
if (devicePath.StartsWith("/dev/sd", StringComparison.Ordinal) ||
|
||||||
if (Directory.Exists("/sys/block/" + devPath))
|
devicePath.StartsWith("/dev/sr", StringComparison.Ordinal) ||
|
||||||
|
devicePath.StartsWith("/dev/st", StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
var resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath);
|
var devPath = devicePath.Substring(5);
|
||||||
resolvedLink = "/sys" + resolvedLink.Substring(2);
|
if (Directory.Exists("/sys/block/" + devPath))
|
||||||
if (!string.IsNullOrEmpty(resolvedLink))
|
{
|
||||||
while (resolvedLink.Contains("/sys/devices"))
|
var resolvedLink = Linux.Command.ReadLink("/sys/block/" + devPath);
|
||||||
{
|
resolvedLink = "/sys" + resolvedLink.Substring(2);
|
||||||
resolvedLink = Path.GetDirectoryName(resolvedLink);
|
if (!string.IsNullOrEmpty(resolvedLink))
|
||||||
if (!Directory.Exists(resolvedLink + "/pcmcia_socket")) continue;
|
while (resolvedLink.Contains("/sys/devices"))
|
||||||
|
{
|
||||||
|
resolvedLink = Path.GetDirectoryName(resolvedLink);
|
||||||
|
if (!Directory.Exists(resolvedLink + "/pcmcia_socket")) continue;
|
||||||
|
|
||||||
var subdirs = Directory.GetDirectories(resolvedLink + "/pcmcia_socket",
|
var subdirs = Directory.GetDirectories(resolvedLink + "/pcmcia_socket",
|
||||||
"pcmcia_socket*",
|
"pcmcia_socket*",
|
||||||
SearchOption.TopDirectoryOnly);
|
SearchOption.TopDirectoryOnly);
|
||||||
|
|
||||||
if (subdirs.Length <= 0) continue;
|
if (subdirs.Length <= 0) continue;
|
||||||
|
|
||||||
var possibleDir = Path.Combine(resolvedLink, "pcmcia_socket", subdirs[0]);
|
var possibleDir = Path.Combine(resolvedLink, "pcmcia_socket", subdirs[0]);
|
||||||
if (!File.Exists(possibleDir + "/card_type") || !File.Exists(possibleDir + "/cis"))
|
if (!File.Exists(possibleDir + "/card_type") || !File.Exists(possibleDir + "/cis"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var cisFs = new FileStream(possibleDir + "/cis", System.IO.FileMode.Open,
|
var cisFs = new FileStream(possibleDir + "/cis", System.IO.FileMode.Open,
|
||||||
System.IO.FileAccess.Read);
|
System.IO.FileAccess.Read);
|
||||||
var cisBuf = new byte[65536];
|
var cisBuf = new byte[65536];
|
||||||
var cisCount = cisFs.Read(cisBuf, 0, 65536);
|
var cisCount = cisFs.Read(cisBuf, 0, 65536);
|
||||||
Cis = new byte[cisCount];
|
Cis = new byte[cisCount];
|
||||||
Array.Copy(cisBuf, 0, Cis, 0, cisCount);
|
Array.Copy(cisBuf, 0, Cis, 0, cisCount);
|
||||||
cisFs.Close();
|
cisFs.Close();
|
||||||
|
|
||||||
IsPcmcia = true;
|
IsPcmcia = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO: Implement for other operating systems
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IsPcmcia = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// TODO: Implement for other operating systems
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IsPcmcia = false;
|
if (remote.GetPcmciaData(out var cisBuf))
|
||||||
|
{
|
||||||
|
IsPcmcia = true;
|
||||||
|
Cis = cisBuf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion PCMCIA
|
#endregion PCMCIA
|
||||||
|
|||||||
@@ -751,7 +751,7 @@ namespace DiscImageChef.Devices.Remote
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hdr.packetType != DicPacketType.ResponseGetUsbData)
|
if (hdr.packetType != DicPacketType.ResponseGetFireWireData)
|
||||||
{
|
{
|
||||||
DicConsole.ErrorWriteLine("Expected FireWire Data Response Packet, got packet type {0}...",
|
DicConsole.ErrorWriteLine("Expected FireWire Data Response Packet, got packet type {0}...",
|
||||||
hdr.packetType);
|
hdr.packetType);
|
||||||
@@ -783,7 +783,71 @@ namespace DiscImageChef.Devices.Remote
|
|||||||
|
|
||||||
public bool GetPcmciaData(out byte[] cis)
|
public bool GetPcmciaData(out byte[] cis)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException("Getting PCMCIA data not yet implemented...");
|
cis = null;
|
||||||
|
|
||||||
|
var cmdPkt = new DicPacketCmdGetPcmciaData()
|
||||||
|
{
|
||||||
|
hdr = new DicPacketHeader
|
||||||
|
{
|
||||||
|
id = Consts.PacketId,
|
||||||
|
len = (uint) Marshal.SizeOf<DicPacketCmdGetPcmciaData>(),
|
||||||
|
version = Consts.PacketVersion,
|
||||||
|
packetType = DicPacketType.CommandGetPcmciaData
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var buf = Marshal.StructureToByteArrayLittleEndian(cmdPkt);
|
||||||
|
|
||||||
|
var len = _socket.Send(buf, SocketFlags.None);
|
||||||
|
|
||||||
|
if (len != buf.Length)
|
||||||
|
{
|
||||||
|
DicConsole.ErrorWriteLine("Could not write to the network...");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var hdrBuf = new byte[Marshal.SizeOf<DicPacketHeader>()];
|
||||||
|
|
||||||
|
len = _socket.Receive(hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||||
|
|
||||||
|
if (len < hdrBuf.Length)
|
||||||
|
{
|
||||||
|
DicConsole.ErrorWriteLine("Could not read from the network...");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var hdr = Marshal.ByteArrayToStructureLittleEndian<DicPacketHeader>(hdrBuf);
|
||||||
|
|
||||||
|
if (hdr.id != Consts.PacketId)
|
||||||
|
{
|
||||||
|
DicConsole.ErrorWriteLine("Received data is not a DIC Remote Packet...");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hdr.packetType != DicPacketType.ResponseGetPcmciaData)
|
||||||
|
{
|
||||||
|
DicConsole.ErrorWriteLine("Expected PCMCIA Data Response Packet, got packet type {0}...",
|
||||||
|
hdr.packetType);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf = new byte[hdr.len];
|
||||||
|
len = _socket.Receive(buf, buf.Length, SocketFlags.None);
|
||||||
|
|
||||||
|
if (len < buf.Length)
|
||||||
|
{
|
||||||
|
DicConsole.ErrorWriteLine("Could not read from the network...");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var res = Marshal.ByteArrayToStructureLittleEndian<DicPacketResGetPcmciaData>(buf);
|
||||||
|
|
||||||
|
if (!res.isPcmcia)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
cis = res.cis;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user