Commit Graph
265 Commits
Author SHA1 Message Date
stephentoub 675beeeee6 Fix several issues in UnixFileStream
I'm trying to track down the cause of a sporadic failure in CI of the MemoryMappedFilesTests.DataShared test.  In doing so, I've run across a few issues to be fixed (though I'm not sure any of these are the cause):

- Fix the checking/setting of several FileOptions... we weren't correctly treating the options as a [Flags], which meant we'd incorrectly ignore some options if multiple options were specified.

- When opening a FileStream, if the PosixFAdvise or SeekCore failed, we weren't deterministically disposing of the file handle, instead leaving it up to finalization to close.

- If Close on the file descriptor fails (e.g. it's interrupted), we don't attempt a retry, by design.  However, closing of the handle is what releases the advisory lock we placed on the file descriptor when the UnixFileStream was constructed.  Added an explicit call to remove the lock, separate from closing the descriptor. (I thought this one would have been the cause of the sporadic test failure, but if it were the problem, the assert in SafeFileHandle.ReleaseHandle should have fired, and it didn't in the one occurence I saw since that assert got added.)

- Removed several stale TODOs and replaced them with explanatory comments.

- Added several more Debug.Asserts

Separately, I also tweaked TempFile to simplify its ctor to use File.WriteAllBytes.


Commit migrated from https://github.com/dotnet/corefx/commit/1e0cd691eee8bd65a3fed666ac4ea6a208a78b8c
2015-09-23 12:33:52 -04:00
Stephen Toub b4e2952db8 Merge pull request dotnet/corefx#3372 from stephentoub/case_sensitivity
Add internal platform-agnostic case sensitivity detection

Commit migrated from https://github.com/dotnet/corefx/commit/ed45618b1ef82f1efb661ea0e80c4bd824433079
2015-09-22 22:14:32 -04:00
Jeremy Kuhne 2a13ee707b Switch to use localhost for test server name.
On the MS corpnet, there is a server called "Server" which is killing the perf of the tests.
(Via VPN tests still won't finish after 30+ minutes.) Using LocalHost avoids this.


Commit migrated from https://github.com/dotnet/corefx/commit/d1e7521f028e9564308a05b3b7ef4abf47f41509
2015-09-22 15:05:25 -07:00
stephentoub 02007d2533 Add platform-agnostic case sensitivity detection
After the recent refactoring based on introducing native shims, the only reason there are special builds of System.IO.FileSystem and System.IO.FileSystem.DriveInfo for each of Linux and OS X is because of PathInternal.CaseSensitive/CaseInsensitive.cs, which just provides a hard-coded value as to whether the target platform is case-sensitive or case-insensitive-but-preserving.  Similarly, these files are the only things forcing System.IO.Compression.ZipFile to not be completely platform-agnostic and to have separate Windows/Unix builds.

This commit recombines those assemblies by adding a platform-agnostic helper that simply creates a temporary file with upper-case letters and then checks whether that file can be found via the lower-cased version.  This isn't perfect, in that it's possible to mount multiple file systems each with different case sensitivities, but a) it's better than the hardcoded version we currently have, and b) I don't know of any better portable solution.

(Issue dotnet/corefx#3156 tracks adding an API to provide information on case sensitivity.  This change can be replaced by using such an API if/when it's available.)


Commit migrated from https://github.com/dotnet/corefx/commit/62ba788d4730be24cff0ff0432f43bcc7b9e4561
2015-09-22 12:35:47 -04:00
Jeremy Kuhne 16099fc5a4 Move max path directory check up front.
No need to create a bunch of intermediate directories when we'll fail at the end.
This was having significant impact on test times with dotnet/corefx#3192.


Commit migrated from https://github.com/dotnet/corefx/commit/d5f7c91ac455244195135c48ab3b94bb24eeb78f
2015-09-21 22:52:39 -07:00
Nick Guerrera d7753ed3b3 Let shim handle platform support of posix_fadvise
Call the shim always and ignore ENOTSUP. This will let new platforms
with posix_fadvise do the right thing without code changes.

Also, remove unused declarations from */Interop.Libraries.cs.


Commit migrated from https://github.com/dotnet/corefx/commit/db74dd930ab6037edfb63a0a45ab614789d1dbb1
2015-09-20 18:04:46 -07:00
Jonathan Miller fb3803dfe9 Finishing up PAL'ing Unix\libc (non-networking and crypto)
PInvoke calls


Commit migrated from https://github.com/dotnet/corefx/commit/f8fd4b7ff731cd8951e6da0bb70ca206533866bb
2015-09-17 13:05:29 -07:00
Ian Hays 0e2ae5be2d Fixed test bug with FileInfo_GetSetTimes
resolves dotnet/corefx#3272


Commit migrated from https://github.com/dotnet/corefx/commit/50aa6bbfd3921a9312392f534c5986a193486c35
2015-09-16 11:03:32 -07:00
Wes Haggard a0d524ea1c Merge pull request dotnet/corefx#3177 from akoeplinger/update-dnx
Update build to use DNX beta7 instead of beta5

Commit migrated from https://github.com/dotnet/corefx/commit/34e8271eae1e8cbda5389f6b152c1f27994ca6c2
2015-09-16 10:34:50 -07:00
Stephen Toub 8dc75dfdc7 Merge pull request dotnet/corefx#3265 from nguerrera/shim-work
Increase native compilation warnings and fix the fallout

Commit migrated from https://github.com/dotnet/corefx/commit/77b35ab922586c69b51f4df66f3d8149f940e1a7
2015-09-16 13:15:56 -04:00
Nick Guerrera 23277810e6 Increase native compilation warnings and fix the fallout
We were using -Wall but now use -Weverything and opt out of only
a handful of issues such as C++-98 compat, which we don't need.

The most notable impact is that the compiler now catches
narrowing implicit conversions, which was also the primary
motivation for doing this now as there was known debt in our
unsupervised usage of 64-bit types for sizes.

We now assert on bad buffer sizes *and* retain full checks in
release builds to be completely defensive against overflow.

We now use int32_t for scratch buffer sizes. int64_t remains for
file offsets and uint64_t remains for memory mapped files, but
int32_t for scratch eliminates a bunch of managed casts and
therefore makes it easier to reason about overflow prevention.

INT32_MAX is also the most portable limit on these buffer sizes
because the behavior of functions like read is only implementation
defined when the input size is greater than SSIZE_MAX and ssize_t
is int32_t on the lowest common denominator of modern platforms.

Enums corresponding to platform values are now enum X : T instead
of enum class X : T. The PAL_* names are descriptive enough without
scoping and the implicit conversion to raw integer is actually helpful
to avoid a bunch of casts, which are otherwise needed to interop with
the corresponding native API.


Commit migrated from https://github.com/dotnet/corefx/commit/648c01d69fba8d23750122d9823f53257785c8ca
2015-09-16 09:15:33 -07:00
stephentoub f6ff0fe5eb Update UnixFileStream to read more from OS after using buffer
Stream.Read is not required to hand back as many bytes as the caller requested; a conforming implementation can hand back any number > 0 and <= count when there's still data left in the stream, and many streams do frequently return < count.  UnixFileStream currently frequently does this, returning what's left in the internal buffer when there's any data left in the buffer.

Win32FileStream, however, in this case does a subsequent read from the underlying file handle to try to give back as much data as the user requested.  This request still may not return the requested count, either because we reached the end of the file or because Windows decided not to return as much data as was requested, but it frequently will.  As such, some code has been written to expect this behavior, and while that code is flawed and should be fixed even on Windows, it frequently works.

To maintain the consistency with Windows, this change updates UnixFileStream to do such a subsequent read if we tried to satisfy a Read request purely from the buffer but didn't have as much data as the user requested.  I've not added a test for the behavior, because a) it's not guaranteed by Stream.Read, but more importantly b) the test could fail because the OS may not give us back what we requested.


Commit migrated from https://github.com/dotnet/corefx/commit/da456e315cf4c52334f9ed6315c0523af534bc37
2015-09-15 22:55:05 -04:00
Alexander Köplinger 3e20a867b2 Update build to use DNX beta7 instead of beta5
The corefx build used an older beta5 version of DNX which hardcoded the path to bash in dnu, breaking the build on FreeBSD.
Updating DNX to the latest "stable" beta7 release fixes this.

After updating I noticed a few test projects didn't build anymore as they were missing some dependencies in project.json, added those.

Fixes dotnet/corefx#3173


Commit migrated from https://github.com/dotnet/corefx/commit/6df77fdbb6cf8e0d35a3074bb325f7810085daa3
2015-09-16 02:12:26 +02:00
Nick Guerrera 3fbfac1ae5 Merge pull request dotnet/corefx#3250 from dotnet-bot/from-tfs
Merge changes from TFS

Commit migrated from https://github.com/dotnet/corefx/commit/ee819c778c5d27c4edba9cebf6002ebd87bf7708
2015-09-15 08:18:26 -07:00
Wes Haggard ff07322b31 Fixed PackageTargetRuntime casing to be lower case for System.IO.FileSystem so that the resolution from nuget will work... yes it is case-sensitive for these runtime ids :(
[tfs-changeset: 1525012]


Commit migrated from https://github.com/dotnet/corefx/commit/2f6f4b5a64bb2160603d398047d5da3be18f0492
2015-09-14 16:56:33 -07:00
Ian Hays 71345b4a45 Fixed OSX file creation time format
FileInfo.CreationTime on OSX was returning a correctly timed but incorrectly formatted DateTime. This commit fixes this issue and adds coverage to a existing test to fill the test gap that let the issue through.


Commit migrated from https://github.com/dotnet/corefx/commit/e59a99c6628b817e95a43880fe14cbf602602b9e
2015-09-14 10:51:15 -07:00
stephentoub b07d619076 Reduce FileSystem inner loop test time from 90 to 5 seconds
Three tests were consuming the vast majority of the time:
- DirectoryLongerThanMaxLongPathWithExtendedSyntax_ThrowsPathTooLongException. It was taking 70 seconds on my machine.  I moved it to outer loop.
- ManyConcurrentWriteAsyncs.  It uses a MemberData that results in it executing ~40 times, for a combined time of around 7 seconds on my machine.  I made one combination run in inner loop and moved the rest to outer.
- CopyToAsyncBetweenFileStreams.  Same MemberData, same solution.


Commit migrated from https://github.com/dotnet/corefx/commit/03205295cc6834b1fdcd8b7ba364515f4ec7164a
2015-09-12 19:46:49 -04:00
Stephen Toub 1b40da7c89 Merge pull request dotnet/corefx#3193 from stephentoub/fix_fs_osx_time_tests
Fix failing FileSystem tests on OS X

Commit migrated from https://github.com/dotnet/corefx/commit/81263d7b155f225c4dac61e91bb1d0bdddba9de1
2015-09-11 17:45:28 -07:00
stephentoub 8b936e6509 Fix failing FileSystem tests on OS X
Several FileSystem tests are failing on OS X because the tests are expecting that file/directory creation time can be changed on Unix.  Fixing the tests.


Commit migrated from https://github.com/dotnet/corefx/commit/12c0d738a0c234b707b0c99e40b3cb760df8096e
2015-09-11 14:51:53 -07:00
Jonathan Miller 9e25edd8d1 Moving more Unix\libc function calls over to the PAL layer
along with fixing up the Interop calls for the switched
functions.


Commit migrated from https://github.com/dotnet/corefx/commit/aed4a23f36ace07e7f5f33bf5a28808fd215fea6
2015-09-11 14:09:37 -07:00
Dmitry Turin 946da9d4e3 Fix System.IO.FileSystem.Tests
System.IO.FileSystem.Tests leaves behind temp directories in %TMP%.
This commit fixes this issue.


Commit migrated from https://github.com/dotnet/corefx/commit/889d024aca35e0c98500f5b34e6db1dc9071edf7
2015-09-11 18:06:35 +03:00
Nick Guerrera 753e95f292 Shim memory map functions
Commit migrated from https://github.com/dotnet/corefx/commit/e001833c95b622bcdcd66f3e4a56cd83e648f849
2015-09-10 18:10:43 -07:00
Stephen Toub 27f4c46d83 Merge pull request dotnet/corefx#3118 from stephentoub/fs_enum_unix_tweaks
Two perf tweaks to UnixFileSystem's enumeration iterator

Commit migrated from https://github.com/dotnet/corefx/commit/49701f5f87e732709eccd1352d30fd510563c224
2015-09-08 10:05:19 -07:00
stephentoub 2f2611643a Two perf tweaks to UnixFileSystem's enumeration iterator
1. When enumerating directories recursively, we were computing the Path.Combine for the user path twice for each directory: once as part of pushing the string onto the exploration stack, and once as part of yielding it.  This fixes it to only ever compute it once per directory.

2. Due to https://github.com/dotnet/roslyn/issues/5062, a field was being added to the iterator object for isDir.  I changed the switch to an if/elseif/else to shrink the size of the object.  I also rearranged the order in which we push the directory onto the evaluation stack and yield the string in order to allow userPath not to be lifted, either.


Commit migrated from https://github.com/dotnet/corefx/commit/a73f471abdb054b9dad1dd3a998dd0fd16dd32d0
2015-09-07 22:46:28 -04:00
stephentoub 1344081a9d Delete EnumerableUtils from System.IO.FileSystem.Tests
Dead code.

It also contained the only types in the test assembly that were in a namespace other than System.IO.FileSystem.Tests (there are still types that have no namespace).


Commit migrated from https://github.com/dotnet/corefx/commit/1616cc5e5328eec964874f0afe683e9292789cf7
2015-09-07 18:47:52 -04:00
Eric St. John 10898f843d Add x-plat support to FileSystem package
This also refactored the Win32 implementation to be used as the 'dotnet' implementation
on any windows platform.  This well do the right thing for future OOB target frameworks.

[tfs-changeset: 1521958]


Commit migrated from https://github.com/dotnet/corefx/commit/2c0de8825f064afc183c63b5647adb45d0359e7a
2015-09-03 14:12:40 -07:00
Jonathan Miller 6f86fe0671 Converting simple almost-one-line functions in I/O and Process over
from platform-specific P/Invoke to the PAL layer


Commit migrated from https://github.com/dotnet/corefx/commit/062c0088b90826510e9b3a8871ac50e837703cb4
2015-09-02 14:36:28 -07:00
Jeremy Kuhne dc3f2ae9e2 Clean naming and disable stack pathhelper
PathHelper doesn't handle growing past MAX_PATH when using
the stackalloc version. dotnet/corefx#3009 tracks this.


Commit migrated from https://github.com/dotnet/corefx/commit/ed2d1a890dd79a0871531c8d45b48506781afe25
2015-08-28 16:47:39 -07:00
Jeremy Kuhne b2782d7f70 Unblock paths > MAX_PATH without extended syntax.
Also allow directories up to max component length (255) as opening does not
require extended syntax.


Commit migrated from https://github.com/dotnet/corefx/commit/496c66e0b498077d5d349d324713a51be6b91c68
2015-08-28 15:32:31 -07:00
Nick Guerrera 658498b97b Merge pull request dotnet/corefx#2998 from nguerrera/fix-readdir-casing
Fix casing of Interop.ReadDir.cs to match function name

Commit migrated from https://github.com/dotnet/corefx/commit/08889f82399d99e7adcac8add4a5e07d34adf8b6
2015-08-27 13:37:52 -07:00
Nick Guerrera 61e1e8a437 Fix casing of Interop.ReadDir.cs to match function name
Commit migrated from https://github.com/dotnet/corefx/commit/9d65dc9349a83ec17b8aef464e7770caafa4dc0e
2015-08-27 11:35:48 -07:00
Nick Guerrera 1d93864f50 Shim chmod, mkdir, mkfifo to make permission handling consistent
We were mixing Interop.libc.Permissions with Interop.Sys.Stat. This
is not incorrect because the numeric values are fixed by POSIX, but
it was inconsistent and confusing.

We now have shims for all functions taking mode_t.


Commit migrated from https://github.com/dotnet/corefx/commit/057c39493b29d2f5f25543b4d569b27ddf170674
2015-08-27 11:21:38 -07:00
Nick Guerrera 453f5e9697 Remove unused gnu_get_libc_version P/Invoke declaration
This was previously needed for the logic to switch between GNU
strerror_r and POSIX strerror_r, but that is now addressed by the shims.


Commit migrated from https://github.com/dotnet/corefx/commit/ff96ce829df16f8a0b58f568e9b696fa19e698a8
2015-08-27 08:07:54 -07:00
Stephen Toub 326e7d7fb9 Merge pull request dotnet/corefx#2929 from stephentoub/filestream_async_buffering
Improve FileStream WriteAsync buffering and performance

Commit migrated from https://github.com/dotnet/corefx/commit/6cffbc2fcd0c9e3d6b91828a874daf6c77e528af
2015-08-26 16:01:11 -04:00
Jonathan Miller 3fae217002 Switching readdir calls over from directly pinvoking the OS calls
per-platform to pinvoking the PAL. This will make it easier for
us to manage the slight differences in readdir and dirent.


Commit migrated from https://github.com/dotnet/corefx/commit/da4ed3caa56aa0bd5080f2bc5c2126b3debf2c6d
2015-08-25 13:08:27 -07:00
stephentoub 26253f6265 Add more tests for FileStream
- Mainly, I added several tests (with lots of theory-based parameterized inputs) to stress WriteAsync: many concurrent writes, long chains of writes, etc., for various size inputs and buffers, async vs not, etc.
- There were multiple variations on Flush tests based on whether to use Flush(), Flush(false), or False(true).  I combined these all into single theories.
- I then added some more Flush tests for some missing cases highlighted by code coverage, e.g. flushing reads.
- I then duplicated these tests for FlushAsync, and added some additional tests specific to FlushAsync, e.g. cancellation.
- I added a few tests for pipes.


Commit migrated from https://github.com/dotnet/corefx/commit/bb34d5a458613faa39d3808a8a352e62e3bcf52f
2015-08-24 16:59:59 -04:00
stephentoub 550a223701 Fix buffering changes to FileStream WriteAsync
- We now properly handle the case where multiple overlapped writes are issued while a flush is in progress (offsets were being handled incorrectly).
- We now correctly optimize buffering for the common case where a write completely fills the buffer, such that we now do a single write for that buffer instead of doing a write for the almost full buffer and one for the additional data.
- We now have some additional optimizations to avoid creating WhenAll tasks if it's not necessary.
- The flush and write tasks are not appropriately coordinated in all cases.


Commit migrated from https://github.com/dotnet/corefx/commit/f646fa6836b13154c3f52254cce5dcb5ab640d74
2015-08-24 16:59:56 -04:00
tymlipari 4113737a6e Handle internal overflow of the write buffer in WriteAsync by introducing new cases:
1) Internal buffer overflows, but write can fit in next buffer - Fill the existing buffer, copy the remaining data into a new buffer, and flush the original to disk

2) Internal buffer is non-empty, overflows, and the remaining data won't fit in a second buffer - Chain the flush operation to a second write operation which writes the entire incoming block directly to disk.

Additionally, adds a new unit test to ensure the different buffering cases are being covered.


Commit migrated from https://github.com/dotnet/corefx/commit/b69caa929d3cb3b87574ee31a651d799f61e3a75
2015-08-24 16:50:56 -04:00
Nick Guerrera 16d140fd57 Use shims for open, close, unlink, shm_open, shm_unlink
Commit migrated from https://github.com/dotnet/corefx/commit/709afe1d4f6b2d5ca75a0565e4c24e16a5254ee7
2015-08-20 15:50:44 -07:00
stephentoub 4992aaa978 Fix access to user's home directory on Unix
Today in several places we get a user's home directory by accessing the HOME environment variable.  This is the right place to check first, but in certain cases it may not be set, such as in initialization scripts.

This commit implements a fallback, such that if HOME doesn't have a path, we consult the pw_dir path from a call to getpwuid_r for the current user.

As long as I was adding getpwuid_r to the native shim, I also moved our existing geteuid and getegid imports to the shims.


Commit migrated from https://github.com/dotnet/corefx/commit/5b8f55c8d43a880147478cb7d2191fa607000594
2015-08-19 15:06:32 -04:00
Nick Guerrera b4c8ad5504 Use Stat from System.Native shim throughout
Replace all usage of GetFileInformation from libcoreclr with newer
Stat from System.Native shim.


Commit migrated from https://github.com/dotnet/corefx/commit/2de10733ebca8a9612f72ea9df490a14edfb315f
2015-08-16 21:42:02 -07:00
Eric St. John d7a0ae297b Update corefx packages to latest
Commit migrated from https://github.com/dotnet/corefx/commit/23f0b695bd162e0f665427c95180dc21931e5c70
2015-08-14 15:43:23 -07:00
Eric St. John 9142282fd7 Fix ref-def mismatch in FileSystem tests
Since FileSystem tests are using a project reference to
System.Runtime.Extensions, and S.R.E uses a project reference
to System.Diagnostics.Debug (due to
https://github.com/dotnet/corefx/issues/2817) these tests  must
also use a P2P reference to S.D.D.


Commit migrated from https://github.com/dotnet/corefx/commit/0cc8949ef5474c8da77cf873ed5e01ea1cd91d21
2015-08-14 14:50:56 -07:00
Eric St. John 77309d4821 Update the version of all assemblies
This change updates the assembly versions of all of the corefx assemblies
as needed after we shipped stable versions.  Assemblies with API differences
get a minor version bump.  Assemblies with only bugfixes get a build version
bump.

In order to facilitate this I had to update the reference assemblies, so I took
the opportunity to port them all to the open.

[tfs-changeset: 1514419]


Commit migrated from https://github.com/dotnet/corefx/commit/40723b795917f2e98b64d45c17effb2546dd0cae
2015-08-13 17:07:57 -07:00
Stephen Toub 06871ac655 Merge pull request dotnet/corefx#2795 from dotnet-bot/from-tfs
Merge changes from TFS

Commit migrated from https://github.com/dotnet/corefx/commit/0268cb85fe9e0feebdccb18189f79d93c2d4b6de
2015-08-13 19:00:09 -04:00
Eric St. John 6cb20f1e7c Fix regression caused by https://github.com/dotnet/corefx/commit/dotnet/corefx@b00fed79842d13d9931cf963749aa00006fdacc0
[tfs-changeset: 1514359]


Commit migrated from https://github.com/dotnet/corefx/commit/0d0c501379b6091b4613cac512a1c22dd9db16d6
2015-08-13 14:46:34 -07:00
Ian Hays 1bc633088f Fixed test that was leaving temp directories in root folder
One of the Extended Path FileSystem tests was leaving temporary test directories in the root folder of the running directory. This small change modified the tests to instead treat the user's temp directory as the root.


Commit migrated from https://github.com/dotnet/corefx/commit/bd2d87d7abcf092840e0929c6df1116665f90460
2015-08-13 14:28:37 -07:00
Justin Van Patten 25383ad4d0 Eliminate extra IFileSystemObject allocation on Win32 and Unix
FileSystemInfo/FileInfo/DirectoryInfo all carry a IFileSystemObject
which is used internally for the actual implementation. While this
enables FileSystemInfo/FileInfo/DirectoryInfo to be used with WinRT,
it comes with the cost of an extra unnecessary allocation for plain
Win32 and Unix. This change eliminates the allocation on Win32 and
Unix. After this change, the extra object allocation only happens
when the WinRT APIs need to be used.


Commit migrated from https://github.com/dotnet/corefx/commit/b00fed79842d13d9931cf963749aa00006fdacc0
2015-08-13 10:49:08 -07:00
Justin Van Patten f391a759ca Rename [Unix|Win32]FileSystemObject.cs files
Rename the following files in preparation for a refactor:
- UnixFileSystemObject.cs -> FileSystemInfo.Unix.cs
- Win32FileSystemObject.cs -> FileSystemInfo.Windows.cs

The renames are being done in their own commit first to help git
maintain source history for the renamed files.


Commit migrated from https://github.com/dotnet/corefx/commit/24820ce8305c87d520d776ebcb300e37dddc48c4
2015-08-13 10:49:07 -07:00
Stephen Toub ce4b088056 Merge pull request dotnet/corefx#2737 from ianhays/overlap
Removed USE_OVERLAPPED from FileSystem

Commit migrated from https://github.com/dotnet/corefx/commit/0c677d5b22514f41119ec7de4ac403a42f04e914
2015-08-11 22:01:45 -04:00