45 Commits
Author SHA1 Message Date
jaykrell 3ec9fda371 [System.Core] Guard against embedded NUL in strings for MemoryMappedFiles (#7318) 2018-03-22 17:32:06 +01:00
jaykrell 1c88a11545 [Coop thread threadpool mmap] Convert more functions to coop/handle. (#7097)
* [Coop] ves_icall_System_Threading_Thread_GetDomainID convert to coop/handle.

* [Coop] Convert ves_icall_System_Threading_Thread_ConstructInternalThread to coop/handle.

* [Coop] Convert ves_icall_System_Threading_Thread_Thread_internal to coop/handle.

* [Coop] Convert mono_threads_get_max_stack_size ves_icall_System_Threading_Thread_SystemMaxStackSize/typo SystemMaxStackStize to coop/handle.

* [Coop] Convert ves_icall_System_Threading_Thread_Suspend to coop/handle.

* [Coop] Convert ves_icall_System_Threading_Thread_Sleep_internal to coop/handle.

* [Coop] Convert ves_icall_System_Threading_Thread_SpinWait_nop to coop/handle.

* [Coop] Convert threadpool.c to handles -- no pointers, just MonoError.

* [Coop] Convert ves_icall_System_Threading_InternalThread_Thread_free_internal to coop/handle.

* [Coop] Convert mmap to coop/handle -- where there aren't pointers, just unused errors.

* [Coop] Rename some error to ioerror or win32error.

* [Coop] Convert ves_icall_System_Threading_Thread_current_lcid to coop/handle -- no pointers.

* [Coop] Convert mono_mmap_open_file, mono_mmap_open_handle to coop/handle.

* [Coop] Convert ves_icall_System_Threading_Thread_Yield to coop/handle (no pointers).

* [Coop] Layer ves_icall_System_Threading_Thread_ConstructInternalThread over new mono_thread_construct_internal.

* Ignore out of memory.

* Favor mono_error_set_generic_error over small factories (loss of breakpoint?).

* Restore accidentally lost barrier.

* [Coop] Mostly undo commit d7bdbcc9a2e76913861b69ff106f0bf9573e7ea6
Convert ves_icall_System_Threading_Thread_Sleep_internal to coop/handle.
for now.
It duplicates mono_thread_execute_interruption to mono_thread_execute_interruption_handle
which we want to ensure does not last long.
This should be achieved better by pull
  https://github.com/mono/mono/pull/6639
which removes all but one pointer user and leaves
that pointer user layered over handle instead of duplicating.

* [Coop] Fix Windows build.

* [Tailcall][Windows] Add missing error parameter.
2018-03-14 13:50:10 -07:00
Marius Ungureanu fd185fb454 [System.Core] Implement MemoryMappedFile.OpenExisting
Reuse the existing icall infrastructure to give the same handle back.

This PR implements all OpenExisting methods (with the access rights parameter discarded) and the SafeHandle property.
In the runtime, we don't check the capacity parameter if we try to open a mmap file, and we fallthrough the handle refcount case.
2017-06-26 16:57:31 +02:00
Zoltan Varga ba36f4d622 [bcl] Add a finalizer to MemoryMappedFile. 2017-03-24 14:35:18 +01:00
Niklas Therning 205a420dae MemoryMappedFile support on Windows
This implements the icalls in file-mmap-windows.c used by MemoryMappedFile.
The implementation has been inspired by the CoreFX MemoryMappedFile
implementation.

This patch also fixes a few incompatibilities between .NET and Mono:

 * The default MemoryMappedFileOptions has been changed from DelayAllocatePages
   to None.
 * mono_pagesize() on Windows now return SYSTEM_INFO.dwPageSize, the same as
   .NET and CoreFX.
 * Added mono_valloc_granule() which returns
   SYSTEM_INFO.dwAllocationGranularity and changed mono-codeman.c to use it
   when trying to allocate adjacent virtual memory.
 * MemoryMappedFileTest has been updated to succeed on .NET.
 * A test has been added to test correct DelayAllocatePages behavior (only
   supported on Mono on Windows, the flag is ignored on other platforms).
 * The posix MemoryMappedFile code has been changed to throw
   UnauthorizedAccessException rather than IOException when trying to create a
   view outside of the bounds of a MemoryMappedFile.
 * Creating a named mapping larger than 4GB on 32-bit systems now throws
   ArgumentOutOfRangeException.
2016-10-26 11:33:50 +02:00
Marek Safar 775c082236 [System.Core] Fixes warnings 2016-09-23 13:36:41 +02:00
Alexander Köplinger 3c3ef17376 [bcl] Update to match NETStandard 1.6 members 2016-08-11 20:53:38 +02:00
Alexander Köplinger b03e606287 Remove ChangeLog files from the repo
They weren't updated in the last 6 years and aren't helpful anymore (e.g. by causing unrelated matches during git grep searches).
2016-01-29 19:17:06 +01:00
Marcos Henrich 4ccc225ba6 [System.Core] Using more reference source files.
Changed MemoryMappedFile related code to use reference source
MemoryMappedViewAccessor and MemoryMappedViewStream.

This change was motivated by segmentations faults while dnmv code was
calling a CoreFX class that uses reflection to call MemoryMappedFile
code.

Now that we are using more code from reference sources there should be
no problem.

Fixes #30741 and #30825.
2015-06-15 16:09:31 +01:00
Marcos Henrich d527ed4980 [System.Core] Implemented PointerOffset
Implemented MemoryMappedViewAccessor.PointerOffset and
MemoryMappedViewStream.PointerOffset.
2015-06-03 15:41:02 +01:00
Marek Safar b23077459a [System.Core] More reference sources 2015-01-28 16:30:19 +01:00
Zoltan Varga 032f313d5f [bcl] Remove NET_4_0 defines from class libs. 2015-01-13 16:06:31 -05:00
Rodrigo Kumpera 59fd337839 [runtime] Rewrite MemoryMappedFile to support named mappings. 2014-06-13 12:17:27 -04:00
Miguel de Icaza a64dbc3e94 MemoryMappedFile fixes
This patch includes a few fixes:

	* CreateNew will actually create a memory map file, the previous logic
	  in MemoryMapImpl.Open was wrong, and would fail if the file did not
	  exist.   We now cope with this (bug #20052 was caused by this).

 	* Some exceptions were wrong, so this patch updates the
	  exceptions being thrown to be the right ones

	* On Mobile, we inverted the logic to ensure that capacity must be
	  bigger or equal than the file size (which is what the API needs to do),
	  previously it performed the opposite test.

Added tests that match the behavior on .NET for this.
2014-05-31 12:53:11 -04:00
Sebastien Pouliot d6eaeb508a [System.Core][ios] Fix value for ENAMETOOLONG (typo?) internal constant in System.IO.MemoryMappedFiles.MemoryMappedFile 2014-05-20 11:24:40 -04:00
Sebastien Pouliot 7fefa95e63 [System.Core] Fix MOBILE-implementation of MemoryMappedFile
Internal API was updated only for the non-MOBILE part. Public/shared API requires them in sync.
2014-05-07 19:33:45 -04:00
Alex Rønne Petersen 7848571e6f Fix the check in 4660f44381 for special files. 2014-05-07 16:57:12 +02:00
Marek Safar 4660f44381 [system.core] Fix some MemoryMappedFile argument checks 2014-05-07 14:19:57 +02:00
Marek Safar 323f0816f4 Add missing types and methods 2014-03-11 23:22:16 +01:00
Alex Rønne Petersen d8feb5e9ad Allow creating MemoryMappedFiles with an in-memory and on-disk capacity of zero on Unix.
This is necessary to map special files such as /dev/mem.
2014-01-06 21:41:48 +01:00
Jonathan Pryor 0e7dc370e3 [System.Core/Android] Android's libc.so doesn't export getpagesize()
Partially fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=12739

Android's libc.so doesn't export getpagesize(3), resulting in an
EntryPointNotFoundException:

	System.EntryPointNotFoundException: getpagesize
	  at (wrapper managed-to-native) System.IO.MemoryMappedFiles.MemoryMapImpl.getpagesize ()
	  at System.IO.MemoryMappedFiles.MemoryMapImpl.Map (int,long,long&,System.IO.MemoryMappedFiles.MemoryMappedFileAccess,intptr&,int&)
	  at System.IO.MemoryMappedFiles.MemoryMappedViewAccessor.Create (long,long,System.IO.MemoryMappedFiles.MemoryMappedFileAccess)
	  at System.IO.MemoryMappedFiles.MemoryMappedViewAccessor..ctor (int,long,long,System.IO.MemoryMappedFiles.MemoryMappedFileAccess)
	  at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateViewAccessor (long,long,System.IO.MemoryMappedFiles.MemoryMappedFileAccess)

Android does provide getpagesize(3); it's just an inline function.

The full fix will require two parts:

 1. Update MemoryMapImpl to P/Invoke
    libmonodroid.so!monodroid_getpagesize()
 2. Add a libmonodroid.so!monodroid_getpagesize() export.

This commit implements (1).
2013-08-12 16:59:14 -04:00
Rodrigo Kumpera 1b92a4148c Since MOBILE implies NET_4_* now, take this into account and simplify our ifdefs. 2013-02-11 18:42:18 -05:00
Sebastien Pouliot 52852db613 Use same name/casing for DllImport so we do not duplicate needlessly the extern entries in the metadata 2012-11-06 19:08:39 -05:00
James Bellinger 9322e0d16b ACLs now work on Windows. Tests all the way up to DirectorySecurityTest and FileSecurityTest.
NativeObjectSecurity is implemented.
I've done it in such a way that, for OSes that do not have a unified API for all ACLs,
overrides can be done in subclasses such as FileSystemSecurity without trouble.

ObjectSecurity, CommonObjectSecurity, and DirectoryObjectSecurity all implemented.
MutexSecurity, PipeSecurity, etc. all just add type specialization and nothing else. Implemented all of these as well.

Access and Audit rules now correctly use NTAccount in their string overloads (see unit tests).
The constructors all provide correct AccessMasks now. In other words, these classes are all now un-broken/no longer stubs.

More unit tests for CommonSecurityDescriptor and fixes to pass them.
A few had checks that were redundant (implemented by (Authorization|Audit|Access)Rule) as well. These have been removed.
The Allow Everyone Full Access default for null DiscretionaryAcls in CommonSecurityDescriptor is, I think,
properly implemented. This required some changes to GenericSecurityDescriptor as well, but now Mono matches
MS.NET on GetSddl/GetBinaryForm for null DiscretionaryAcl including roundtrip.

What's still missing:
(1) CommonAcl's RemoveAccess/RemoveAudit. RemoveAll and RemoveSpecific work so it's not a big issue.
(2) CommonAcl merging will not yet try to merge a CommonAce together with an ObjectAce.
(3) The various *Security constructors. Get/SetAccessControl work on files and directories.
However, you still have to create and then set. I am not too familiar with Mono runtime internal
calls, but to someone who is: If the SECURITY_ATTRIBUTES parameter to Create*'s lpSecurityDescriptor
pointed to the output of GenericSecurityDescriptor's GetBinaryForm, that would be a complete
implementation.
2012-07-07 18:45:06 -04:00
Rob Wilkens 8fe578747d Fixes a problem that was preventing mono from compiling
Somehow the compiler became more strict, and a not-implemented class is now
causing mono to fail to build.

The attached patch doesn't really fix anything besides letting it compile.

I was nice enough to throw a NotImplementedException() on the default
constructor.

The compile time error was:
System.IO.MemoryMappedFiles/MemoryMappedFileSecurity.cs(35,15): error CS0122:
`System.Security.AccessControl.ObjectSecurity
<System.IO.MemoryMappedFiles.MemoryMappedFileRights>.ObjectSecurity()' is
inaccessible due to its protection level

Feel free to reject this patch if I am the only one seeing this problem (on
Linux x86_64 build) after most recent git clone of mono/master.
2012-07-01 22:02:21 -04:00
Zoltan Varga de60ac57fb Fix the build. 2011-12-03 01:12:23 +01:00
Miguel de Icaza ee8ad64dc5 Include System.IO.MemoryMappedFiles in the MOBILE profile 2011-12-02 13:15:37 -05:00
Rodrigo Kumpera b2f29e14ba Implement a mobile ready version of memory mapped files. 2011-11-03 12:13:28 -02:00
Rodrigo Kumpera 60b9bc64ab Move all Mono.Unix deps into a single place and put a skeleton of MOBILE support for mmap'd files. 2011-11-03 12:13:27 -02:00
Marek Safar 81cf39742a Update few constant values 2011-10-07 10:11:30 +01:00
Marek Safar bd05c6c836 Some .net 4.0 api compatibility fixes 2010-12-15 11:12:07 +00:00
Marek Safar aad016fd87 Clean up few more warnings 2010-10-15 15:20:25 +01:00
Jb Evain 2f29080c3f 2010-05-25 Jb Evain <[email protected]>
* MemoryMappedViewAccessor.cs: fix API.


svn path=/trunk/mcs/; revision=157852
2010-05-25 13:59:46 +00:00
Jb Evain b34661184e 2010-05-25 Jb Evain <[email protected]>
* MemoryMappedFile.cs: add missing overloads.


svn path=/trunk/mcs/; revision=157850
2010-05-25 13:51:40 +00:00
Jb Evain 67cb3134c4 2010-05-25 Jb Evain <[email protected]>
* MemoryMappedFile.cs: make some helper methods private.


svn path=/trunk/mcs/; revision=157847
2010-05-25 13:37:35 +00:00
Jb Evain 2e8968f23e 2010-05-25 Jb Evain <[email protected]>
* MemoryMappedFileSecurity.cs: ifdef for NET_4_0.


svn path=/trunk/mcs/; revision=157846
2010-05-25 13:37:05 +00:00
Jb Evain 401a69270a 2010-04-15 Jb Evain <[email protected]>
* MemoryMappedFile.cs: implement CreateOrOpen.


svn path=/trunk/mcs/; revision=155494
2010-04-15 11:49:37 +00:00
Jb Evain 1a85aa1d2a eol
svn path=/trunk/mcs/; revision=155493
2010-04-15 11:49:13 +00:00
Jb Evain 259e22f6ee 2010-04-14 Jb Evain <[email protected]>
* MemoryMappedViewAccessor.cs
	* MemoryMappedFile.cs
	* MemoryMappedViewStream.cs:
		Properly retrieve the size of the mmapped file. Fixes the
		unit tests.


svn path=/trunk/mcs/; revision=155407
2010-04-14 16:38:53 +00:00
Miguel de Icaza 953f560654 2009-12-14 Miguel de Icaza <[email protected]>
* MemoryMappedFile.cs: Make this by default use the native
        interface (Mono.Unix.Native.Syscall) to map files and only support
        the FileStream.Handle when the user explicitly uses this API.

        The reason is that currently the code depends on the io-layer
        keeping parity between our handles and Unix file descriptors, this
        removes this dependency for most cases. 


svn path=/trunk/mcs/; revision=148366
2009-12-14 05:24:34 +00:00
Miguel de Icaza 76574e8f58 2009-12-13 Miguel de Icaza <[email protected]>
* SafeMemoryMappedViewHandle.cs (ReleaseHandle): implement. 

2009-12-13  Miguel de Icaza  <[email protected]>

        * MemoryMappedViewAccessor.cs: Derive from
        UnmanagedMemoryAccessor, remove explicit IDisposable
inheritance.
        (CreatePosix): Call Initialize on the base class to initialize. 
        (Dispose): Kill methods. 
        (Flush): Add.
        (MapPosix): no need to return out mmap_size, it is always size.

        * MemoryMappedFile.cs: Add FlushPosix.

        * MemoryMappedViewStream.cs: Update API.


svn path=/trunk/mcs/; revision=148361
2009-12-14 01:40:50 +00:00
Miguel de Icaza 04db5e3842 2009-12-10 Miguel de Icaza <[email protected]>
* MemoryMappedFile.cs: Updated to the new Beta API, fill in some
	blanks, map some new flags, obey some settings, throw some
	exceptions. 

svn path=/trunk/mcs/; revision=148003
2009-12-10 05:55:57 +00:00
Zoltan Varga 08351b9b95 2009-09-05 Zoltan Varga <[email protected]>
* MemoryMappedViewAccessor.cs: New net 4.0 class.

	* MemoryMappedViewStream.cs: Move the mmap code to MemoryMappedFile.cs,
	so it can be used by ViewAccessor as well.

svn path=/trunk/mcs/; revision=141375
2009-09-04 22:22:58 +00:00
Zoltan Varga 1994c7d03b 2009-08-30 Zoltan Varga <[email protected]>
* MemoryMappedViewStream.cs: Implement this for unix.

svn path=/trunk/mcs/; revision=140930
2009-08-29 23:59:13 +00:00
Zoltan Varga 4174126774 2009-08-29 Zoltan Varga <[email protected]>
* net_4_0_System.Core.dll.sources: Add System.IO.MemoryMappedFiles/*.cs
	and Microsoft.Win32.SafeHandles/SafeMemoryMappedFileHandle.cs.

svn path=/trunk/mcs/; revision=140929
2009-08-29 23:59:04 +00:00