mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
* DiscImageChef.Devices/Linux/Enums.cs:
* DiscImageChef.Devices/Linux/Extern.cs: * DiscImageChef.Devices/Linux/Structs.cs: Filled Linux enums. * DiscImageChef.Devices/Windows/Enums.cs: Typo
This commit is contained in:
@@ -1,3 +1,13 @@
|
|||||||
|
2015-10-06 Natalia Portillo <claunia@claunia.com>
|
||||||
|
|
||||||
|
* Linux/Enums.cs:
|
||||||
|
* Linux/Extern.cs:
|
||||||
|
* Linux/Structs.cs:
|
||||||
|
Filled Linux enums.
|
||||||
|
|
||||||
|
* Windows/Enums.cs:
|
||||||
|
Typo
|
||||||
|
|
||||||
2015-10-06 Natalia Portillo <claunia@claunia.com>
|
2015-10-06 Natalia Portillo <claunia@claunia.com>
|
||||||
|
|
||||||
* Windows/Extern.cs:
|
* Windows/Extern.cs:
|
||||||
|
|||||||
@@ -2,19 +2,151 @@
|
|||||||
|
|
||||||
namespace DiscImageChef.Devices.Linux
|
namespace DiscImageChef.Devices.Linux
|
||||||
{
|
{
|
||||||
static class Enums
|
[Flags]
|
||||||
|
enum FileFlags : int
|
||||||
{
|
{
|
||||||
internal const int O_RDONLY = 0;
|
/// <summary>
|
||||||
internal const int O_RDWR = 2;
|
/// O_RDONLY
|
||||||
|
/// </summary>
|
||||||
|
Readonly = 00000000,
|
||||||
|
/// <summary>
|
||||||
|
/// O_WRONLY
|
||||||
|
/// </summary>
|
||||||
|
Writeonly = 00000001,
|
||||||
|
/// <summary>
|
||||||
|
/// O_RDWR
|
||||||
|
/// </summary>
|
||||||
|
ReadWrite = 00000002,
|
||||||
|
/// <summary>
|
||||||
|
/// O_CREAT
|
||||||
|
/// </summary>
|
||||||
|
OpenOrCreate = 00000100,
|
||||||
|
/// <summary>
|
||||||
|
/// O_EXCL
|
||||||
|
/// </summary>
|
||||||
|
CreateNew = 00000200,
|
||||||
|
/// <summary>
|
||||||
|
/// O_NOCTTY
|
||||||
|
/// </summary>
|
||||||
|
NoControlTTY = 00000400,
|
||||||
|
/// <summary>
|
||||||
|
/// O_TRUNC
|
||||||
|
/// </summary>
|
||||||
|
Truncate = 00001000,
|
||||||
|
/// <summary>
|
||||||
|
/// O_APPEND
|
||||||
|
/// </summary>
|
||||||
|
Append = 00002000,
|
||||||
|
/// <summary>
|
||||||
|
/// O_NONBLOCK
|
||||||
|
/// </summary>
|
||||||
|
NonBlocking = 00004000,
|
||||||
|
/// <summary>
|
||||||
|
/// O_DSYNC
|
||||||
|
/// </summary>
|
||||||
|
Synchronous = 00010000,
|
||||||
|
/// <summary>
|
||||||
|
/// O_ASYNC
|
||||||
|
/// </summary>
|
||||||
|
Async = 00020000,
|
||||||
|
/// <summary>
|
||||||
|
/// O_DIRECT
|
||||||
|
/// </summary>
|
||||||
|
Direct = 00040000,
|
||||||
|
/// <summary>
|
||||||
|
/// O_LARGEFILE
|
||||||
|
/// </summary>
|
||||||
|
LargeFile = 00100000,
|
||||||
|
/// <summary>
|
||||||
|
/// O_DIRECTORY
|
||||||
|
/// </summary>
|
||||||
|
Directory = 00200000,
|
||||||
|
/// <summary>
|
||||||
|
/// O_NOFOLLOW
|
||||||
|
/// </summary>
|
||||||
|
NoFollowSymlink = 00400000,
|
||||||
|
/// <summary>
|
||||||
|
/// O_NOATIME
|
||||||
|
/// </summary>
|
||||||
|
NoAccessTime = 01000000,
|
||||||
|
/// <summary>
|
||||||
|
/// O_CLOEXEC
|
||||||
|
/// </summary>
|
||||||
|
CloseOnExec = 02000000
|
||||||
|
}
|
||||||
|
|
||||||
internal const ulong SG_GET_VERSION_NUM = 0x2282;
|
/// <summary>
|
||||||
internal const ulong SG_IO = 0x2285;
|
/// Direction of SCSI transfer
|
||||||
|
/// </summary>
|
||||||
|
enum ScsiIoctlDirection : int
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// No data transfer happens
|
||||||
|
/// SG_DXFER_NONE
|
||||||
|
/// </summary>
|
||||||
|
None = -1,
|
||||||
|
/// <summary>
|
||||||
|
/// From host to device
|
||||||
|
/// SG_DXFER_TO_DEV
|
||||||
|
/// </summary>
|
||||||
|
Out = -2,
|
||||||
|
/// <summary>
|
||||||
|
/// From device to host
|
||||||
|
/// SG_DXFER_FROM_DEV
|
||||||
|
/// </summary>
|
||||||
|
In = -3,
|
||||||
|
/// <summary>
|
||||||
|
/// Bidirectional device/host
|
||||||
|
/// SG_DXFER_TO_FROM_DEV
|
||||||
|
/// </summary>
|
||||||
|
Unspecified = -4,
|
||||||
|
/// <summary>
|
||||||
|
/// Unspecified
|
||||||
|
/// SG_DXFER_UNKNOWN
|
||||||
|
/// </summary>
|
||||||
|
Unknown = -5
|
||||||
|
}
|
||||||
|
|
||||||
internal const int SG_DXFER_FROM_DEV = -3;
|
enum LinuxIoctl : ulong
|
||||||
|
{
|
||||||
|
SG_EMULATED_HOST = 0x2203,
|
||||||
|
SG_GET_VERSION_NUM = 0x2282,
|
||||||
|
SG_IO = 0x2285,
|
||||||
|
SG_GET_SCSI_ID = 0x2276,
|
||||||
|
}
|
||||||
|
|
||||||
internal const uint SG_INFO_OK_MASK = 0x1;
|
[Flags]
|
||||||
internal const uint SG_INFO_OK = 0x0; /* no sense, host nor driver "noise" */
|
enum SgInfo : uint
|
||||||
internal const uint SG_INFO_CHECK = 0x1;
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Mask to check OK
|
||||||
|
/// </summary>
|
||||||
|
OkMask = 0x01,
|
||||||
|
/// <summary>
|
||||||
|
/// No sense or driver noise
|
||||||
|
/// </summary>
|
||||||
|
Ok = 0x00,
|
||||||
|
/// <summary>
|
||||||
|
/// Check Condition
|
||||||
|
/// </summary>
|
||||||
|
CheckCondition = 0x01,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Direct I/O mask
|
||||||
|
/// </summary>
|
||||||
|
DirectIoMask = 0x06,
|
||||||
|
/// <summary>
|
||||||
|
/// Transfer via kernel buffers (or no transfer)
|
||||||
|
/// </summary>
|
||||||
|
IndirectIo = 0x00,
|
||||||
|
/// <summary>
|
||||||
|
/// Direct I/O performed
|
||||||
|
/// </summary>
|
||||||
|
DirectIo = 0x02,
|
||||||
|
/// <summary>
|
||||||
|
/// Partial direct and partial indirect I/O
|
||||||
|
/// </summary>
|
||||||
|
MixedIo = 0x04
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ namespace DiscImageChef.Devices.Linux
|
|||||||
static class Extern
|
static class Extern
|
||||||
{
|
{
|
||||||
[DllImport("libc", CharSet = CharSet.Ansi, SetLastError = true)]
|
[DllImport("libc", CharSet = CharSet.Ansi, SetLastError = true)]
|
||||||
internal static extern int open(string pathname, int flags);
|
internal static extern int open(
|
||||||
|
string pathname,
|
||||||
|
[MarshalAs(UnmanagedType.U4)]
|
||||||
|
FileFlags flags);
|
||||||
|
|
||||||
[DllImport("libc")]
|
[DllImport("libc")]
|
||||||
internal static extern int close(int fd);
|
internal static extern int close(int fd);
|
||||||
@@ -14,7 +17,7 @@ namespace DiscImageChef.Devices.Linux
|
|||||||
internal static extern int ioctlInt(int fd, ulong request, out int value);
|
internal static extern int ioctlInt(int fd, ulong request, out int value);
|
||||||
|
|
||||||
[DllImport("libc", EntryPoint="ioctl", SetLastError = true)]
|
[DllImport("libc", EntryPoint="ioctl", SetLastError = true)]
|
||||||
internal static extern int ioctlSg(int fd, ulong request, ref Structs.sg_io_hdr_t value);
|
internal static extern int ioctlSg(int fd, ulong request, ref sg_io_hdr_t value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,37 +3,34 @@ using System.Runtime.InteropServices;
|
|||||||
|
|
||||||
namespace DiscImageChef.Devices.Linux
|
namespace DiscImageChef.Devices.Linux
|
||||||
{
|
{
|
||||||
static class Structs
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
struct sg_io_hdr_t
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
/// <summary>
|
||||||
internal struct sg_io_hdr_t
|
/// Always 'S' for SG v3
|
||||||
{
|
/// </summary>
|
||||||
/// <summary>
|
public int interface_id; /* [i] 'S' (required) */
|
||||||
/// Always 'S' for SG v3
|
public int dxfer_direction; /* [i] */
|
||||||
/// </summary>
|
public byte cmd_len; /* [i] */
|
||||||
public int interface_id; /* [i] 'S' (required) */
|
public byte mx_sb_len; /* [i] */
|
||||||
public int dxfer_direction; /* [i] */
|
public ushort iovec_count; /* [i] */
|
||||||
public byte cmd_len; /* [i] */
|
public ScsiIoctlDirection dxfer_len; /* [i] */
|
||||||
public byte mx_sb_len; /* [i] */
|
public IntPtr dxferp; /* [i], [*io] */
|
||||||
public ushort iovec_count; /* [i] */
|
public IntPtr cmdp; /* [i], [*i] */
|
||||||
public uint dxfer_len; /* [i] */
|
public IntPtr sbp; /* [i], [*o] */
|
||||||
public IntPtr dxferp; /* [i], [*io] */
|
public uint timeout; /* [i] unit: millisecs */
|
||||||
public IntPtr cmdp; /* [i], [*i] */
|
public uint flags; /* [i] */
|
||||||
public IntPtr sbp; /* [i], [*o] */
|
public int pack_id; /* [i->o] */
|
||||||
public uint timeout; /* [i] unit: millisecs */
|
public IntPtr usr_ptr; /* [i->o] */
|
||||||
public uint flags; /* [i] */
|
public byte status; /* [o] */
|
||||||
public int pack_id; /* [i->o] */
|
public byte masked_status;/* [o] */
|
||||||
public IntPtr usr_ptr; /* [i->o] */
|
public byte msg_status; /* [o] */
|
||||||
public byte status; /* [o] */
|
public byte sb_len_wr; /* [o] */
|
||||||
public byte masked_status;/* [o] */
|
public ushort host_status; /* [o] */
|
||||||
public byte msg_status; /* [o] */
|
public ushort driver_status;/* [o] */
|
||||||
public byte sb_len_wr; /* [o] */
|
public int resid; /* [o] */
|
||||||
public ushort host_status; /* [o] */
|
public uint duration; /* [o] */
|
||||||
public ushort driver_status;/* [o] */
|
public SgInfo info; /* [o] */
|
||||||
public int resid; /* [o] */
|
|
||||||
public uint duration; /* [o] */
|
|
||||||
public uint info; /* [o] */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -236,8 +236,5 @@ namespace DiscImageChef.Devices.Windows
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
IOCTL_SCSI_GET_ADDRESS = 0x41018
|
IOCTL_SCSI_GET_ADDRESS = 0x41018
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// AAAAA
|
|
||||||
/// </summary>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user