Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -9,6 +9,7 @@ Mono.Unix/UnixPathTest.cs
Mono.Unix/UnixSignalTest.cs
Mono.Unix/UnixUserTest.cs
Mono.Unix.Android/TestHelper.cs
Mono.Unix.Native/MemfdTest.cs
Mono.Unix.Native/OFDLockTest.cs
Mono.Unix.Native/RealTimeSignumTests.cs
Mono.Unix.Native/SocketTest.cs

View File

@@ -341,6 +341,38 @@ namespace Mono.Unix.Native {
return fopen_mode;
}
[DllImport (LIB, EntryPoint="Mono_Posix_FromMremapFlags")]
private static extern int FromMremapFlags (MremapFlags value, out UInt64 rval);
public static bool TryFromMremapFlags (MremapFlags value, out UInt64 rval)
{
return FromMremapFlags (value, out rval) == 0;
}
public static UInt64 FromMremapFlags (MremapFlags value)
{
UInt64 rval;
if (FromMremapFlags (value, out rval) == -1)
ThrowArgumentException (value);
return rval;
}
[DllImport (LIB, EntryPoint="Mono_Posix_ToMremapFlags")]
private static extern int ToMremapFlags (UInt64 value, out MremapFlags rval);
public static bool TryToMremapFlags (UInt64 value, out MremapFlags rval)
{
return ToMremapFlags (value, out rval) == 0;
}
public static MremapFlags ToMremapFlags (UInt64 value)
{
MremapFlags rval;
if (ToMremapFlags (value, out rval) == -1)
ThrowArgumentException (value);
return rval;
}
[DllImport (LIB, EntryPoint="Mono_Posix_FromStat")]
private static extern int FromStat (ref Stat source, IntPtr destination);

View File

@@ -1,5 +1,5 @@
/*
* This file was automatically generated by create-native-map from ./../../class/lib/net_4_x/Mono.Posix.dll.
* This file was automatically generated by create-native-map from ./../../class/lib/net_4_x-linux/Mono.Posix.dll.
*
* DO NOT MODIFY.
*/
@@ -438,6 +438,38 @@ namespace Mono.Unix.Native {
return rval;
}
[DllImport (LIB, EntryPoint="Mono_Posix_FromMemfdFlags")]
private static extern int FromMemfdFlags (MemfdFlags value, out UInt32 rval);
public static bool TryFromMemfdFlags (MemfdFlags value, out UInt32 rval)
{
return FromMemfdFlags (value, out rval) == 0;
}
public static UInt32 FromMemfdFlags (MemfdFlags value)
{
UInt32 rval;
if (FromMemfdFlags (value, out rval) == -1)
ThrowArgumentException (value);
return rval;
}
[DllImport (LIB, EntryPoint="Mono_Posix_ToMemfdFlags")]
private static extern int ToMemfdFlags (UInt32 value, out MemfdFlags rval);
public static bool TryToMemfdFlags (UInt32 value, out MemfdFlags rval)
{
return ToMemfdFlags (value, out rval) == 0;
}
public static MemfdFlags ToMemfdFlags (UInt32 value)
{
MemfdFlags rval;
if (ToMemfdFlags (value, out rval) == -1)
ThrowArgumentException (value);
return rval;
}
[DllImport (LIB, EntryPoint="Mono_Posix_FromMessageFlags")]
private static extern int FromMessageFlags (MessageFlags value, out Int32 rval);
@@ -598,38 +630,6 @@ namespace Mono.Unix.Native {
return rval;
}
[DllImport (LIB, EntryPoint="Mono_Posix_FromMremapFlags")]
private static extern int FromMremapFlags (MremapFlags value, out UInt64 rval);
public static bool TryFromMremapFlags (MremapFlags value, out UInt64 rval)
{
return FromMremapFlags (value, out rval) == 0;
}
public static UInt64 FromMremapFlags (MremapFlags value)
{
UInt64 rval;
if (FromMremapFlags (value, out rval) == -1)
ThrowArgumentException (value);
return rval;
}
[DllImport (LIB, EntryPoint="Mono_Posix_ToMremapFlags")]
private static extern int ToMremapFlags (UInt64 value, out MremapFlags rval);
public static bool TryToMremapFlags (UInt64 value, out MremapFlags rval)
{
return ToMremapFlags (value, out rval) == 0;
}
public static MremapFlags ToMremapFlags (UInt64 value)
{
MremapFlags rval;
if (ToMremapFlags (value, out rval) == -1)
ThrowArgumentException (value);
return rval;
}
[DllImport (LIB, EntryPoint="Mono_Posix_FromMsyncFlags")]
private static extern int FromMsyncFlags (MsyncFlags value, out Int32 rval);
@@ -838,6 +838,38 @@ namespace Mono.Unix.Native {
return rval;
}
[DllImport (LIB, EntryPoint="Mono_Posix_FromSealType")]
private static extern int FromSealType (SealType value, out Int32 rval);
public static bool TryFromSealType (SealType value, out Int32 rval)
{
return FromSealType (value, out rval) == 0;
}
public static Int32 FromSealType (SealType value)
{
Int32 rval;
if (FromSealType (value, out rval) == -1)
ThrowArgumentException (value);
return rval;
}
[DllImport (LIB, EntryPoint="Mono_Posix_ToSealType")]
private static extern int ToSealType (Int32 value, out SealType rval);
public static bool TryToSealType (Int32 value, out SealType rval)
{
return ToSealType (value, out rval) == 0;
}
public static SealType ToSealType (Int32 value)
{
SealType rval;
if (ToSealType (value, out rval) == -1)
ThrowArgumentException (value);
return rval;
}
[DllImport (LIB, EntryPoint="Mono_Posix_FromSeekFlags")]
private static extern int FromSeekFlags (SeekFlags value, out Int16 rval);

