2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2015-10-12 06:39:31 +01:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : Extern.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Component : Linux direct device access.
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Contains the P/Invoke definitions of Linux syscalls used to directly
|
|
|
|
|
// interface devices.
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
2015-10-12 06:39:31 +01:00
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// This library 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
|
|
|
|
|
// Lesser General Public License for more details.
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2015-10-12 06:39:31 +01:00
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2015-10-12 06:39:31 +01:00
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
2017-12-19 03:50:57 +00:00
|
|
|
using System;
|
2015-10-12 06:39:31 +01:00
|
|
|
using System.Runtime.InteropServices;
|
2015-10-05 21:20:25 +01:00
|
|
|
|
|
|
|
|
namespace DiscImageChef.Devices.Linux
|
|
|
|
|
{
|
|
|
|
|
static class Extern
|
|
|
|
|
{
|
|
|
|
|
[DllImport("libc", CharSet = CharSet.Ansi, SetLastError = true)]
|
2015-10-06 21:18:02 +01:00
|
|
|
internal static extern int open(
|
|
|
|
|
string pathname,
|
|
|
|
|
[MarshalAs(UnmanagedType.U4)]
|
|
|
|
|
FileFlags flags);
|
2015-10-05 21:20:25 +01:00
|
|
|
|
|
|
|
|
[DllImport("libc")]
|
|
|
|
|
internal static extern int close(int fd);
|
|
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
[DllImport("libc", EntryPoint = "ioctl", SetLastError = true)]
|
2015-10-12 06:25:49 +01:00
|
|
|
internal static extern int ioctlInt(int fd, LinuxIoctl request, out int value);
|
2015-10-05 21:20:25 +01:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
[DllImport("libc", EntryPoint = "ioctl", SetLastError = true)]
|
2015-10-12 06:25:49 +01:00
|
|
|
internal static extern int ioctlSg(int fd, LinuxIoctl request, ref sg_io_hdr_t value);
|
2015-12-31 16:12:22 +00:00
|
|
|
|
2016-10-22 22:58:01 +01:00
|
|
|
[DllImport("libc", EntryPoint = "ioctl", SetLastError = true)]
|
|
|
|
|
internal static extern int ioctlMmc(int fd, LinuxIoctl request, ref mmc_ioc_cmd value);
|
|
|
|
|
|
2015-12-31 16:12:22 +00:00
|
|
|
[DllImport("libc", CharSet = CharSet.Ansi, SetLastError = true)]
|
2016-04-19 02:11:47 +01:00
|
|
|
internal static extern int readlink(string path, System.IntPtr buf, int bufsize);
|
2015-12-31 16:12:22 +00:00
|
|
|
|
2016-04-19 02:11:47 +01:00
|
|
|
[DllImport("libc", CharSet = CharSet.Ansi, EntryPoint = "readlink", SetLastError = true)]
|
|
|
|
|
internal static extern long readlink64(string path, System.IntPtr buf, long bufsize);
|
2017-08-21 21:04:44 +01:00
|
|
|
|
|
|
|
|
[DllImport("libudev", CharSet = CharSet.Ansi, SetLastError = true)]
|
|
|
|
|
internal static extern IntPtr udev_new();
|
|
|
|
|
|
|
|
|
|
[DllImport("libudev", CharSet = CharSet.Ansi, SetLastError = true)]
|
|
|
|
|
internal static extern IntPtr udev_device_new_from_subsystem_sysname(IntPtr udev, string subsystem, string sysname);
|
|
|
|
|
|
|
|
|
|
[DllImport("libudev", CharSet = CharSet.Ansi, SetLastError = true)]
|
|
|
|
|
internal static extern string udev_device_get_property_value(IntPtr udev_device, string key);
|
2015-10-05 21:20:25 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|