View File

@@ -1 +1 @@
c9eb750d22227382cc4989053d328c0e7fc0bc79
c518961806361767322f0b757271f1146519fa75

View File

@@ -0,0 +1,98 @@
//
// Tests for memfd_create and file sealing
//
// Authors:
// Steffen Kiess (kiess@ki4.de)
//
// Copyright (C) 2019 Steffen Kiess
//
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using Mono.Unix;
using Mono.Unix.Native;
using NUnit.Framework;
namespace MonoTests.Mono.Unix.Native
{
[TestFixture, Category ("NotDotNet"), Category ("NotOnWindows"), Category ("NotOnMac")]
public class MemfdTest {
[Test]
public unsafe void TestMemfd ()
{
int fd;
try {
fd = Syscall.memfd_create ("mono-test", 0);
} catch (EntryPointNotFoundException) {
Assert.Ignore ("memfd_create() not available");
return;
}
if (fd < 0 && Stdlib.GetLastError () == Errno.ENOSYS)
// Might happen on a new libc + old kernel
Assert.Ignore ("memfd_create() returns ENOSYS");
if (fd < 0)
UnixMarshal.ThrowExceptionForLastError ();
byte b = 42;
if (Syscall.write (fd, &b, 1) < 0)
UnixMarshal.ThrowExceptionForLastError ();
// Should fail with EPERM because MFD_ALLOW_SEALING was not used
var res = Syscall.fcntl(fd, FcntlCommand.F_ADD_SEALS, SealType.F_SEAL_WRITE);
Assert.AreEqual (-1, res);
Assert.AreEqual (Errno.EPERM, Stdlib.GetLastError ());
//Stdlib.system ("ls -l /proc/$PPID/fd/");
if (Syscall.close (fd) < 0)
UnixMarshal.ThrowExceptionForLastError ();
// Call memfd_create with MFD_ALLOW_SEALING
fd = Syscall.memfd_create ("mono-test", MemfdFlags.MFD_CLOEXEC | MemfdFlags.MFD_ALLOW_SEALING);
if (fd < 0)
UnixMarshal.ThrowExceptionForLastError ();
if (Syscall.write (fd, &b, 1) < 0)
UnixMarshal.ThrowExceptionForLastError ();
res = Syscall.fcntl(fd, FcntlCommand.F_GET_SEALS);
if (res < 0)
UnixMarshal.ThrowExceptionForLastError ();
// Need to convert the result to SealType
SealType sealType = NativeConvert.ToSealType (res);
Assert.AreEqual ((SealType)0, sealType);
if (Syscall.fcntl(fd, FcntlCommand.F_ADD_SEALS, SealType.F_SEAL_WRITE) < 0)
UnixMarshal.ThrowExceptionForLastError ();
// Should fail with EPERM because the file was sealed for writing
var lres = Syscall.write (fd, &b, 1);
Assert.AreEqual (-1, lres);
Assert.AreEqual (Errno.EPERM, Stdlib.GetLastError ());
res = Syscall.fcntl(fd, FcntlCommand.F_GET_SEALS);
if (res < 0)
UnixMarshal.ThrowExceptionForLastError ();
// Need to convert the result to SealType
sealType = NativeConvert.ToSealType (res);
Assert.AreEqual (SealType.F_SEAL_WRITE, sealType);
//Stdlib.system ("ls -l /proc/$PPID/fd/");
if (Syscall.close (fd) < 0)
UnixMarshal.ThrowExceptionForLastError ();
}
}
}
// vim: noexpandtab
// Local Variables:
// tab-width: 4
// c-basic-offset: 4
// indent-tabs-mode: t
// End: